Skip to content

fix(load): preserve sealed CSV fields on 4.2-dev - #32768

Merged
XuPeng-SH merged 3 commits into
4.2-devfrom
codex/csv-sealed-cr-42
Nov 15, 2026
Merged

XuPeng-SH merged 3 commits into
4.2-devfrom
codex/csv-sealed-cr-42

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #30462; backport of main #30498.

What this PR does / why we need it:

The end-of-record CR strip can remove a byte from an already sealed CSV field. Its stored boundary then exceeds the row buffer and row/header decoding panics. Preserve sealed-field bytes by stripping CR only within the current open field. Genuine CRLF terminators retain their existing behavior.

Backport the producer-side guard from #30498 to 4.2-dev, with exact-value controls for row/header decoding, TrimLastSep, refill/reuse, unterminated quotes and 4.2 retained-field metadata.

Validation on Linux/amd64, CPU-only, Go 1.26.4:

  • The same regression tests with original 4.2 source reproduce slice-bounds panic; the fixed full csvparser package passes normal, race and vet.
  • The diagnostic 4,176 input/config/block combinations reproduce 44 panicking combinations at baseline and zero with this fix.
  • Real LOAD DATA on one private CN preserves the issue field as HEX 617E0D and an empty non-NULL second field; normal CRLF and sealed/current CR controls pass. An unterminated enclosure returns the existing error (20301); repeated LOAD and subsequent queries succeed.
  • Incremental golangci-lint reports 0 issues. Final retained-field test addition leaves production/native inputs identical to the SQL-tested build. Test services and data have been removed.

Full hosted CI is pending. This PR is independent of the CSV allocation optimization.

Keep sealed field indexes valid before row and header decoding.

Backport of #30498; related to #30462.
@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner November 15, 2026 13:21
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Nov 15, 2026
@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 795b906bee7f0a1aaf1a4d4e4b16d91f10766f4a

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: 795b906bee7f0a1aaf1a4d4e4b16d91f10766f4a

Assessment: approve

The guard preserves sealed-field bytes through the existing boundary owner without adding state or another decoding path. Exact-value tests cover row/header decoding, retained fields and ordinary CRLF controls. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete two-file delta, row/header/TrimLastSep/retention consumers, all three discussion entries and linked issue #30462.

  • Isolation preflight passed. The complete-parser differential probe passed 12 candidate scenarios, reproduced eight baseline slice-bounds failures and preserved four CRLF/error controls.

  • Frozen-source, patch, gofmt, whitespace, discussion coverage and execution-evidence audit passed.

  • Assessed author-reported full csvparser normal/race/vet, 4,176 differential combinations and private 4.2 LOAD checks.

Limitations:

  • The local probe replaces four external dependencies with documented standard-library scaffolding; native error codes and live SQL/file-service behavior were not exercised.

  • Author runtime logs were unavailable and six hosted checks remain pending. Linked main/MOTR results are contextual, not fresh 4.2 execution.

XuPeng-SH added a commit that referenced this pull request Nov 15, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to #32751. Port of main #32766.

## What this PR does / why we need it:

CSV fragments spanning read blocks were assembled into a temporary
growing buffer and then copied into the row buffer, repeating allocation
even with a reusable row buffer. Append fragments directly into the
caller-owned row/lookahead accumulator, retaining the single-block path.

Adapt the change to 4.2's raw record bounds and memory reservation
callbacks. Growth grants still precede appends, and rejected lookahead
preserves the prior empty-fragment error result. Keep the existing
conservative reservation envelope.

Six alternating Linux/amd64 CPU benchmark samples with Go 1.26.4:
- Reused plain 1 MiB / 8 MiB fields: 3,399,680 / 43,220,992 B/op -> 0;
time improves about 44% / 55%. Four concurrent 1 MiB readers improve
about 58%.
- Tradeoff: serial small/wide CSV framing is about 3.6% / 3.5% slower
(roughly 1 ns/field). Cold row capacity after an 8 MiB field is about
9.07 MiB versus 8 MiB (1 MiB: 1.20 versus 1 MiB). This targets
large-value ingestion and does not make every workload better.
- Parallel fixtures keep mutable row headers local to each goroutine.
Corrected small-field concurrent controls do not establish a consistent
regression; initial shared-header samples are superseded.

Validation: full csvparser normal/race/vet, focused external
admission/reset/typed-boundary normal/race controls, 4,176 baseline/head
input/config/block comparisons, and final incremental lint (0 issues).
CN RSS evidence is from sibling main #32766; this port has
branch-specific component and consumer validation. The pre-existing
sealed-CR panic found in baseline controls is addressed independently by
#32768.

Full hosted CI is pending. Maintained benchmarks cover cold/reused,
small/wide/quoted/large inputs and independent concurrent readers.

This branch was successfully deployed

No deployments
ci — f3419578 Deployed Nov 15, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants