Repository navigation
fix(csv): preserve multiline records in parallel non-strict LOAD - #30399
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
loom seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
ce2d6da to
9ae2e83
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 9ae2e836d571f6382c60b6396fc83b1b801d381e
Assessment: request_changes
Reviewed the complete six-file delta and its parser, compile, and reader consumers. Replaying the existing parser from confirmed record boundaries is a sound design, and focused correctness checks pass. Two actionable gaps remain: avoidable field decoding during planning and missing required SQL-entrypoint regression coverage.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
-
P2
pkg/sql/colexec/external/external.go:942: Parallel non-strict CSV loading scans records containing escaped field values to select boundaries.
Impact: CSVParser.Read unescapes and materializes values that the boundary planner discards, adding allocation and CPU costs proportional to import size before workers start. Reuse the parser's record-framing implementation through an appropriate scanning operation without decoding field values.
Evidence: A retained approximately 16 MiB, eight-range benchmark measured a median 190 ms and 1,334,943 allocations on the candidate. A diagnostic overlay using the same parser's readRecord routine measured 93 ms and 367 allocations with identical bytes read; the focused external boundary tests also passed. See candidate-probe.log, diagnostic-framing.log, and their overlays under the assigned diagnostic directory. These measurements isolate planning, not total LOAD throughput. -
P2
pkg/sql/colexec/external/csv_nonstrict_boundary_test.go:183: Validation requirement: execute SQL LOAD DATA with PARALLEL 'true', STRICT 'false', multiple admitted ranges, and a quoted multiline field crossing a nominal split.
Impact: The new integration test directly invokes ReadFileOffset and CsvReader, bypassing SQL admission and execution. Add and execute a public-path regression that proves multiple ranges are used and asserts complete values and exact row identities without omissions or duplicates.
Evidence: The repository testing contract requires public-path proof for SQL-visible changes. The PR explicitly reports no SQL/frontend BVT execution. Existing load_data.sql coverage uses test_parallel.csv, which is 1,958,890 bytes and therefore falls below the 128 MiB parallel-admission threshold. The new sparse-file compile test also calls the compile helper directly. Consequently, the supplied green BVT statuses do not close this regression requirement.
Validation:
-
Preflight passed. Independently matched 192 native build inputs and seven retained library hashes to the current revision and verified the successful build receipt.
-
Focused Go tests passed with -count=1, -vet=all, and the supplied test-exec: 17 top-level tests and 89 total test/subtest passes across external, compile, and csvparser.
-
The retained multiline counterexample passed on the candidate and failed against the complete base overlay with 'unterminated quoted field', confirming the intended correction.
-
Compared candidate/base planning for ordinary and escaped CSV with two/eight ranges and a JSONLINE control. CSV adds a serial scan; JSONLINE retained its read volume. Ordinary SQL paths outside this splitter remain unchanged.
-
Source fingerprints, formatting, diff checks, overlay hashes, command receipts, and terminal logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/034a9f0a41929577ce72502e/attempt-1/evidence-audit.json. Source remained unchanged.
Limitations:
-
Performance probes used an in-memory ETL reader; SQL throughput, object-store latency, and concurrent-load effects were not measured.
-
Frozen CI reports successful UT, static analysis, and multi-CN BVT checks, but detailed CI logs and retained author validation artifacts were not supplied.
-
The linked issue body was absent from the supplied evidence.
Merge Queue Status
This pull request spent 2 hours 17 minutes 35 seconds in the queue, including 56 minutes 8 seconds running CI. Required conditions to merge
|
…fb2a95dc7e1fdf2e0d61ba24a0c4938e078cc6c
|
独立合并后验证补充(2026-10-17,main
#30378、#30446 已分别附证据并转给 @Ariznawlll。 |
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
Parallel non-strict CSV LOAD can split a valid quoted multiline field at a physical newline, causing reader errors or incorrect records. Choose split points by replaying the production CSV parser from the preceding confirmed record boundary. The new
ScanRecordoperation shares framing and header handling withReadwhile skipping the field decoding and unescaping that partition planning discards.Keep best-effort legacy splitting after a CSV syntax failure. Propagate configuration, storage, cancellation and resource-limit errors; close scan readers before fallback; preserve EOF and close-error handling. Retain the configured, overlap-aware physical terminator fallback and bounded worker assignment from main.
The SQL regression uses the existing one-CN integration fixture and a service/path-scoped testing threshold, with a private local worker budget capped by CPUs and query
max_dop. This allows a 58-byte input to exercise real parallel admission and execution without a large fixture. Production thresholds are unchanged. Both LOAD planning entrypoints use the shared admission helper, and observer callbacks receive copied offsets.Validation before the CI follow-up (
mo-cgo-test, Go 1.27.1, Darwin/arm64):TestLoadCSVParallelNonStrictMultilinepassed through the MySQL frontend normally and under race. It observes two actual ranges[0,39)and[39,EOF)with nominal split 29 inside the quoted field, checks complete multiline/escaped values and exactly IDs 1, 2, 3 without a uniqueness constraint, and checks serial execution. Mutating the observer's private offset copy does not affect execution.external.go: ranges become[0,36)and[36,EOF), and LOAD reports mismatched input columns. This is a read-only source overlay retaining the test control.CI follow-up and error propagation:
TestReadFileOffsetClosesTailScanReaders/partial_read_error. The first CSV replay probe now reports the injected storage error immediately; the old test expected three probes from physical-line guessing. Correct the expected reader count to one, retaining the positive-byte-plus-error injection, exact error identity, nil offsets and close-once checks. Retain the remote follow-up's separate JSONLINE three-probe cleanup case and exact open-attempt assertions. No extra production probes are introduced to satisfy the old assertion.ReadandScanRecord, preserving normal EOF and unterminated final records. This adds no retry, state or persistent format change.Readfailures; this is parser-level evidence, not a full clean-main SQL reproduction.65bcea5d24610dde1a21bb9f4dea1efd82a8ce50, including perf(ci): scope SCA by Go dependencies and shorten freshness BVT #30442's shared mock PID fixture correction for the other coverage failure. This PR adds no runner-process changes.Current Linux/x86 validation (Go 1.27.1,
mo-cgo-test,matrixone_test, bounded GOMAXPROCS=2):TestLoadCSVParallelNonStrictMultilinepassed normally and under race (8.568s / 8.225s) after the error-propagation correction.Planning benchmark: approximately 16 MiB, eight ranges, production parser configuration, one excluded warm-up followed by three measured rounds per input/method (
BenchmarkNonStrictCSVBoundaryFraming,-benchtime=1x, measured-count=3). Every sample asserts identical boundaries and 16,056,320 bytes read, including read-ahead. Medians on Apple M4, GOMAXPROCS=10:Escaped-input allocated bytes drop from 21,130,072 to 2,337,472 per operation. These are warmed in-memory boundary-planning measurements; SQL throughput, remote storage latency and concurrent-load effects were not measured. Partition planning still adds a serial framing pass plus per-reader read-ahead and opens. Syntax fallback remains best effort for malformed files. The original #30378 is left open for reporter verification after merge.