Repository navigation
fix(ENGKNOW-4002): do not flush group/sort buffers when pipeline is in error state - #154
Merged
Merged
Conversation
…n error state When a step upstream of a BinAnalysis (group, sort, rank, atmax, ...) threw, finish() still flushed the buffered bins, so a failing query wrote a partial aggregate row before the error was reported. BinAnalysis.finish() now discards the bins when isInErrorState is set, matching LeftWhereAnalysis. Discarding closes the bins, and SortState.close() deletes any sort spill files so they are not left behind on error. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
gmagnu
marked this pull request as ready for review
October 7, 2026 23:45
bragnarsson
approved these changes
Oct 8, 2026
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.
Jira: ENGKNOW-4002
Problem
When a step upstream of
group/sortthrows (e.g.throwif),BinAnalysis.finish()still flushed the buffered bins during teardown. A failing query therefore wrote a partial aggregate row (e.g.group -count→3,group -lis→0,1,2) before the error was reported.Fix
BinAnalysis.finish()checksisInErrorState(asLeftWhereAnalysisdoes) and calls a newBinAggregator.discard()instead offinalFlush(). This covers everyBinAnalysis: group, sort, rank, atmax, csvcc, queen.discard()closes the bins without emitting.SortState.close()now callsSortGenome.discard(), which deletes the sort spill files. Before this, spill files left by a failed sort were only removed at JVM exit (deleteOnExit).Tests
UTestBufferedAnalysisErrorStateruns queries throughCLIGorExecutionEngineinto a buffer (the push path; the iterator path hid the bug). It covers:group -count,group -lis -sc,sortafterthrowif: only the error is reported, with no data rowsWatched the error-state tests fail before the fix, then pass.
:model:test(1553) and:gortools:test(2660) pass.Scope
Other buffering steps (distinct, vargroup, varnorm, adjust, ...) also flush in
finish()without checkingisInErrorState. They are deliberately left alone. Output is already truncated on error and callers must check the error, so this PR only targets the aggregates whose teardown flush yields a wrong-but-complete-looking value (group/sort), plus the sort spill-file cleanup.🤖 Generated with Claude Code