Repository navigation
Fix the statement after a failed one returning no rows - #469
Merged
Merged
Conversation
… finished with it. A statement run right after the error from another session (a `run` after a failed `execute`, say) could start too early: it failed with "Previous operation ... did not clean up" or, with asserts disabled, returned no rows. The error is now thrown once the connection has finished with the failed statement.
isoos
approved these changes
Oct 1, 2026
Owner
|
Thanks! |
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.
When a statement fails, the statement run right after it on the same connection can come back empty instead of with its real result. This needs it to run from another session (for example a new
runcall), and the server's end-of-statement message to arrive a little after the error.Here
SELECT 1/0fails, then three statements follow on the same connection. The end-of-statement message after the error is delayed by 300 ms, as a busy machine or network can do:SELECT 2Previous operation ... did not clean up[][[2]]SELECT 3[[3]][[3]]SELECT 4[[4]][[4]]In production, a lookup right after a failed insert could report "not found". In tests, it shows up as a flaky assertion failure. Any error triggers it: a constraint violation, a division by zero, a timeout.
It's rare. The built-in
Pooldiscards a connection after an error, so it isn't affected. The two server messages usually arrive together, and under load they sometimes don't. It affects aConnectionused directly, and pools that keep their connections after an error.The fix: the error is now thrown only once the connection has finished with the failed statement, so the next statement can't start too early.
Tests:
test/error_before_ready_test.dartdelays the end-of-statement message after an error, so the problem happens every time. It covers a failed statement in arunsession, one on the connection itself, one in the simple protocol, and one cancelled by its timeout, each followed by aSELECT 2. All four fail before this change and pass after. The full suite passes.