Repository navigation
GH-5230 Database batch cancelled by shutdown is no longer logged as a database failure - #5232
Merged
Merged
Conversation
… database failure DatabaseBatcher.DrainAsync() cancels its own token before joining the active batch. DatabaseOperationBatch.ExecuteAsync() wrapped that cancellation in a DatabaseBatchCommandException, which the executor then logged at Error. A cancellation observed while the batch's own token is cancelled now returns AgentCommands.Empty (logged at Debug) instead, before the executor sees it. Genuine SQL failures and cancellations with a live token still throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U
Merged
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.
Closes #5230
Problem
DatabaseBatcher.DrainAsync()cancels_internalCancellationand then joins the active batch. The in-flightDatabaseOperationBatch.ExecuteAsync()caught that cancellation in its general handler and wrapped it inDatabaseBatchCommandException, andExecutor.InvokeAsynclogged it at the handler's failure level (Error) beforeprocessOperationsAsynccould recognise its own cancelled token.Fix
In
DatabaseOperationBatch.ExecuteAsync(), anOperationCanceledException(directly or as the inner exception) observed while the batch's own cancellation token is cancelled is treated as an orderly stop: logged at Debug, connection closed,AgentCommands.Emptyreturned. It never reaches the executor, so nothing is logged as an invocation failure. The same check covers opening the connection and beginning the transaction.Unchanged: genuine SQL/connection failures, and cancellations when the token is not cancelled, are still wrapped and logged. Shutdown still joins the active batch (
WaitForCompletionAsync) before disposal.Tests
PostgresqlTests.Bugs.Bug_5230_batch_cancelled_by_shutdown_is_not_a_failure(mirrors the issue's repro, Solo mode):ReadResultsAsyncuntil shutdown → no Error-levelDatabaseBatchCommandException(fails without the fix: "Invocation of Wolverine.RDBMS.Polling.DatabaseOperationBatch failed!")select 1 / 0;still logs aDatabaseBatchCommandExceptiondotnet build wolverine.slnx -c Release -f net9.0: 0 warnings, 0 errors.🤖 Generated with Claude Code
https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U