Skip to content

PXC-5370: Galera FATAL "unexpected trx release state" after replay of… - #2406

Open
jankowsk wants to merge 1 commit into
percona:8.4from
jankowsk:PXC-5370
Open

jankowsk wants to merge 1 commit into
percona:8.4from
jankowsk:PXC-5370

Conversation

@jankowsk

Copy link
Copy Markdown

… a no-op INSERT ... ON DUPLICATE KEY UPDATE

https://perconadev.atlassian.net/browse/PXC-5370

Problem:
An INSERT ... ON DUPLICATE KEY UPDATE that matches an existing row but does not change it generates no row events. wsrep_compare_records() still appends certification keys for the unchanged row, so a write set with keys but an empty payload is replicated and certified.

If such a transaction is BF-aborted after certification (e.g. by a conflicting applier blocked on its next-key lock), it is replayed. Applying the empty payload registers no storage engine, so trans_commit() does not run the wsrep commit hooks and the transaction never enters or leaves the commit order. Wsrep_high_priority_service::commit() already has a fallback that cycles through the commit hooks for this case, but only for the s_executing state (CTAS with an empty result set). A replayer is in s_replaying, so the fallback was skipped. Galera kept the trx in the REPLAYING state and failed in galera_release() with:

unexpected trx release state ... MUST_REPLAY->REPLAYING (FATAL)

Debug builds hit the assertion ts.state() == TrxHandle::S_COMMITTED in ReplicatorSMM::replay_trx().

Resolution:
Apply the same fallback to the s_replaying state, so the replayed empty write set goes through before_commit(), ordered_commit() and after_commit(), which release the commit order and let the provider commit the trx. wsrep-lib already supports s_replaying in before_commit() for high priority clients.

Added galera.galera_replay_no_op_trx, which uses Galera sync points to BF-abort and replay a no-op ODKU transaction deterministically.

@it-percona-cla

it-percona-cla commented Nov 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test lacks a Galera provider sync-point capability check, causing debug servers with non-debug providers to fail rather than skip the unsupported test.

1 open issue
What changed in this PR

Fixes commit handling for replayed write sets with no row events, preventing Galera’s fatal “unexpected trx release state” error after a no-op INSERT ... ON DUPLICATE KEY UPDATE.

Changes:

  • Extends the commit-hook fallback to transactions in s_replaying.
  • Adds a regression test that forces replay and verifies successful commits, continued replication, and absence of the fatal error.
File Description
sql/​wsrep_high_priority_service.cc Runs fallback commit hooks for replayed empty write sets.
mysql-test/​suite/​galera/​t/​galera_replay_no_op_trx.test Adds deterministic no-op transaction replay coverage.
mysql-test/​suite/​galera/​r/​galera_replay_no_op_trx.result Records expected replay and replication results.

Review effort: Balanced

… a no-op INSERT ... ON DUPLICATE KEY UPDATE

https://perconadev.atlassian.net/browse/PXC-5370

Problem:
An INSERT ... ON DUPLICATE KEY UPDATE that matches an existing row but
does not change it generates no row events. wsrep_compare_records() still
appends certification keys for the unchanged row, so a write set with keys
but an empty payload is replicated and certified.

If such a transaction is BF-aborted after certification (e.g. by a
conflicting applier blocked on its next-key lock), it is replayed. Applying
the empty payload registers no storage engine, so trans_commit() does not
run the wsrep commit hooks and the transaction never enters or leaves the
commit order. Wsrep_high_priority_service::commit() already has a fallback
that cycles through the commit hooks for this case, but only for the
s_executing state (CTAS with an empty result set). A replayer is in
s_replaying, so the fallback was skipped. Galera kept the trx in the
REPLAYING state and failed in galera_release() with:

  unexpected trx release state ... MUST_REPLAY->REPLAYING (FATAL)

Debug builds hit the assertion ts.state() == TrxHandle::S_COMMITTED in
ReplicatorSMM::replay_trx().

Resolution:
Apply the same fallback to the s_replaying state, so the replayed empty
write set goes through before_commit(), ordered_commit() and
after_commit(), which release the commit order and let the provider commit
the trx. wsrep-lib already supports s_replaying in before_commit() for
high priority clients.

Added galera.galera_replay_no_op_trx, which uses Galera sync points to BF-abort
and replay a no-op ODKU transaction deterministically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Replay commit-order correctness and provider-state cleanup depend on wsrep-lib/Galera implementations absent from this snapshot and require debug-provider validation of the regression and existing replay scenarios.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants