Skip to content

Fix MergeItemSequence shutdown deadlock - #184

Closed
BCook98 wants to merge 1 commit into
powersync-ja:mainfrom
BCook98:fix/merge-item-sequence-deadlock
Closed

Fix MergeItemSequence shutdown deadlock#184
BCook98 wants to merge 1 commit into
powersync-ja:mainfrom
BCook98:fix/merge-item-sequence-deadlock

Conversation

@BCook98

@BCook98 BCook98 commented Sep 10, 2026

Copy link
Copy Markdown

Summary

  • Transfer MergeItemSequence continuation ownership while holding the state mutex, then resume only after unlocking.
  • Keep the terminal state sticky across cancellation and upstream completion races.
  • Cancel and await the detached cross-process update-log reader after a successful native pool close.

The 1.16.1 implementation can deadlock when close cancels the update-log reader while its poll task finishes and resumes the same waiting task under the mutex. This was reproduced as a hung absolute-path PowerSync database close.

Tests

  • 1,000 cancellation-versus-upstream-finish races.
  • 200 concurrent absolute-path open and close cycles.
  • Full package suite: 112 tests passed.

@BCook98 BCook98 closed this Sep 10, 2026
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.

1 participant