Skip to content

fix(installation): replace find-then-insert with atomic upsert (#110)#111

Open
enjoyandlove wants to merge 1 commit into
entrius:testfrom
enjoyandlove:fix/110-installation-handler-atomic-upsert
Open

fix(installation): replace find-then-insert with atomic upsert (#110)#111
enjoyandlove wants to merge 1 commit into
entrius:testfrom
enjoyandlove:fix/110-installation-handler-atomic-upsert

Conversation

@enjoyandlove
Copy link
Copy Markdown

Summary

Replace the check-then-insert/update pattern in InstallationHandler with a single atomic upsert. The previous implementation issued a findOneBy followed by either insert or update, which meant two round-trips and a potential race condition if the same installation event fired concurrently. The new approach uses a createQueryBuilder upsert (.orUpdate) that inserts on first encounter — setting addedAt — and only updates installationId on conflict, so addedAt is never overwritten on re-fires of installation.created or installation_repositories.added.

Related Issues

Fixes #110

Type of Change

  • Bug fix

Testing

  • The handler processes installation.created and installation_repositories.added events without error.
  • Firing the same event twice leaves addedAt unchanged and updates installationId correctly.
  • No new unit tests were added; the fix is a direct query rewrite with equivalent observable behaviour.

Checklist

  • I have read the Contributing Guide
  • Code builds without errors
  • New and existing tests pass (if applicable)
  • Documentation updated (if applicable)
  • No unnecessary dependencies added

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] InstallationHandler non-atomic check-then-insert causes unique-key violation under concurrent delivery

1 participant