Skip to content

fix(cpp): surface E_INVALID_ARG for non-aligned tree scan with sub-row TsBlock capacity - #1154

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

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

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Problem

A non-aligned (tree) query with a TsBlock capacity smaller than a single row spins forever in the query stage.

With a 16-byte row (time INT64 + value INT64) and an 8-byte capacity, TsBlock::init() computes max_row_count_ == 0. The per-type decode loops (i32_DECODE_TV_BATCH, etc.) then report E_OVERFLOW before appending anything, decode_cur_page_data() rewrites that to E_OK with zero rows, and TsFileSeriesScanIterator::get_next() retries the same page endlessly (has_more_data() stays true because the page was never consumed).

Fix

ChunkReader::decode_tv_buf_into_tsblock_by_datatype() now detects the zero-row overflow (the destination block cannot hold even one row) and returns E_INVALID_ARG instead of letting it become E_OK with zero rows. This matches the aligned path, which already reports an error for an unusable block capacity.

Test

Added TsFileReaderTest.NonAlignedTreeSmallTsBlockDoesNotHang: a non-aligned INT64 series read through a scan iterator with tsblock_max_memory_ = 8 must return E_INVALID_ARG rather than looping.

…w TsBlock capacity

A non-aligned (tree) scan with a TsBlock capacity smaller than a single
row spins forever in the query stage. With a 16-byte row and an 8-byte
capacity, TsBlock::init() computes max_row_count_ == 0, so the per-type
decode loops report E_OVERFLOW before appending anything;
decode_cur_page_data() rewrites that to E_OK with zero rows, and the
scan iterator retries the same page endlessly.

Detect the zero-row overflow and return E_INVALID_ARG instead, matching
the aligned path's handling of an unusable block capacity.
@ColinLeeo
ColinLeeo merged commit b22076e 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