MDEV-25553 : Avoid unnecessary rollbacks with SR

This patch changes statement rollback for streaming replication.
Previously, a statement rollback was turned into full transaction
rollback in the case where the transaction had already replicated a
fragment. This was introduced in the initial implementation of
streaming replication due to the fact that we do not have a mechanism
to perform a statement rollback on the applying side.
This policy is however overly pessimistic, causing full rollbacks even
in cases where a local statement rollback, would not require a
statement rollback on the applying side. This happens to be case when
the statement itself has not replicated any fragments.
So the patch changes the condition that determines if a statement
rollback should be turned into a full rollback accordingly.

Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
This commit is contained in:
Daniele Sciascia 2021-04-23 11:31:02 +02:00 committed by Jan Lindström
commit b1b2689f17
12 changed files with 176 additions and 56 deletions

View file

@ -345,11 +345,14 @@ static inline int wsrep_before_rollback(THD* thd, bool all)
}
if (thd->wsrep_trx().is_streaming() &&
!wsrep_stmt_rollback_is_safe(thd))
(wsrep_fragments_certified_for_stmt(thd) > 0))
{
/* 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. */
transaction. A statement rollback is considered unsafe, if
the same statement has already replicated one or more fragments.
Self abort the transaction, the actual rollback and error
handling will be done in after statement phase. */
WSREP_DEBUG("statement rollback is not safe for streaming replication");
wsrep_thd_self_abort(thd);
ret= 0;
}