Repository navigation
fix(external): preserve saved result scan projections - #33045
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? |
|
This pull request is merged. |
|
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: 3d6b47201529ca72f8733c40353199a18e6cf823
Assessment: request_changes
The patch fixes the reported vector leak and preserves explicitly projected saved aliases. The new type check rejects valid saved CHAR results.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
- P2
pkg/sql/colexec/external/reader_zonemap.go:219: With saved results enabled, run/* save_result */ SELECT CAST('a' AS CHAR(2)) AS sand thenSELECT * FROM result_scan(last_query_id()) AS saved.
Impact: The scan returns an invalid-input error for a valid saved result. A CHAR column also causes the scan to fail when other projected columns are valid.
Evidence: The baseline reader returneda. The candidate returned error 20301. The diagnostic run confirmed stored VARCHAR and projected CHAR. The existing executor materializes folded CHAR literals in a VARCHAR container atpkg/sql/colexec/evalExpression.go:2139. Preserve this supported representation and add the CHAR round trip to the SQL regression.
Validation:
-
The issue reproduction retained 4,608 bytes and two objects with the baseline reader. Both projection orders passed on the candidate.
-
The full external package passed under race detection. In normal mode, the suite passed with the MinIO case excluded, and that case passed separately after an initial startup failure.
-
The affected SQL fixture sections matched all 28 result sets on each of two same-instance runs. The saved-result rewrite suite passed.
-
The baseline and candidate CHAR results, exact commands, and terminal receipts are indexed in review-evidence.md.
Limitations:
-
SQL validation used an embedded single CN through the MySQL frontend. The frozen evidence contained no completed mo-tester comparison.
-
The pre-existing wildcard expansion rule still omits
__mo_filepathby name.
|
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: 30f5dd2f1cb023ef943eb40f3d2e382f0adb8c63
Assessment: approve
The saved-result reader uses physical column ordinals and block row counts, preserving saved aliases and returning NULL for missing columns. It reuses the existing reader and vector APIs while removing the temporary vectors that caused the leak. The prior CHAR projection regression is resolved.
Model: gpt-6.2-sol / xhigh
Session: 01a1feb0-0427-7772-9d89-786820ec84a5 · slot 1 · generation 2
Validation:
-
The focused reader and filter-mapping tests passed, including allocation and decode failure cleanup. Receipt 1795280484261690120-2.
-
A single-CN MySQL probe passed two rounds of filtered alias, reordered projection, NULL, and saved CHAR checks. Receipt 1795280461635351758-2.
-
The external package run reported one MinIO startup failure in an unrelated Arrow test. That test passed on isolated retry. Receipts 1795280453390868104-2 and 1795280586390646820-2.
-
Isolation preflight, native build, and git diff --check passed. validation-index.json maps the checks to retained logs and matching receipts.
Limitations:
- Local SQL validation covered the changed regression on a single CN. The complete distributed BVT suite remained pending in the frozen CI snapshot.
…ils (#33046) ## What this PR does Related to #31625. After rebasing onto main, #33045 already removes the temporary vectors this PR originally fixed. This follow-up adds a missing error-path test to the upstream saved-result reader fixture. The test reads a real saved column, then forces the allocation for a missing column's NULL fill to fail. It checks that the original allocation error reaches the caller, the block offset and published row count do not advance, and the loaded column and caller-owned buffers are released. ## Validation - Existing and new saved-result projection subtests pass under race. - With only the new subtest omitted, the missing-column append error branch has zero hits. Enabling the subtest covers that branch in the same fixture. - Go vet and incremental golangci-lint passed.
main now carries the squashed forms of the PRs this branch was stacked on, through matrixorigin#33027. The merged tree is this branch's own commits (4de8e4e..1cc5610) replayed onto main, with three conflicts and one semantic follow-up resolved: - top: processBatchResident takes main's ordering specs (matrixorigin#33042) and keeps this branch's retained-pool prologue. - external/reader_zonemap: main's rewritten saved-result reader (matrixorigin#33045) writes output vectors, including filled missing columns, through the operator's output pool; the loaded block stays on proc's pool. - group/collation_metadata_test: main's form of the same offset fix. - external/reader_zonemap_test (matrixorigin#33046): the capacity-failure cases bind an accounted output view instead of a per-vector allocation account, and pre-size the first column so the failure still lands on the second. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31625
What this PR does / why we need it:
A saved result with a column named
__mo_filepathreturned the result file's path in place of the saved value. When that column was followed by another projected column, the per-block temporary vector also leaked. An absent leading column could make the batch report zero rows.Read saved values by physical column ordinal and use block metadata for row count. Append missing-column NULLs directly to the output and copy loaded columns by contiguous range. A single loaded batch owns the decoded vectors until copying has finished. Metadata-only projections skip column data reads.
On 57 with Go 1.27.1, reproduced the original 4,608-byte and two-object leak on main. In-memory object tests cover reordered and missing columns, two differently sized blocks, cancellation, and allocation failure after partial output. A single-CN SQL round trip preserved the saved alias in a predicate and returned the expected total and non-NULL counts.
The whole external package passed both regular and race runs. Incremental golangci-lint reported zero issues. The SQL probe also round-tripped typed and untyped NULLs, an aggregate, and
SHOW ACCOUNTSthroughRESULT_SCAN. The distributed regression case is included in the patch. The SQL probe used a private single-CN service.Cancellation is tested after metadata has loaded. Cache-buffer lifetime assertions cover successful reads, append failure after an earlier column has been copied, and failure decoding the second column. Mutation checks confirmed the tests detect ignored cancellation, a missing release, and a double release.