Skip to content

Avoid duplicate inserts when updating check runs - #1506

Merged
timothysmith0609 merged 1 commit into
mainfrom
fix/check-run-updates
Oct 7, 2026
Merged

timothysmith0609 merged 1 commit into
mainfrom
fix/check-run-updates

Conversation

@timothysmith0609

Copy link
Copy Markdown
Contributor

Refreshing a check run that is already stored attempts an insert before falling back to an update. This produces a duplicate-key SQL error for an ordinary update, even when the refresh succeeds.

Look up existing runs first and update them directly. Create missing runs inside a savepoint; if another writer creates the same run after the lookup, use a locking read to find it and apply the update. This preserves commit scoping, validations, callbacks, and the existing stale-webhook refresh behavior while keeping enclosing transactions usable after an insert conflict.

Adds regression coverage for updates without SQL errors, identical GitHub IDs on different commits, and a simulated concurrent insert inside a transaction.

Validation:

  • The SQL-error regression fails against the previous implementation and passes with this change.
  • Full SQLite test suite: 1,250 tests and 3,539 assertions passed.
  • Check-run model tests on MySQL and PostgreSQL: 16 tests and 66 assertions passed on each database.
  • RuboCop passes for both changed Ruby files.

@timothysmith0609
timothysmith0609 merged commit 4250374 into main Oct 7, 2026
15 checks passed
@timothysmith0609
timothysmith0609 deleted the fix/check-run-updates branch October 7, 2026 16:01
@timothysmith0609 timothysmith0609 mentioned this pull request Oct 7, 2026
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.

2 participants