10.6-MDEV-31272 statement rollback causing empty write set replication #325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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()