fix(actions): retry workflow insertion on database deadlock #221

Merged
jmiller merged 5 commits from fix/220-actions-deadlock-retry into dev 2026-05-26 22:04:59 +00:00

5 Commits

Author SHA1 Message Date
Jonathan Miller dd6fc4b69c fix(actions): retry workflow insertion on database deadlock
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
PR RC Release / Build RC Release (pull_request) Successful in 2s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || 'development' }}) (pull_request) Failing after 21s
When multiple workflows are triggered by a single event (e.g. a
pull_request with several matching workflow files), each InsertRun
transaction acquires an X-lock on the repository row via
UpdateRepoRunsNumbers and an index lock on action_run. Two concurrent
transactions can deadlock when each holds one lock and waits for the
other. InnoDB kills the lighter transaction, but handleWorkflows only
logged the error and silently dropped the workflow run — making it
appear as though pull_request events were never fired.

This was the root cause of API-created PRs appearing to not trigger
Actions workflows: the notification pipeline was correct, but the DB
insert was lost to an unretried deadlock.

The fix wraps PrepareRunAndInsert in a retry loop (up to 3 attempts
with exponential backoff) that detects deadlock errors across MySQL,
PostgreSQL, and SQLite. On deadlock, the rolled-back run fields are
reset before the next attempt.

Also adds db.IsErrDeadlock() for cross-engine deadlock detection and
unit tests for the same.

Closes #220

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-26 15:16:30 -05:00
jmiller c633024a9c Merge pull request 'rc(v05.05.00): org 2FA, wiki slugs, http render fix' (#219) from rc/05.05.00 into main 2026-05-26 18:50:40 +00:00
jmiller 1e1441f8bd Merge pull request 'rc(v05.04.00): login notifications, help footer, login logo, checksum fix' (#210) from rc/05.04.00 into main 2026-05-26 17:47:13 +00:00
jmiller 3c55a3baca Merge pull request 'rc: footer help + login logo' (#206) from rc/05.03.08 into main 2026-05-26 16:12:57 +00:00
jmiller b7f9743ade Merge pull request 'rc: fix dashboard icon' (#203) from rc/05.03.06 into main 2026-05-26 04:39:15 +00:00