Bug #87389 Replication position not persisted correctly for XA transactions
Submitted: 11 Aug 2017 7:30 Modified: 21 Aug 2017 18:51
Reporter: Wei Zhao (OCA) Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:mysql-5.7.17 OS:Any
Assigned to: CPU Architecture:Any
Tags: position, replication, xa

[11 Aug 2017 7:30] Wei Zhao
If an XA_PREPARE_EVENT log event is executed in SQL thread rather than its slave worker thread, the replication positions was not flushed to table after executing the event. We have to do so after executing the XA_PREPARE log event.

Note that unlike XID_EVENT, we can not update the positions in the user transaction otherwise we would hold transactional row locks of the slave_relay_log_info table for too long and block many other active transactions for too long.

Also, for XA_PREPARE_EVENT  executed by slave worker threads, the positions are already updated in rli object and stored to the worker's row in the slave_worker_info table, so don't do that again for this event in the places as shown in the patch.

Also, I removed several lines of useless code in the related function and an unused data member in a related class.

That's what my patch does. It proves to be working.

How to repeat:
Set up a master-slave replication, and run massive XA transactions on master and kill master's and/or slave's 'mysqld' randomly frequently.

Suggested fix:
See above section and my patch.
[11 Aug 2017 7:31] Wei Zhao
this patch fixes the bug

Attachment: xa-prepare-relaylog-info.diff (application/octet-stream, text), 6.76 KiB.

[21 Aug 2017 18:51] Bogdan Kecman

Thanks for the report, I did reproduce the bug and your patch do seem to fix it.

all best
[17 Nov 2017 1:56] Wei Zhao
adding the patch as contribution

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: xa-prepare-relaylog-info.diff (application/octet-stream, text), 6.76 KiB.