Skip to content

fix(ENGKNOW-4002): do not flush group/sort buffers when pipeline is in error state - #154

Merged
gmagnu merged 1 commit into
mainfrom
ENGKNOW-4002-group-sort-partial-row-on-error
Oct 8, 2026
Merged

gmagnu merged 1 commit into
mainfrom
ENGKNOW-4002-group-sort-partial-row-on-error

Conversation

@gmagnu

@gmagnu gmagnu commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Jira: ENGKNOW-4002

Problem

When a step upstream of group/sort throws (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() checks isInErrorState (as LeftWhereAnalysis does) and calls a new BinAggregator.discard() instead of finalFlush(). This covers every BinAnalysis: group, sort, rank, atmax, csvcc, queen.
  • discard() closes the bins without emitting. SortState.close() now calls SortGenome.discard(), which deletes the sort spill files. Before this, spill files left by a failed sort were only removed at JVM exit (deleteOnExit).

Tests

UTestBufferedAnalysisErrorState runs queries through CLIGorExecutionEngine into a buffer (the push path; the iterator path hid the bug). It covers:

  • nor and gor group -count, group -lis -sc, sort after throwif: only the error is reported, with no data rows
  • sort spill files are removed on error
  • output is unchanged when there is no error

Watched 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 checking isInErrorState. 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

…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]>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Junit Tests - Summary

4 941 tests  +8   4 770 ✅ +8   19m 52s ⏱️ + 1m 30s
  514 suites +1     171 💤 ±0 
  514 files   +1       0 ❌ ±0 

Results for commit 0494c2a. ± Comparison against base commit fe063a2.

@gmagnu
gmagnu marked this pull request as ready for review October 7, 2026 23:45
@gmagnu
gmagnu merged commit 2285213 into main Oct 8, 2026
14 checks passed
@gmagnu
gmagnu deleted the ENGKNOW-4002-group-sort-partial-row-on-error branch October 8, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants