Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10.6-MDEV-31272 statement rollback causing empty write set replication #325

Open
wants to merge 9 commits into
base: 10.6
Choose a base branch
from

Conversation

sjaakola
Copy link

If a statement execution has successfully modified some rows, then the write set for the transaction, will be appended by the key values related to the modified rows. If the staement execution eventually fails, e.g. for duplicate key error, then statement rollback will be carried out, to undo changes in storage engine and truncate binlog cache to wipe out replication events related to the statement execution.

If the transaction has no other successful write statements then there is nothing to commit, at commit time, and no binlog events either. But as there were earlier key appends, the transaction remains registred for wsrep replication, and at commit time replicator extracts binlog events from cache and populates the final write set for the replication. In the buggy version, it was observed that there are no binlog events, but the write set was populated, nevertheless, and the empty write set was replicated. Note that this consumes one GTID, for a void operation.

The fix for this issue, cancels the replication of such empty write set anf gives a warning for the client.
This fix is in: Wsrep_client_service::prepare_data_for_replication()

It also turned out that the binlog cache truncate for statement rollback was not complete if server was not configured to use binloggging. In buggy version, only statmenet cache was truncated, but events remained in the transaction cache. This has been fixed in wsrep_thd_binlog_stmt_rollback()

sjaakola and others added 9 commits May 16, 2023 09:10
If a statement execution has successfully modified some rows, then the
write set for the transaction, will be appended by the key values related
to the modified rows. If the staement execution eventually fails,
e.g. for duplicate key error, then statement rollback will be carried out,
to undo changes in storage engine and truncate binlog cache to wipe out
replication events related to the statement execution.

If the transaction has no other successful write statements then there is
nothing to commit, at commit time,  and no binlog events either. But as there
were earlier key appends, the transaction remains registred for wsrep
replication, and at commit time replicator extracts binlog events from cache
and populates the final write set for the replication. In the buggy version,
it was observed that there are no binlog events, but the write set was populated,
nevertheless, and the empty write set was replicated.  Note that this consumes
one GTID, for a void operation.

The fix for this issue, cancels the replication of such empty write set anf gives
a warning for the client.
This fix is in: Wsrep_client_service::prepare_data_for_replication()

It also turned out that the binlog cache truncate for statement rollback was not
complete if server was not configured to use binloggging. In buggy version,
only statmenet cache was truncated, but events remained in the transaction cache.
This has been fixed in wsrep_thd_binlog_stmt_rollback()
binlog_commit maintains also binlog cache, which is needed
also when binlogging is not used, e.g. to support steement rollback
…have empty last WS carrying only commit flag
methods for managing binlog cache when actual binlog is not used
…ines

mtr test galera.galera_ctas should pass with this patch
@sjaakola
Copy link
Author

sjaakola commented Jun 6, 2023

test_pr

@sjaakola sjaakola requested a review from sciascid June 6, 2023 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants