Skip to content

[5.x] Restart the transaction and retry per request set after a deadlock or snapshot isolation conflict, #331 - #350

Merged
snake14 merged 3 commits into
5.x-devfrom
fix-331-aborted-transaction-5x
Oct 20, 2026
Merged

snake14 merged 3 commits into
5.x-devfrom
fix-331-aborted-transaction-5x

Conversation

@snake14

@snake14 snake14 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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

  1. Use the PDO adapter against MariaDB with innodb_snapshot_isolation=ON (or produce a deadlock), and process the queue while concurrent writes touch the same rows.
  2. Expected: the affected requests are retried and every hit is stored once.
  3. Actual: processing stops with "There is no active transaction", and requests stored after the error are stored again on the next run.

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [NA] Are all newly added texts included via translation?
  • [NA] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [✔] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
  • [NA] Documentation updated?

…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
snake14 marked this pull request as ready for review October 20, 2026 08:09
@snake14
snake14 requested a review from a team October 20, 2026 08:09
@snake14
snake14 enabled auto-merge (squash) October 20, 2026 08:10
@snake14
snake14 merged commit d9c8bdd into 5.x-dev Oct 20, 2026
10 checks passed
@snake14
snake14 deleted the fix-331-aborted-transaction-5x branch October 20, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants