Skip to content

fix(cpp): stop serial aligned multi-column read at chunk end - #1098

Merged
ColinLeeo merged 1 commit into
developfrom
fix/aligned-serial-chunk-end
Nov 13, 2026
Merged

ColinLeeo merged 1 commit into
developfrom
fix/aligned-serial-chunk-end

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Summary

The serial path for multi-column aligned chunks reported E_TSFILE_CORRUPTED after the last page of a chunk was consumed.

AlignedChunkReader::get_cur_page_header() resets the page header and returns E_OK when chunk_visit_offset - serialized_size >= data_size. get_next_page_multi_serial() did not distinguish that from a real page: it broke out of the header loop with E_OK and called decode_cur_time_page_data() on the zero-byte header, which failed with E_COMPRESS_ERR and surfaced as E_TSFILE_CORRUPTED (35).

This only reproduces when the serial path is used (no decode pool, no offset/field filter that would build a page plan) and the aligned chunk has more than one page.

Fix

Check has_more_data_multi() immediately after the page headers are fetched, and return E_NO_MORE_DATA when the chunk is exhausted. The previous end-of-chunk check at the bottom of the loop is removed; a skipped final page now exits through the same top-of-loop check on the next iteration. Single-page chunks and the page-plan path are unchanged.

Test

New AlignedSerialChunkEndTest.SerialReadStopsAtChunkEnd in cpp/test/reader/aligned_serial_chunk_end_test.cc: writes a 40-row, two-column aligned chunk with 8 points per page, drives AlignedChunkReader through the serial path with a 40-row TsBlock, and verifies all 40 rows decode and the read ends with E_NO_MORE_DATA. Fails with ret=35 before the fix.

Full TsFile_Test: 1475 tests ran, 1472 passed, 3 skipped. mvn -o -P with-cpp spotless:check passes.

AlignedChunkReader::get_cur_page_header() resets the page header and
returns E_OK once a chunk's data has been fully consumed. The serial
multi-value path treated that reset header as a page to decode,
decompressed a zero-byte page and surfaced E_TSFILE_CORRUPTED for
multi-page chunks.

Check has_more_data_multi() right after the headers are fetched and drop
the now-redundant check after the skip branch, so the reader reports the
end of the chunk instead of decoding an empty page.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the chunk-completion handling change.

No open issues 🎉

What changed in this PR

Fixes end-of-chunk handling in the C++ serial aligned multi-column reader so normal completion returns E_NO_MORE_DATA instead of a corruption error.

Changes:

  • Checks chunk exhaustion after fetching page headers, before attempting to decode an empty page.
  • Adds a regression test verifying all 40 rows across multiple pages and two columns are read successfully before completion.
File Description
cpp/​test/​reader/​aligned_serial_chunk_end_test.cc Adds regression coverage for serial multi-page reads and clean chunk completion.
cpp/​src/​reader/​aligned_chunk_reader.cc Moves the exhaustion check before decoding and uses the multi-column data check.

Review effort: Balanced

@ColinLeeo
ColinLeeo merged commit c1b44eb into develop Nov 13, 2026
50 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.

2 participants