Repository navigation
[5.x] Restart the transaction and retry per request set after a deadlock or snapshot isolation conflict, #331 - #350
Merged
Conversation
…es, #331 Sets that conflict in turn could otherwise keep the queue locked for up to three passes per set. Also tests that a set whose environment cannot be restored is not cut down using the previous set's count.
snake14
marked this pull request as ready for review
October 20, 2026 08:09
snake14
enabled auto-merge (squash)
October 20, 2026 08:10
AltamashShaikh
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Backport of #348 and #349 to 5.x.
A database deadlock or a MariaDB snapshot isolation conflict (error 1020) could make queue processing fail with a fatal "There is no active transaction" error, and could cause some hits to be counted twice. Snapshot isolation conflicts are now retried in the same way as deadlocks.
On these errors the server ends the transaction itself, so the handler now starts a new transaction straight after one. A batch whose retry fails is retried again while the queue lock is held, with a short pause after a transaction error. Each request set gets its own three tries: only a set that keeps conflicting is dropped, with a warning logged, and a set that fails for another reason is left out while the rest of the batch is retried, so neither blocks its queue or costs the other requests in the batch. Once a batch has been retried six times, a set that conflicts again is dropped straight away, so sets that conflict in turn can't keep the queue locked for long.
Issue No
Fixes #331
Steps to Replicate the Issue
innodb_snapshot_isolation=ON(or produce a deadlock), and process the queue while concurrent writes touch the same rows.Checklist