Skip to content

fix(cpp): return E_INVALID_ARG when a result block cannot hold one row - #1149

Merged
ColinLeeo merged 1 commit into
apache:developfrom
ColinLeeo:fix-192-timefilter-hang
Nov 27, 2026
Merged

ColinLeeo merged 1 commit into
apache:developfrom
ColinLeeo:fix-192-timefilter-hang

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Problem

A table query with a TimeBetween filter and a tsblock_max_memory_ smaller than one result row spun forever: the first ResultSet::next() never returned (100% CPU).

The hang was in TsFileSeriesScanIterator::get_next. When the output TsBlock cannot hold a single row, AlignedChunkReader::get_next_page reports E_OK with 0 rows while has_more_data() stays true, so the 0-row retry branch continues without any progress and loops forever.

Fix

Before decoding, TsFileSeriesScanIterator::get_next now checks that the output block is usable:

  • a null block (allocation failure) returns E_OOM;
  • a block with max_row_count == 0 (memory budget smaller than one row) returns E_INVALID_ARG.

This matches the existing behavior of the single-value and serial multi-value decode paths, which already convert the same "empty block" condition to E_INVALID_ARG.

Test

Added AlignedFieldFilterRegressionTest.TimeBetweenFilterUnusableCapacityReportsError: a 10-tag / 100-field table queried through a TimeBetween filter with tsblock_max_memory_ = 8, asserting the first next() returns E_INVALID_ARG instead of hanging (covered in both parallel and row/batch read modes).

A table query with a TimeBetween filter and a tsblock_max_memory_ smaller than one result row spun forever in TsFileSeriesScanIterator::get_next: an E_OK with 0 rows was retried while has_more_data() stayed true with no progress. Detect an unusable block (zero max rows) before decoding and surface E_INVALID_ARG, matching the serial decode paths.
@ColinLeeo
ColinLeeo merged commit 4d89273 into apache:develop Nov 27, 2026
49 checks passed
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.

1 participant