Repository navigation
fix(load): honor line terminators in parallel file splits - #30364
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? |
|
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: 6899b9bd826feef2d59641baef59d477f01eb073
Assessment: request_changes
Reviewed the complete five-file delta and affected callers. Bounded scanning, probe cleanup and range clamping fit the existing owners, but multi-byte delimiter alignment introduces a confirmed record-corruption case.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P2
pkg/sql/colexec/external/external.go:800: With LINES TERMINATED BY '||', a non-strict parallel split starts on the second byte of a terminator, and the next record’s first field starts with '|'. No quoting, escaping or embedded complete delimiter is required.
Impact: The scanner accepts a match spanning the preceding terminator and the next field, returning an offset inside that record. Range parsing then adds a partial row and removes the field’s leading '|'. Establish valid delimiter alignment before accepting the boundary, or conservatively avoid ambiguous splits, and add this boundary regression.
Evidence: The retained TestReviewNonStrictOverlappingBoundary uses a real file containing 'a,bbb|||c,d||' and calls ReadFileOffset with two readers. HEAD returns [0,8,8,-1]: serial rows [[a,bbb],[|c,d]] become [[a,bbb],[|],[c,d]]. The identical probe passes against the complete merge-base overlay. overlap-head.log/receipt 1792132197345603207-3.json records exit 1; overlap-base.log/receipt 1792132213375906817-3.json records exit 0.
Validation:
-
Isolation preflight passed. Native reuse verified 192 current inputs and 19 artifacts against retained repository build-owner evidence.
-
Focused boundary and compiler tests passed with -vet=all. Complete external and compile packages passed with -count=1 and -vet=all in 34.183s and 9.053s; receipt 1792132291288616143-3.json.
-
Verified clean source, frozen patch, formatting and all five merge-base overlay files. Commands, source fingerprints, exits and logs are reconciled in review-evidence-audit.json under /home/xupeng/.local/state/mo-bot/jobs/eed0c5bbe55c092c17f05ee7/attempt-1. Final audit receipt 1792132353560533155-4.json passed.
Limitations:
-
The counterexample exercises production offset discovery and CSV parsing directly; it bypasses the large-file threshold for automatic SQL splitting. No live large-file LOAD or S3 reproduction was run.
-
Scanning has fixed buffering plus O(delimiter length) state; no independent performance benchmark was run. Author scale-test claims and frozen green CI statuses were not independently reconciled from raw logs. local_validation was empty, and the full linked issue text was not supplied.
6899b9b to
9d15af1
Compare
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 9d15af1b8c1ee9124fe3cee407cae3e7aea83a67 against merge-base 575d57ae5546aa788707707ffe0af7f128d91f1a: no blocking findings.
Read the full linked issue, all reviews/comments (no inline threads), the increment from reviewed head 6899b9bd826feef2d59641baef59d477f01eb073, and the complete five-file diff. The previous self-overlapping-terminator corruption is fixed: overlapping matches remain visible, and an accepted bordered delimiter has sufficient lookbehind and no overlapping predecessor. Ambiguous periodic runs conservatively remain in one range through a safe boundary or EOF. This retains the documented physical-delimiter contract; it does not claim arbitrary quote/escape resynchronization.
Checked configured/default terminators, cross-buffer matches, EOF/error/cancellation handling, synchronous probe ownership/close, remaining-range clamping, and the runtime empty-range path (readFile -> CsvReader.Open). Memory is fixed buffering plus O(delimiter length), with no new goroutine, shared lifecycle or synchronization protocol.
Independent validation:
- Fresh native build and full external / compile package suites,
-count=1 -vet=all: PASS (605 / 1,450 root tests; 34.298s / 8.854s). - Committed real-file overlap regressions preserve all serial fields across 2/3/4 readers.
- Independent exhaustive oracle compared every accepted suffix-probe cut against greedy delimiter consumption from the actual file origin: 122,910 probes, 19,882 accepted cuts, no misaligned cut.
- Actual public-MySQL LOAD DATA on a generated 272,272,002-byte file, with embedded LF data and the automatic midpoint on the second byte of
||immediately followed by a field-leading|: serial and non-strict parallel under both permissive and default SQL modes all produced 17,000 rows, 272,000,002 payload bytes, 17,000 distinct IDs and zero invalid/NULL tails. Full-field joins against serial found zero differences. Logs confirm both parallel statements used two real ranges:[0,136152018)and[136152018,EOF). Final complete probe passed in 12.658s.
The large test is an isolated review probe, not an ordinary small BVT or a throughput benchmark. No S3/cloud execution or all-CI-complete claim. Temporary probes and owned worktrees are removed after verified review delivery.
|
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: 9d15af1b8c1ee9124fe3cee407cae3e7aea83a67
Assessment: request_changes
Reviewed the complete five-file delta and affected callers. Synchronous probe cleanup and unified range assignment are appropriate, and the previous overlapping-terminator concern is fixed. However, the new boundary scanner introduces confirmed data corruption when a field separator contains the line terminator.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
- P2
pkg/sql/colexec/external/external.go:808: Load unquoted CSV using FIELDS TERMINATED BY 'x||y' LINES TERMINATED BY '||' PARALLEL 'true' STRICT 'false', with a file large enough for multiple reader ranges.
Impact: The scanner accepts the embedded '||' inside a field separator as a record boundary, whereas the CSV parser consumes 'x||y' as one field token. Splitting there creates extra rows and damages fields. Account for field-separator tokenization, or conservatively avoid byte splitting for conflicting delimiter configurations, and add a regression test.
Evidence: For 'aax||yb||ccx||yd||', serial parsing yields [[aa,b],[cc,d]], but candidate offsets [0,14,14,-1] yield [[aa,b],[ccx],[yd]]. The exact base implementation preserves both rows. Public SQL reproduced this with a 272,340,000-byte file: the candidate imported 17,001 rows instead of 17,000, with two damaged tail fields under empty SQL mode. The same fixture with both changed production files overlaid from the merge base preserved every field under both SQL modes. Retained evidence: candidate.log, candidate-base.log, field-public.log and field-public-base.log in the assigned diagnostic directory.
Validation:
-
Preflight passed. Verified 192 native inputs and 62 retained artifacts against current sources; the repository native build owner completed successfully.
-
Full external and compile package suites passed with -vet=all, -count=1 and the supplied test executor. Additional checks covered cancellation during scanning and 571,454 raw-delimiter alignment probes.
-
Public SQL validation of the original overlapping-terminator case passed with actual two-range execution and full-field comparisons.
-
Both the small parser reproduction and public SQL regression failed on the candidate and passed with exact-base production overlays.
-
Audited commands, source fingerprints, exit receipts, logs and artifact hashes. Source remained unchanged; formatting and diff checks passed. Evidence index: /home/xupeng/.local/state/mo-bot/jobs/3400e8264a4a8a4ee6d0ee3f/attempt-1/review-evidence.json. Final audit receipt: checks/1792145207552976003-3.json.
Limitations:
-
No throughput benchmark or cloud-filesystem test was run; recorded SQL timings establish functional execution only.
-
The supplied evidence omitted the linked issue's full body and raw author/CI logs. Conclusions rely on frozen sources and independently retained checks.
|
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: 2f0a3df2975884875436ddd4a70b2af2944530ed
Assessment: approve
Reviewed the complete five-file delta and affected callers. Boundary discovery remains with its existing owner; conservative fallback avoids duplicating CSV parsing, and the common range clamp safely handles exhausted workers. Both previous correctness findings are resolved. No actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Evidence retained under /home/xupeng/.local/state/mo-bot/jobs/f64c54e863fb4e4078f94f4a/attempt-1. review-evidence.json reconciles commands, source fingerprints, exit receipts, logs and diagnostic-source hashes. Final reconciliation receipt: checks/1792163219361800442-3.json.
-
Verified the assigned head, merge base, complete patch and unchanged source. Isolation preflight passed. Rebuilt native prerequisites through the repository owner and verified current native provenance; the initial missing-prerequisite attempt executed no tests.
-
Full external and compile packages passed with -count=1 -vet=all and the supplied test executor: 36.839s and 9.002s. Receipt checks/1792163082773728632-3.json matches packages-and-partitions.log.
-
An independent diagnostic using the actual CSV parser checked 1,648,110 suffix probes and 116,175 accepted cuts without serial/split output differences. Permanent tests also passed for overlapping delimiters, conflicting field tokens, EOF, cancellation, read/close failures and exhausted compiler ranges.
-
Public MySQL validation passed nine loads across three inputs exceeding 256 MiB. Serial and parallel loads under permissive/default SQL modes preserved 17,000 rows, 272,000,000 payload bytes and every field in comparisons. Logs confirm conflicting tokens use one range while the comma control retains two. Receipt checks/1792163142645222423-3.json matches public-load.log.
-
Helper microbenchmarks against the base LF implementation showed bounded allocation: approximately 4 KiB versus 2 MiB for a 1 MiB record. Short LF scanning showed no observed slowdown. Multi-byte scanning remained linear, measuring approximately 2.98 ms per 1 MiB.
Limitations:
-
Existing non-strict quote/escape-context limitations remain. Conflicting field/line tokens intentionally sacrifice within-file read parallelism for correctness.
-
Public SQL validation used one CN; compiler tests covered exhausted ranges across multiple scopes. Microbenchmarks do not establish database throughput.
-
One unrelated Arrow/MinIO integration test skipped. Separate linked-issue text and raw author/CI logs were not supplied; local validation independently covered the described contract.
Merge Queue Status
This pull request spent 18 minutes 28 seconds in the queue, with no time running CI. ReasonPull request #30364 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
…6ee4b45a99900a1230b24e70f079b8e99e6a777
## What type of PR is this? - [x] BUG - [x] Test and CI ## Which issue(s) this PR fixes: Related to #30185: test-fixture follow-up to the SQL file access policy introduced by #30212. The affected boundary tests were introduced by #30364 (related to #30341). Their bare contexts became incompatible when #30212 added mandatory acquisition policy. This PR fixes the resulting base-main UT failure observed in [#30297 CI](https://github.com/matrixorigin/matrixone/actions/runs/38940003540/job/117105103611?pr=30297). ## What this PR does / why we need it: Four `ReadFileOffset` test suites construct bare contexts while reading `etl:` fixtures. The SQL file factory requires an explicit access policy, so all 28 subcases fail at admission before exercising delimiter boundaries and probe ownership. Bind the existing `fileservice.WithSQLFileAccess(t.Context(), "sys", "moadmin")` policy in these four fixture contexts, matching neighboring external-reader tests. Preserve every existing row, offset, cancellation, error-precedence and probe-close assertion. Production code and authorization rules are unchanged. One test file, four replacements, zero net added lines. ## Validation - Reproduced on clean latest main `47b9690d`: the full external package fails with the same four suites and missing-policy error. - Full `pkg/sql/colexec/external` UT: PASS (35.204s, `-count=1`). - Incremental SCA for the changed package: gofmt clean; `go vet` passed; golangci-lint 2.14.0 / Go 1.27.1: 0 issues. - Focused `-race` run for all four suites and their 28 subcases: PASS (1.163s, `-count=1`).
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
Parallel
LOAD DATA ... STRICT 'false'searched for a raw LF when adjusting file splits, even whenLINES TERMINATED BYspecified another delimiter. With||records containing LF field data, a split could fragment a source record, silently import corrupted rows in permissive SQL mode, or reject valid input in strict SQL mode.Use the configured line terminator, with the same LF default as the CSV reader. Scan with bounded buffering and linear prefix matching for multi-byte delimiters. Close each boundary-probe reader promptly, propagate non-EOF fast-scan failures, and let both strict modes assign fewer ranges when a probe reaches EOF. The existing non-strict physical-delimiter semantics remain; this does not add general quote/escape-context recovery at arbitrary offsets.
Validation on macOS arm64 / Go 1.27.1:
externalandcompilepackage tests with-vet=allpassed using the repository CGo wrapper.The scale-path SQL experiment stays outside ordinary BVT fixtures because actual byte splitting requires at least 256 MiB. Boundary scanning retains fixed buffering plus O(delimiter length) state; it adds no full-file pass. The original head passed CI; the repaired head will trigger fresh CI on publication. Reporter verification is expected after merge; the issue remains open for that verification.
Review follow-up in
9d15af1b8c1ee9124fe3cee407cae3e7aea83a67, rebased onto official main575d57ae5546aa788707707ffe0af7f128d91f1a:A split inside a self-overlapping terminator such as
||could accept a match spanning the preceding delimiter and the next field's leading|. Enumerate overlapping matches and accept a boundary only after enough preceding bytes are visible to exclude every overlapping predecessor. This preserves ordinary parallel splitting with fixed buffering and O(terminator length) state. Ambiguous periodic runs stay together until a safe boundary or EOF; existing non-strict quote/escape limitations remain.Current validation on macOS arm64 / Go 1.27.1:
||,aaa,abab, missing final delimiters, insufficient lookbehind and long periodic EOF. Ordinary bordered and unbordered inputs retain multiple ranges.-count=1 -vet=all(37.426s / 10.678s). Incremental golangci-lint reports 0 issues; formatting and diff checks pass.|immediately after the terminator crossed by the nominal split at byte 136,169,999. Public MySQL LOAD DATA in serial mode and non-strict parallel mode under both empty/default SQL modes returned 17,000 rows, 271,999,998 payload bytes, 17,000 distinct IDs and zero NULL/bad tail fields. Full-field joins against the serial result found no differences. Both parallel loads used two actual ranges[0,136186020)and[136186020,EOF).New-head CI results are pending publication.
Field-token review follow-up in
2f0a3df2975884875436ddd4a70b2af2944530ed:A raw line terminator can be hidden inside a field separator such as
x||y, or span its suffix and subsequent field data (x|followed by|...). For non-strict byte splitting, detect these conflicts once per file and retain[FileStartOff, EOF)as one range. This preserves CSV tokenization and avoids ambiguous probes; ordinary comma-separated||files retain parallel ranges. Strict parsing and the documented quote/escape limitations remain unchanged. Configuration detection is linear in field/line token length and retains O(line token length) state.-count=1 -vet=allpass (38.692s / 13.344s), incremental golangci-lint reports 0 issues, and formatting/diff checks pass. An independent tokenizer model checked 344,256 suffix probes and 112,768 accepted cuts without a misaligned boundary.x||y(272,441,998 bytes),x|with a following|in field data (272,373,998 bytes), and ordinary comma fields (272,339,998 bytes). Serial and non-strict parallel LOAD DATA under empty/default SQL modes each returned 17,000 rows, 271,999,998 payload bytes, 17,000 distinct IDs and zero invalid/NULL tails; full-field joins against serial found no differences. Logs confirm conflicting configurations use[0,EOF)while the comma control retains two actual ranges[0,136186020)and[136186020,EOF). These are functional scale probes, not throughput benchmarks.Independent gpt-6-astra medium design and final overall review cover the complete five-file change. The large SQL probe stays outside ordinary BVT fixtures because automatic splitting requires at least 256 MiB. Fresh CI will run after publication.