commit b029b42e253120c33e4bf958db0b23120076152a Author: GAO Xiaoxin Date: Sun Jun 28 00:46:39 2020 +0800 Postfix #98616 XA PREPARE/XA COMMIT/XA ROLLBACK lost if mysql crash just after binlog flush If a trx in trx_sys->rw_trx_list has been rollbacked in trx_rollback_resurrected during start-up recover due to trx->xid->get_gtrid_length()==0, xarecover_handlerton should skip this trx rather than do hton->rollback_by_xid, which will lead mysql crash. diff --git a/sql/xa.cc b/sql/xa.cc index 2b3960d..af3c202 100644 --- a/sql/xa.cc +++ b/sql/xa.cc @@ -155,8 +155,12 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, transaction_cache_insert_recovery(info->list + i); info->found_foreign_xids++; } else { - sql_print_information("rollback xid %s due to find xa transaction partial executed", target_xid.xid_to_str(buf)); - hton->rollback_by_xid(hton, info->list + i); + if (target_xid.get_gtrid_length() > 0) { + sql_print_information("rollback xid %s due to find xa transaction partial executed", target_xid.xid_to_str(buf)); + hton->rollback_by_xid(hton, info->list + i); + } else { + sql_print_information("find an trx with gtrid_length=0, which means a rollbacked trx."); + } } continue;