Race Condition Prevention
GitAuto uses a database insert (insert_check_suite) as a lock to prevent multiple Lambda invocations from processing the same check suite simultaneously. Only the first insertion succeeds; subsequent attempts see the existing record and bail out.
Why This Exists
GitHub sends multiple webhook events for the same test failure - a check_suite event, a check_run event, and sometimes status events. Each event triggers a separate Lambda invocation. Without deduplication at the check-suite level, two or more agents work on the same fix simultaneously, creating conflicting commits that corrupt the branch.
How It Works
When a Lambda invocation starts processing a check suite, it attempts to insert a record into the database with the check suite ID as a unique key. The database enforces uniqueness - if the record already exists, the insert fails. The first Lambda to insert successfully proceeds with processing. All subsequent Lambdas that receive the same check suite ID detect the existing record and exit immediately, logging that another invocation is already handling it.
Related Features
- Webhook Deduplication - deduplicates at the webhook event level before check-suite processing
- Bot Loop Prevention - prevents another form of duplicate processing from bot interactions
Need Help?
Have questions or suggestions? We're here to help you get the most out of GitAuto.
Contact us with your questions or feedback!