fix: remove outer transaction wrapper in sync to prevent PGlite deadlock#193
Open
Jpumpkin1223 wants to merge 1 commit intogarrytan:masterfrom
Open
fix: remove outer transaction wrapper in sync to prevent PGlite deadlock#193Jpumpkin1223 wants to merge 1 commit intogarrytan:masterfrom
Jpumpkin1223 wants to merge 1 commit intogarrytan:masterfrom
Conversation
When syncing >10 files, sync.ts wrapped all importFile() calls inside a single engine.transaction(). However, importFile() opens its own inner transaction on the same connection, and PGlite does not support nested transactions — the event loop hangs indefinitely. Remove the conditional outer transaction wrapper. Each importFile() call is already individually atomic, so no outer wrapper is required. Fixes: gbrain sync hanging forever when more than 10 files are changed.
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.
Problem
When syncing more than 10 changed files,
sync.tswraps allimportFile()calls inside a singleengine.transaction():However,
importFile()opens its own inner transaction on the same DB connection. PGlite does not support nested transactions — the event loop hangs indefinitely with no error, no output, and no timeout.This makes
gbrain syncsilently hang forever whenever a repo has more than 10 changed files.Fix
Remove the conditional outer
engine.transaction()wrapper. EachimportFile()call is already individually atomic, so no outer wrapper is needed.Reproduction
gbrain sync --repo <path>Testing
Verified locally with a repo containing 17 changed files — sync now completes successfully.