[MDEV-21469] Implement crash-safe logging of the user XA Created: 2020-01-13 Updated: 2024-01-11 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Affects Version/s: | 10.5 |
| Fix Version/s: | 10.6 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Andrei Elkin | Assignee: | Brandon Nesterenko |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | XA | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||
| Description |
|
This task is ensued by In fact there's no issue in the ordering of logging of XA PREPARE into the binary log and transaction preparing in Engine. The chosen by upstream method of the logging goes first is not really incorrect but just needs So in case the server crashes having XA-prepared "transaction" binlogged but not yet XA-COMMIT or XA-ROLLBACK are logged compatibly with XA-PREPARE and therefore |
| Comments |
| Comment by Sujatha Sivakumar (Inactive) [ 2020-02-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello Andrei, Please review MDEV-21469 changes. Branch name: bb-10.5-MDEV_21469 Thank you. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sujatha Sivakumar (Inactive) [ 2020-03-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Design of XA recovery:- PREPARE XA1 Engine has the following view of above XA transactions. XA1 - Complete in Engine During server restart binlog recovery is initiated.
'XA' recovery list is prepared as shown below. Parse 1 of Binary log: PREPARE XA1 name state in_engine_prepare
PREPARE XA2 name state in_engine_preare
COMMIT XA1 name state in_engine_prepare
The above list is passed on to engine during 'ha_recover(xid_list, XA_list)'. By checking with engine update the 'in_engine_prepare' filed in list. Since engine has only 'XA2' in prepared state it is marked with 'Y' flag. name state in_engine_prepare
Now the above list is returned back to binlog recovery code. Parse 2 of binary log to replay the events: PREPARE XA1 - Compare XA1 state with 'state' in list. if (PREPARE == C ) No. This transaction is complete. Donot apply. COMMIT XA1 - if (COMMIT == C) yes. PREPARE XA2 if (PREPARE == P) yes Then replay the event from binary log. Recovery of XA_COMMIT/XA_ROLLBACK: PREPARE XA1 Let us assume server has crashed at this stage. Engine has the following view of above XA transactions. XA1 - Complete in Engine Parse 1 of Binary log: PREPARE XA1 name state in_engine_prepare
PREPARE XA2 name state in_engine_preare
COMMIT XA1 name state in_engine_prepare
COMMIT XA2 name state in_engine_prepare
The above list is passed on to engine during 'ha_recover(xid_list, XA_list)'. Updated list after checking with engine is given below. name state in_engine_prepare
Now the above list is returned back to binlog recovery code. Parse 2 of binary log to replay the events: PREPARE XA1 - Compare XA1 state with 'state' in list. if (PREPARE == C ) No. This transaction is complete. Donot apply. COMMIT XA1 - if (COMMIT == C) yes. PREPARE XA2 - Compare XA2 state with 'state' in list if (PREPARE == P) yes COMMIT XA2 - if (COMMIT == C) Then 'COMMIT XA2' is present only in binlog. Not in engine. Similar logic applies for ROLLBACK as well. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2020-03-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sujatha, thanks for an awesome piece of work! We may polish the high-level description later though (for which I don't have time right now). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2020-06-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Howdy, Serg. Could you please check two commits that top bb-10.5-MDEV_21469 branch To MDEV-21469 Pre-commit: make sure binlog hton is listed in the head of the user XA participants list I already pointed (in the last weekly call) that changing trans_register_ha() is the least intrusion method, as well as with the least extra operations for non-user-xa executions (the cost is of that of one if). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-12-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
https://github.com/MariaDB/server/commit/dc92235f21e | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-07-26 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MySQL 8.0.30 includes WL#11300 Crash-safe XA + binary log. However, MySQL Bug #76233 XA prepare is logged ahead of engine prepare has not been closed yet. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Brandon Nesterenko [ 2023-08-10 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Changed the relationship from blocks to relates to. In reality, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Brandon Nesterenko [ 2023-12-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Changed the fix version to 10.6 because the patch for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-12-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Note that we have to ensure that this MDEV and MDEV-31949 are both solved and tested together | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kristian Nielsen [ 2023-12-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Repeating my comment from MDEV-31949: Let me just state once and for all: The idea to binlog first and prepare in engine later for XA prepare will not be approved. Don't spend more effort in this direction.
For these reasons, the engine prepare must come before the binlog write for XA PREPARE. Again, patches that does the opposite will be rejected in review. |