Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues. [Bug]: __mo_file_line reports wrong physical line after COMMENT or LINES STARTING BY skipped lines #30318 concerns physical-line metadata and [Bug]: LINES STARTING BY silently corrupts rows when a quoted field contains a newline #30319 concerns quoted multiline STARTING BY framing; neither describes storage-error propagation.
Branch Name
main; also reached by the CSV boundary scanner in #30399.
Commit ID
65bcea5 (main parser source); rebased PR #30399 at 339cfc5cc796c371b5dfb0f90dc853f1c1260489 before the correction.
Other Environment Information
Linux/x86_64, Debian 13, Go 1.27.1, repository CPU CGo wrapper. Deterministic in-process fault injection; no external storage server is required.
Actual Behavior
The shared CSV parser can swallow a one-time non-EOF read error during COMMENT or LINES STARTING BY lookahead, retry the reader, and return a successful record. This also lets the non-strict split planner proceed without reporting an underlying storage error.
Executed reproductions on the pre-fix PR: four subcases (COMMENT / STARTING BY × Read / ScanRecord) expected iotest.ErrTimeout but got nil. A consumer regression through getNonStrictBoundary likewise expected the injected storage error but got nil; the probe reader was closed.
Both legacy Read reproductions also fail with the exact main csv_parser.go and main legacy tests restored through a Go source overlay. This is a parser-source baseline comparison, not a full clean-main SQL execution.
Expected Behavior
Propagate every non-EOF storage error without retrying past it or treating it as CSV syntax fallback. Preserve valid final records at EOF and close every opened split-probe reader exactly once.
Steps to Reproduce
Use testing/iotest.TimeoutReader, which fails only its second read and would succeed on a subsequent read. Construct CSVParser with blockBufSize=1 (five effective buffer bytes), fields terminator comma and lines terminator newline.
- COMMENT="#", data="1,xx\n2,y\n": read the first record, then read again. Expected ErrTimeout; actual nil.
- LINES STARTING BY="row:", data="row:1,x\nrow:2,y\n": the first read encounters the injected error after buffering the prefix. Expected ErrTimeout; actual nil.
- Repeat through both
ReadandScanRecordon fix(csv): preserve multiline records in parallel non-strict LOAD #30399.
A minimal test assertion is require.ErrorIs(t, err, iotest.ErrTimeout). The second underlying read is an explicit deterministic fault, not a wall-clock timeout.
Additional information
Root cause: the COMMENT prefix branch discards peekBytes errors. The STARTING BY branch tolerates any error when content is nonempty, although only EOF is safe to tolerate. Both branches are in the existing shared readRecord implementation. A correction and focused regression coverage are being included in #30399.
Activity
fix(csv): preserve multiline records in parallel non-strict LOAD (#30399
XuPeng-SH commentedon Oct 17, 2026
增量实测验证(2026-10-17):main
a322466757b9b0165c59fbda565608653d923b2a,Linux/amd64、Go 1.27.1、匹配 CGo 产物。完整运行
pkg/sql/util/csvparser、pkg/common/runtime、pkg/sql/colexec/external的普通和-race -count=1测试,均通过。external 每次仅跳过一个尚缺 MinIO 依赖的 Arrow 对象存储测试;该跳过项不是本 CSV issue 的通过证据。TestCSVLookaheadPropagatesReadError的 COMMENT/STARTING BY × Read/ScanRecord 四个一次性 I/O 错误注入场景实际执行通过;external 的错误传播、partial-read 错误身份、nil offsets 和 reader close 断言也通过。未把 I/O 错误改作 CSV 语法 fallback。本 issue 覆盖的修复已验证,按约定转给 @Ariznawlll。