From 8d12dd8f503282179a078f2f883b88f6ccee5ebd Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 11 May 2022 14:33:20 +0200 Subject: MDEV-28053 Sysbench data load crashes Galera secondary node in async master slave setup This patch fixes a problem that arises when a Galera node acts as a replica for native replication. When parallel applying is enabled, it is possible to end up with attempts to write binlog events with gtids out of order. This happens because when multiple events are delivered from the native replication stream and applied in concurrently, it is for them to be replicated to the Galera cluster in an order which is different from the original order in which they were committed in the aync replication master. To correct this behavior we now wait_for_prior_commit() before replicating changes though galera. As a consequence, parallel appliers may apply events in parallel until the galera replication step, which is now serialized. --- sql/wsrep_trans_observer.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/wsrep_trans_observer.h') diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h index 837bad4c50f..cde8163cf4f 100644 --- a/sql/wsrep_trans_observer.h +++ b/sql/wsrep_trans_observer.h @@ -229,6 +229,10 @@ static inline int wsrep_before_prepare(THD* thd, bool all) WSREP_DEBUG("wsrep_before_prepare: %d", wsrep_is_real(thd, all)); int ret= 0; DBUG_ASSERT(wsrep_run_commit_hook(thd, all)); + if ((ret= thd->wsrep_parallel_slave_wait_for_prior_commit())) + { + DBUG_RETURN(ret); + } if ((ret= thd->wsrep_cs().before_prepare()) == 0) { DBUG_ASSERT(!thd->wsrep_trx().ws_meta().gtid().is_undefined()); -- cgit v1.2.1