Add terminal sync cancellation - #27
Draft
tszymczyszyn-shopify wants to merge 1 commit into
Draft
Conversation
tszymczyszyn-shopify
force-pushed
the
ae-task-166-implement-libsql-cooperative-terminal-sy
branch
2 times, most recently
from
May 27, 2026 08:34
cd656fa to
d84cef2
Compare
## Summary POS terminal cleanup needs a way to stop an in-flight v1 remote-replica sync without dropping the future and racing local replica deletion against libsql cleanup. Add a cooperative cancellation path that returns through libsql's normal rollback and settlement flow. ## Approach - Track the active foreground sync with a per-sync cancellation token stored outside the replicator mutex. - Thread cancellation through the replication state machine, remote waits, snapshot streaming, and SQLite injection. - Interrupt and then join blocking SQLite injection work before returning cancellation. - Expose Database::cancel_current_sync_for_shutdown() for terminal shutdown callers and add coverage for cancellation rollback and the no-active-sync API case. Co-authored-by: Claude <noreply@anthropic.com> Orchestrated-by: ae <noreply@shopify.com>
tszymczyszyn-shopify
force-pushed
the
ae-task-166-implement-libsql-cooperative-terminal-sy
branch
from
May 27, 2026 08:47
d84cef2 to
ce82c96
Compare
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
POS terminal cleanup needs a way to stop an in-flight v1 remote-replica sync without dropping the future and racing local replica deletion against libsql cleanup. This adds a cooperative cancellation path that returns through libsql's normal rollback and settlement flow.
Approach
Database::cancel_current_sync_for_shutdown()for terminal shutdown callers.libsql-serverbackground replicator.SqliteInjectorcancellation-await behavior.CI follow-up
tokio-utilto thelibsqlreplicationfeature socargo udeps --manifest-path libsql/Cargo.toml --no-default-features --features replicationcan resolve the cancellation token dependency.SyncCancelledForShutdownin thelibsql-serverreplica loop to keep the new replicator error exhaustive in server builds.Validation
cargo fmt --all --checkcargo check -p libsql_replication -p libsql --features replicationcargo check -p libsql --no-default-features --features replicationcargo check -p libsql-servercargo test -p libsql_replication cancellation_cargo test -p libsql_replication replicatorcargo test -p libsql_replication sqlite_injectorcargo test -p libsql_replicationcargo test -p libsql --features replication cancel_current_sync_for_shutdowncargo test -p libsql --features replication(cd libsql-sqlite3/test/rust_suite && CMAKE_POLICY_VERSION_MINIMUM=3.5 cargo +1.85.0 test --features=extensions extensions --no-run)cargo clippy -p libsql_replication --tests --no-deps -- -D warnings -A clippy::needless-lifetimes -A clippy::suspicious-open-options -A clippy::nonminimal-boolStrict
cargo clippy -p libsql_replication --tests -- -D warningsandcargo clippy -p libsql --features replication --tests -- -D warningsremain blocked by pre-existing clippy warnings inlibsql,libsql-ffi, and vendored code unrelated to this patch.Co-authored-by: Claude noreply@anthropic.com
Orchestrated-by: ae noreply@shopify.com