Skip to content

fix: sync to the filesystem when a transaction ends - #1066

Open
AntonOfTheWoods wants to merge 1 commit into
electric-sql:mainfrom
pgxsinkit:fix/transaction-end-sync
Open

fix: sync to the filesystem when a transaction ends#1066
AntonOfTheWoods wants to merge 1 commit into
electric-sql:mainfrom
pgxsinkit:fix/transaction-end-sync

Conversation

@AntonOfTheWoods

@AntonOfTheWoods AntonOfTheWoods commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Every top-level query/exec ends with syncToFs(), gated on not being inside a transaction — but transaction() executed its terminal COMMIT/ROLLBACK while #inTransaction still suppressed that gate and cleared the flag only afterwards. A resolved transaction() had therefore neither performed nor scheduled any filesystem sync: with relaxedDurability: false the awaited durability promise was silently broken, and with relaxedDurability: true no background sync was even scheduled until some later unrelated query ran.

Clear the flag before the terminal statement so #runExec ends the transaction with the same synchronization as a top-level exec, and sync explicitly on the tx.rollback() path, which exits the wrapper without running a terminal statement.

Fixes: #1065

@AntonOfTheWoods
AntonOfTheWoods force-pushed the fix/transaction-end-sync branch from 6127fe5 to ee8a022 Compare July 21, 2026 01:41
Every top-level query/exec ends with syncToFs(), gated on not being
inside a transaction — but transaction() executed its terminal
COMMIT/ROLLBACK while #inTransaction still suppressed that gate and
cleared the flag only afterwards. A resolved transaction() had
therefore neither performed nor scheduled any filesystem sync: with
relaxedDurability: false the awaited durability promise was silently
broken, and with relaxedDurability: true no background sync was even
scheduled until some later unrelated query ran.

Clear the flag before the terminal statement so #runExec ends the
transaction with the same synchronization as a top-level exec, and
sync explicitly on the tx.rollback() path, which exits the wrapper
without running a terminal statement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@AntonOfTheWoods
AntonOfTheWoods force-pushed the fix/transaction-end-sync branch from ee8a022 to 91bd413 Compare July 21, 2026 02:47
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.

[BUG]: PGlite suppresses synchronization while inside a transaction

1 participant