Repository navigation
Keep logging commands after a command fails - #39498
Merged
AndriySvyryd merged 1 commit intoNov 3, 2026
Merged
Conversation
- Clear the command execute suppression in CommandError and CommandCanceled, since CommandExecuted won't run for that command - Add tests for each execute method and for the reported scenario on SQLite Fixes dotnet#32244
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change is supported by targeted regression coverage for synchronous and asynchronous failure and cancellation paths.
No open issues 🎉
What changed in this PR
This pull request fixes relational command logging suppression after a command fails or is canceled, ensuring subsequent commands are logged immediately.
Changes:
- Clear command-execution logging suppression across synchronous and asynchronous error and cancellation paths.
- Add relational regression tests for non-query, scalar, and reader commands in sync and async scenarios.
- Add a SQLite functional test confirming commands remain logged after a failure.
| File | Description |
|---|---|
test/EFCore.Sqlite.FunctionalTests/LoggingSqliteTest.cs |
Verifies subsequent SQLite commands are logged after a failure. |
test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs |
Tests suppression reset across command execution methods and execution modes. |
src/EFCore.Relational/Diagnostics/Internal/RelationalCommandDiagnosticsLogger.cs |
Resets command logging suppression after errors and cancellations. |
Review effort: Lite
AndriySvyryd
approved these changes
Nov 3, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
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.
Fixes #32244
The
*Executingmethods set_suppressCommandExecuteExpirationtostartTime + LoggingCacheTime, and the*Executedmethods clear it when the executed event is enabled. A command that fails or is canceled never reaches*Executed, so the expiry stays set andShouldLogCommandExecutereturns false until it runs out. At Information level that loses theCommandExecutedentries of the commands after the failure, for up to a second by default. Debug logging hides it because*Executingclears the expiry itself.CommandErrorandCommandCanceled, sync and async, now clear the expiry. If nobody is listening, the only cost is that the next command takes the logging path once and sets the expiry again.Tests:
RelationalCommandTest:Logging_is_not_suppressed_after_exceptionandLogging_is_not_suppressed_after_cancellation, for non-query, scalar and reader, sync and async.LoggingSqliteTest.Commands_are_logged_after_a_command_fails: the reported scenario on SQLite, sync and async.All of them fail without the change.
EFCore.Relational.TestsandLoggingSqliteTestpass with it.