Repository navigation
Push the cancellation token through the retry stores - #5732
Merged
Merged
Conversation
rbev
approved these changes
Aug 11, 2026
johnsimons
force-pushed
the
john/cancel_part4
branch
from
August 11, 2026 07:17
b4e4217 to
76224ee
Compare
…ementations This change continues the effort to consistently apply optional `CancellationToken` parameters to asynchronous methods within the persistence data store interfaces (`IRetryBatchStore`, `IRetryHistoryDataStore`, `IRetryStagingStore`) and their EFCore and RavenDB implementations. The cancellation tokens are now propagated to underlying asynchronous database calls and to consuming services. This ensures proper cancellation of long-running database operations and resolves related static analysis warnings, further reducing cancellation analyzer debt.
johnsimons
force-pushed
the
john/cancel_part4
branch
from
August 11, 2026 10:37
76224ee to
9312e41
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.
Push the cancellation token through the retry stores
Fourth slice of the cancellation propagation work, and the second Phase 3 slice. Covers the retry interface group:
IRetryBatchStore(10 methods),IRetryStagingStore(10) andIRetryHistoryDataStore(3), both persisters, 17 host call sites.Deletes a debt block
ServiceControl/.editorconfigno longer carries theRecoverability/Retrying/RetriesGateway.csblock. This is the first project-level suppression the burn-down has removed outright rather than narrowed, and it was one of the three the plan named as the signal that Phase 3 is landing. Both conditions its comment was waiting on are now met:BulkRetryRequest.Invokeforwarded aFunc<string, DateTime, Task>straight intoForEachUnresolvedMessageand friends. That callback is nowFunc<string, DateTime, CancellationToken, Task>, so the store hands each streamed message the token it is iterating under. All four overrides follow.AssignMessagesToBatchcould not take a required token "until the parameters are reordered". Done: the token moved from last position to position 5, ahead of the trailing optionals, because C# forbids a required parameter after optional ones (CS1737).CA1068explicitly permits optional parameters after a required token, so the result is legal and rule-clean. Three call sites updated.The error instance is now down to 4 cancellation diagnostics from 7, and all four are the transport and external-integration files that later phases own.
Progress
ServiceControl.Persistence.EFCoreServiceControl.Persistence.RavenDBServiceControl.PersistenceServiceControl.Persistence.Tests92 diagnostics retired, 563 to 471 across the four persistence projects.
Persistence.Testsdoes not move. Its 10 remaining retry hits arePS0018on test-local helper methods, which belong to the blanket test-project escape rather than to this slice.Worth a reviewer's attention
CancellationToken.Noneis deliberately left in place.RetryBatchStore.AssignMessagesToBatchnow has a token, so it could be forwarded todialect.InsertMissingRetryClaims, but that call is an established explicit opt-out sitting inside a transaction the dialect owns, and flipping it changes runtime behaviour on a write path. Called out here rather than changed silently. It also carries no comment explaining the opt-out, which the convention asks for and which would be worth adding either way.RetryProcessornow take the token:RecordStagingFailure,IncrementStagingAttemptsandRemoveFromBatch. Each sits in acatch (Exception e)preceded by acatch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)filter, so the token is guaranteed live on entry. If shutdown does land mid-write, the batch is left forAdoptOrphanedBatchesto re-adopt on restart, which is the existing recovery path.InTransactionin the EFCore staging store changes fromFunc<Task>toFunc<CancellationToken, Task>with a required token, satisfying bothPS0013andPS0004. Its three lambdas becomeasync token =>. It is private and self-contained, unlikeDataStoreBase.ExecuteWithDbContext, which remains deliberately unconverted until the last store lands.