Honor the latest seek when cached-page replay is pending
perfloop-oss/parquet-go · Uncatalogued correctness
https://perfloop.ai/t/oss/case_bdnrr3d671
Verdict
VERIFIED · settled 2026-11-17 · merged as parquet-go/parquet-go#685
What happened: The check fails before this change and passes with it.
Hypothesis
Two successful row seeks without an intervening read can make the next file-backed page read return the wrong row. This affects the public page-seeking operation on valid indexed files. A bounded native check reproduces the problem with both plain and dictionary encoding; consumer frequency and the full affected configuration range remain unknown.
In FilePages.SeekToRow, seeking to lastPageIndex sets serveLastPage and returns. A later seek to another page does not clear that flag, including the f.index == target fast return. FilePages.ReadPage checks serveLastPage before the input stream and returns a slice of lastPage using the newer seek's skip count. Thus the pending cached page and the requested position can describe different pages.
The new Go tests TestHuntFilePagesSeekSequenceSearch and TestHuntFilePagesLatestSeekReplay ran through the repository's test command. The fixture is one row group with two one-row pages containing 0 and 1, explicitly flushed through ColumnWriter.Flush, with separate plain and dictionary columns. The search enumerates sequences in increasing length over ReadPage, SeekToRow(0), and SeekToRow(1), to depth four, with no random seed. In each column it found its first failure at sequence 55: ReadPage; SeekToRow(0); SeekToRow(1); ReadPage. Every shorter sequence passed within this domain. The replay is stored explicitly in the temporary check source.
Commands were `go test . -run '^TestHuntFilePagesSeekSequenceSearch$' -count=1 -v -timeout=2m` and `go test . -run '^TestHuntFilePagesLatestSeekReplay$' -count=1 -v -timeout=2m`. Both exited 1. Both columns reported `step=3 got first=0 rows=1 n=1 err=EOF; want first=1 rows=1`. This is a failed value assertion, not a build or fixture failure. The check source was removed after the runs.
The Case should establish that the latest successful seek determines the next returned row and subsequent page order, including when the second seek uses buffered or physical repositioning. Native regression-test layout is provisional. A control showing the unrepaired implementation returns the requested suffix for this replay would refute the diagnosis; the smallest repair check is to replay it and compare continuation through EOF. Broader sequence and configuration checks remain to be done.
Current upstream https://github.com/parquet-go/parquet-go/pull/272 owns avoiding decode work during skips, not invalidating cached-page replay. Its inspected patch does not implement this repair. The inspected file.go changes in https://github.com/parquet-go/parquet-go/pull/561 reuse page headers; #302 adds a dictionary setter and #557 shares footers. Those are distinct mechanisms. CONTRIBUTING.md names GitHub issues and PRs as the review venue. Merged-history coverage is a gap: this checkout is shallow and the bounded GitHub file-history acquisition was refused with HTTP 403. No performance gain is asserted.
Change to test: Make each successful seek replace the pending read position, including any cached-page replay requested by an earlier seek. Keep the cached-page, buffered-input and next-page positions consistent so reading resumes at the latest requested row without changing the public API.
Where it lives
Evidence
The check fails before this change and passes with it: `For the tested consecutive successful seeks on indexed four-page files, FilePages returns the row suffix selected by the latest seek in order through EOF, with plain and dictionary columns, data page versions 1 and 2, and both buffered and physical repositioning.`
The check fails before this change and passes with it: `For two one-row-page files with plain or dictionary columns and V1/V2 data pages, FilePages returns row 1 then EOF after SeekToRow(0), optional ReadPage, loading OffsetIndex, and SeekToRow(1), and after reading both pages then seeking to row 0 and row 1.`
Checks: 3 of 3 passed. Verification: no defect found.