fix: init blocks when trigger is dropped and created#26
Open
fix: init blocks when trigger is dropped and created#26
Conversation
On every pod startup, NewStore() ran init() which executes DROP TRIGGER + CREATE TRIGGER DDL requiring ACCESS EXCLUSIVE locks. When multiple pods start simultaneously (autoscaling), this blocks all operations on the outbox table across all pods, causing a cascading freeze. Now NewStore() checks information_schema.tables first and only runs init() DDL when the table does not yet exist. Also adds a 10-second timeout to init() as a safety net for first-time setup. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
gjarmstrong
approved these changes
Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ACCESS EXCLUSIVElocks that cause cascading freezes during multi-pod autoscalinginit()context as a safety net for first-time setupProblem
NewStore()runsDROP TRIGGER+CREATE TRIGGERDDL on every pod startup. These statements require PostgreSQLACCESS EXCLUSIVElocks on the outbox table. When a new pod starts during autoscaling:init()requestsACCESS EXCLUSIVEon the outbox tableROW EXCLUSIVElocks from active outbox dispatch transactionsACCESS EXCLUSIVErequest blocks waiting for existing transactionsFix
init()now checksinformation_schema.tablesfirst. If the table exists, DDL is skipped entirely. The DDL only runs on first-time setup (when the table doesn't exist yet). A 10-second context timeout is also added soinit()can never hang indefinitely.Test plan
go test ./...)🤖 Generated with Claude Code