diff options
author | Daniele Sciascia <daniele.sciascia@galeracluster.com> | 2020-03-21 08:17:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-21 09:17:28 +0200 |
commit | 9394cc89143e4fce3126a96ac1c8a91a66d71dea (patch) | |
tree | d21d24e28e3c28ac25815e4509b146f5e9774d97 /sql/wsrep_trans_observer.h | |
parent | bd3c8f47cd16b4795dd073bbd30decd804c76969 (diff) | |
download | mariadb-git-9394cc89143e4fce3126a96ac1c8a91a66d71dea.tar.gz |
MDEV-21675: Data inconsistency after multirow insert rollback (#1474)
* Remove dead code
* MDEV-21675 Data inconsistency after multirow insert rollback
This patch fixes data inconsistencies that happen after rollback of
multirow inserts, with binlog disabled.
For example, statements such as `INSERT INTO t1 VALUES (1,'a'),(1,'b')`
that fail with duplicate key error. In such cases the whole statement
is rolled back. However, with wsrep_emulate_binlog in effect, the
IO_CACHE would not be truncated, and the pending rows events would be
replicated to the rest of the cluster. In the above example, it would
result in row (1,'a') being replicated, whereas locally the statement
is rolled back entirely. Making the cluster inconsistent.
The patch changes the code so that prior to statement rollback,
pending rows event are removed and the stmt cache reset.
That patch also introduces MTR tests that excercise multirow insert
statements for regular, and streaming replication.
Diffstat (limited to 'sql/wsrep_trans_observer.h')
-rw-r--r-- | sql/wsrep_trans_observer.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h index 6bb26c40064..98fc63cf783 100644 --- a/sql/wsrep_trans_observer.h +++ b/sql/wsrep_trans_observer.h @@ -335,15 +335,22 @@ static inline int wsrep_before_rollback(THD* thd, bool all) int ret= 0; if (wsrep_is_active(thd)) { - if (!all && thd->in_active_multi_stmt_transaction() && - thd->wsrep_trx().is_streaming() && - !wsrep_stmt_rollback_is_safe(thd)) + if (!all && thd->in_active_multi_stmt_transaction()) { - /* Non-safe statement rollback during SR multi statement - transasction. Self abort the transaction, the actual rollback - and error handling will be done in after statement phase. */ - wsrep_thd_self_abort(thd); - ret= 0; + if (wsrep_emulate_bin_log) + { + wsrep_thd_binlog_stmt_rollback(thd); + } + + if (thd->wsrep_trx().is_streaming() && + !wsrep_stmt_rollback_is_safe(thd)) + { + /* Non-safe statement rollback during SR multi statement + transasction. Self abort the transaction, the actual rollback + and error handling will be done in after statement phase. */ + wsrep_thd_self_abort(thd); + ret= 0; + } } else if (wsrep_is_real(thd, all) && thd->wsrep_trx().state() != wsrep::transaction::s_aborted) |