fix: make observation additive and reference-counted per webview (#54) - #55
Merged
Merged
Conversation
Contributor
Author
|
@velocitysystems @yokuze This attempts to resolve this issue: #54 |
velocitysystems
requested changes
Jul 30, 2026
jjhafer
commented
Jul 30, 2026
This was referenced Jul 30, 2026
…vermine#54) Observation was destructive: any observe() call dropped the existing broker, and with it the sole broadcast sender, ending every current subscriber's stream with no error and no attributable cause. Since observe() is exposed over IPC, one window could silently kill another window's change stream just by observing the same database, which made multi-window use impossible. Observation is now shared rather than replaced. The broker is created once per database and reused, requested tables are merged into it, and each window holds its own registration so teardown waits for the last one to be released. Correctness depends on the registrations and the broker staying in step, so the lock order protecting them is enforced by the compiler rather than by convention - the registration methods require proof that the caller holds the database lock. The same ordering defect had been reintroduced four times while the rule lived only in a comment. Fixes issue silvermine#54. BREAKING CHANGE: DatabaseWrapper::enable_observation() no longer tears down the existing broker. Callers who re-called it to shed subscribers, or to change channel_capacity/capture_values on a live database, must now call disable_observation() first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jjhafer
force-pushed
the
fix-observation-issue
branch
from
July 30, 2026 19:40
208b57f to
abb8001
Compare
Contributor
Author
|
@velocitysystems Updated, can you review again? |
velocitysystems
approved these changes
Jul 30, 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.
Observation was destructive: any observe() call dropped the existing broker, and with it the sole broadcast sender, ending every current subscriber's stream with no error and no attributable cause. Since observe() is exposed over IPC, one window could silently kill another window's change stream just by observing the same database, which made multi-window use impossible.
Observation is now shared rather than replaced. The broker is created once per database and reused, requested tables are merged into it, and each window holds its own registration so teardown waits for the last one to be released.
Correctness depends on the registrations and the broker staying in step, so the lock order protecting them is enforced by the compiler rather than by convention - the registration methods require proof that the caller holds the database lock. The same ordering defect had been reintroduced four times while the rule lived only in a comment.
Fixes issue #54.
BREAKING CHANGE: DatabaseWrapper::enable_observation() no longer tears down the existing broker. Callers who re-called it to shed subscribers, or to change channel_capacity/capture_values on a live database, must now call disable_observation() first.