fix(replication): replace custom AbortToken with tokio::CancellationToken#1131
Open
meskill wants to merge 1 commit into
Open
fix(replication): replace custom AbortToken with tokio::CancellationToken#1131meskill wants to merge 1 commit into
meskill wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
sgrif
reviewed
Jul 3, 2026
|
|
||
| // Create a child cancel token with the guard to cancel the handles below | ||
| // in case any of it fails without affecting the parent task. | ||
| // If every handle succeed the guard token will just cancel already finished work |
Contributor
There was a problem hiding this comment.
Suggested change
| // If every handle succeed the guard token will just cancel already finished work | |
| // If every handle succeeds the guard token will just cancel already finished work |
| // Create a child cancel token with the guard to cancel the handles below | ||
| // in case any of it fails without affecting the parent task. | ||
| // If every handle succeed the guard token will just cancel already finished work | ||
| let cancel = cancel.child_token(); |
Contributor
There was a problem hiding this comment.
I think we should require the caller to call .child_token() if they don't want to be cancelled.
Suggested change
| let cancel = cancel.child_token(); |
| // in case any of it fails without affecting the parent task. | ||
| // If every handle succeed the guard token will just cancel already finished work | ||
| let cancel = cancel.child_token(); | ||
| let _guard = cancel.clone().drop_guard(); |
Contributor
There was a problem hiding this comment.
Suggested change
| let _guard = cancel.clone().drop_guard(); | |
| let _guard = cancel.drop_guard_ref(); |
Comment on lines
+442
to
+445
| let cancel = cancel.clone(); | ||
| syncs.push(async move { | ||
| let manager = ParallelSyncManager::new(tables, replicas, dest)?; | ||
| let tables = manager.run().await?; | ||
| let tables = manager.run(cancel).await?; |
Contributor
There was a problem hiding this comment.
Suggested change
| let cancel = cancel.clone(); | |
| syncs.push(async move { | |
| let manager = ParallelSyncManager::new(tables, replicas, dest)?; | |
| let tables = manager.run().await?; | |
| let tables = manager.run(cancel).await?; | |
| syncs.push(async move { | |
| let manager = ParallelSyncManager::new(tables, replicas, dest)?; | |
| let tables = manager.run(cancel.child_token()).await?; |
|
|
||
| let dest = dest.clone(); | ||
| set.spawn(async move { | ||
| let cancel = cancel.clone(); |
Contributor
There was a problem hiding this comment.
This is the first place we actually do anything with a cancellation token other than pass it through. Should we remove everything up the chain from here and the CancellationToken::new()s, and create it at this point?
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.
Replace custom AbortSignal with CancellationToken to make the cancellation explicit and not relied on futures drop (that holds rx part of channel). Pass cancellation token for graceful cancellation. Early cancellation on errors