Commit 5d6692d
Bug#32416819 ASSERTION "UT_LIST_GET_LEN.TRX_SYS->MYSQL_TRX_LIST. == 0"
ON SHUTDOWN Note: This commit on trunk is different from 8.0 Background: ----------- The trx_sys->mysql_trx_list maintains a list of trx_t objects created for user transactions. When the `USE <database>` statement is run, a trx_t object is created for the THD running this query and added to this list. When the connection is closed, the trx_t object of the THD is freed and removed from this list. During shutdown, all the connections are closed before trx_sys is closed. When closing trx_sys, it is expected that all trx_t objects in trx_sys->mysql_trx_list are freed and the list is empty. In replication, when the applier sees an `XA START`, it detaches the THD from the handlertons by storing a backup in the engine's ha_data. In case of InnoDB, the trx_t created for the THD is stored in ha_data and is made nullptr; but not removed from the mysql_trx_list. In replication, the detached engine ha_data is reattached after the XA transaction is processed. During the reattach, the trx_t is restored from the ha_data back to the THD. By design, the detach happens when `XA START` is encountered by the applier. When the applier sees an `XA PREPARE`, the reattach is done via `applier_reset_xa_trans` calling `attach_native_trx`. When the applier sees an `XA COMMIT .. ONE PHASE`, the reattach is done in `ha_commit_low`. If the server is shutdown, the applier performs the reattach in `ha_rollback_low`. The binlog applier can be simulated by enabling `pseudo_replica_mode` and running a `BINLOG '0'`. Issue: ------ When the XA transaction is empty, the ha_list is nullptr. The reattach logic is performed only when ha_list is non-empty. Hence, if the server is shutdown after the applier detaches the engine (i.e, after running an `XA START`), the applier would never reattach the ha_data which leads to the assert when InnoDB closes trx_sys. Due to the design, the problem is seen only with the reattach in `ha_commit_low` and `ha_rollback_low`. Fix: ---- Ensured that reattach is done even if ha_list is empty. Change-Id: Ida617d067d112914c9d55ef4cde9f91956d19a081 parent ec3e63d commit 5d6692d
File tree
4 files changed
+681
-39
lines changed- mysql-test
- include
- r
- t
- sql
4 files changed
+681
-39
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
0 commit comments