Repository navigation
Conversation
…28275-foundation-delivery-20261111
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 4f1836d659a36cd197e0f4260b134f6a68f2a263
Assessment: request_changes
The new discussion identifies an additional aggregate compatibility regression, confirmed by source tracing. The earlier accounting P2 remains open. Existing ownership mechanisms are coherent, but canonical admission was not integrated with existing aggregate encoders.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
-
P1
pkg/container/vector/json_admission.go:42: JSON_ARRAYAGG or JSON_OBJECTAGG processes supported legacy CHAR/VARCHAR/TEXT bytes containing malformed UTF-8, such as 0xff, in values or object keys.
Impact: Previously successful aggregates now fail during Flush with invalid JSON vector payload, including ordinary execution that never uses the new readers.
Evidence: Legacy text admission permits these bytes. jsonagg2.go:670-672 and :1227 preserve them, and both aggregate flush implementations reach the changed validator. Baseline IsValidByteJson accepted their framing; ValidateStoredJSONDocument rejects their UTF-8. Normalize producer strings and keys using the established U+FFFD policy before canonical admission, with matching size accounting and key ordering/deduplication. Add regressions for both aggregates, including object keys. -
P2
pkg/container/vector/json_reader.go:272: Use nil allocation selection with nonnil statement admission and backing larger than the remaining statement budget.
Impact: Snapshot, builder and selection backing can exceed statement and CN execution-memory ledgers after only fixed metadata is reserved.
Evidence: Retained from review 5872144112: NewJSONReadSetWithAdmission accepts this combination, but duplication receives nil selection and allocOwned uses ordinary mp.Alloc. Lease size reporting does not reserve capacity. Charge physical backing before allocation, retain charges through final release, and test transient-only payload and row-map limits.
Validation:
-
Compared the prior review with new discussion and reconciled all seven discussion entries.
-
Traced legacy text admission, both aggregate execution modes, encoders, baseline validation and candidate rejection.
-
Reused unchanged prior coverage and supplied CI reports. Artifact audit passed: checks/1794477401859085977-3.json and followup-audit.log.
Limitations:
-
No local Go or SQL reproduction was run; both findings are source-established.
-
No released-binary upgrade failure is claimed.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Follow-up review of head 595c99f (delta 4f1836d..HEAD is the single fix commit 'account JSON reader backing and preserve aggregate text'; no merge commits in that range). Both previously blocking topics are fixed and I withdraw them. (1) Legacy aggregate text (P1 raised by Codex review 5872192571, repeated by mo-bot 5872439230): JSON_ARRAYAGG/JSON_OBJECTAGG now normalize malformed UTF-8 to U+FFFD only at final emission in both ordinary and accounted execution; raw bytes remain for DISTINCT and merge; normalized object keys are ordered and deduplicated before encoding with last-entry-wins semantics; the accounted path pre-sizes and pre-admits its scratch and is failure-atomic (normalizeJSONAggregateEntries, json_utf8.go, jsonagg2.go). Regressions cover array/object, values, keys, binary keys, DISTINCT, collisions and scratch-admission failure, plus SQL BVT json_agg_legacy_bytes_32546 (x'ff'/x'fe' inputs to EFBFBD output). (2) Transient-only reader budget (P2 from mo-bot 5872144112, retained in 5872439230): admission without an allocation account now wraps into a transient AllocationAccountSelection; snapshot dup, builder growth, dictionary materialization, bitmap/sidecar growth (makeSelectedSlice), Select/materialize mappings, delete mappings and reader destinations all charge physical backing through mpool.AllocAdmitted, which reserves before allocation, admits replacements before freeing old blocks so the temporary peak is covered, releases on Free, cross-pool Free and noLock teardown, and keeps the opaque release until final release; FreezeVector copies instead of pinning under the transient policy. Finite-budget refusal regressions were added in vector, objectio and mpool covering growth rollback, detach, pin transfer, concurrency and teardown. I found no concrete defect in either fix after tracing every allocation site in the delta. One new non-blocking residual remains, recorded below: non-aggregate producers of legacy malformed text through the same tightened validator now error where origin/main succeeded. fengttt's approval predates the fixes and is context only. Test limitation: no Go tests or the BVT could be run in this checkout, because CGO builds require jemalloc headers under thirdparties/install (a prerequisite this review must not build) and CGO_ENABLED=0 builds fail on missing malloc.SimpleCAllocator; the P2 finding below, like both prior reviews, is source-established.
P2 - Legacy malformed text still hard-fails in non-aggregate JSON producers (JSON_ARRAY/JSON_OBJECT built-ins, stored legacy documents) (pkg/container/vector/json_admission.go:42)
This is distinct from the raised-and-fixed aggregate finding (Codex 5872192571, mo-bot 5872439230): that covered the JSON_ARRAYAGG/JSON_OBJECTAGG encoders embedding CHAR/VARCHAR/TEXT bytes into TpCodeString, and 595c99f normalizes exactly those encoders to U+FFFD. The residual is a materially different set of producer call sites through the same tightened validator. validateJSONValue (json_admission.go:42) now calls ValidateStoredJSONDocument, whose TpCodeString check rejects invalid UTF-8, where origin/main accepted it via IsValidByteJson (framing only). Concrete path: jsonvalue returns raw string bytes (pkg/sql/jsonvalue/value.go:105), opBuiltInJsonArray/JsonObject build CreateByteJSON values and append them via rs.AppendBytes (pkg/sql/plan/function/func_builtin_json.go:2301 and 2513), which is validated in BuildVarlenaNoInline (pkg/container/vector/vector.go:13257). So SELECT JSON_ARRAY(v), or JSON_OBJECT(k, v) with the column pairs in this PR's own BVT table json_agg_legacy_bytes_32546 (VARCHAR holding x'ff'), succeeds on origin/main and now errors with 'invalid JSON vector payload'; a stored JSON document that itself contains malformed bytes (creatable only through the pre-PR lax producers now normalized) fails the same way when re-emitted through any T_json-producing operation. Author response position: the documented design contract makes canonical UTF-8 the admission boundary ('canonical JSON admission validates UTF-8', 'malformed-input failures stay visible', 'JSON inputs do not receive this text conversion'), so erroring is deliberate for these producers; the normalization amendment covers only the retained-bytes aggregate pipelines. Why this is non-blocking rather than a repeat of the aggregate blocker: MySQL rejects invalid utf8mb4 in JSON text and cannot even create such VARCHAR data under a utf8mb4 charset, the input class is legacy laxness the engine now intentionally surfaces instead of silently rewriting, and the aggregate path - the common legacy pattern both reviewers blocked on - is preserved. Closing options: extend the established U+FFFD policy to the builtin JSON constructors (and CAST-to-JSON producers) for uniform behavior, or document the error contract for these producers in design decision D1; a regression covering JSON_ARRAY(v)/JSON_OBJECT(k,v) over the legacy-byte column would pin the intended semantics either way.
|
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: 595c99fabe2a1a0bb987cf52f0e6c860fd837054
Assessment: approve
Approve D1 at this head (docs/design/json_read_ownership.md; #32546 → #28275) and the foundation implementation. Separate Vector/cache owners have justified lifetimes and reuse existing validation, leases and budgets. Both prior blockers are resolved; no actionable findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
Reviewed all 61 changed files, relevant owners/consumers, linked issue context and all ten discussion entries; saved discussion-assessment.json.
-
Isolation preflight passed; verified 198 native build inputs and eight retained artifact hashes.
-
Nine normal package suites passed: 8,969 test/subtest passes and six FileService skips. Evidence: owning-tests.jsonl and checks/1794490627653994115-3.json.
-
Four owning-package race suites passed; seven exact concurrency tests each passed 100 race repetitions. validation-summary.json maps logs to receipts.
-
Frozen evidence reports successful required CI and two 10/10 runs of the new aggregate SQL BVT.
-
Final source, patch, discussion and receipt audit passed: final-audit.log and checks/1794491095481066857-3.json. Source remains unchanged.
Limitations:
-
Consumer #28275 implementation, fresh composed SQL/performance and released-binary upgrade were outside local validation. The historical native abort remains unclassified.
-
Other malformed legacy UTF-8 remains subject to canonical rejection, as accepted in the current discussion.
-
Composite formatting retains the documented conservative memory-admission bound.
|
@Mergifyio refresh |
✅ Pull request refreshed |
🚫 Left the queue · pull request dequeued1 h 44 min in the queue, with no time running CI. So far
Reason Pull request #32546 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.
To get back in the queue
Merge conditions not met when it left the queue
Tick the box to put this pull request back in the merge queue (same as
2 merge conditions met
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
issue #28037 — ownership prerequisite for #28275; this PR does not complete the SQL feature.
What this PR does / why we need it:
The dependent JSON_VALUE work needs to query multiple paths without revalidating an entire binary document for every path. Add immutable, fully admitted JSON read owners and connect them to storage, cache, memory and received-batch publication. A private version owns its descriptors, payload, NULL/constant state and row mapping. Retained readers and views keep that owner alive; query results do not expose its writable backing. Ordinary mutable or unknown input continues to receive complete validation.
The snapshot boundary copies externally aliased input before validation. Private producers can transfer ownership only before exposing writable aliases. Dictionary vectors are materialized into a private version and validated before publication. Accounting includes retained backing and metadata, and allocation, malformed-input and lifecycle failures stay visible. The publication path is demand-driven. This PR does not add JSON_VALUE syntax or a disk/wire format; discovery and consumption by JSON_VALUE remain in #28275.
Design review phase — D1 (approved at
595c99f)Design decision D1 includes query-result and text accounting; the earlier review target
3aa3c20preceded that fix. XuPeng-SH approved D1 and the foundation implementation at595c99f, and gouhongshen also approved that head. These approvals do not imply QA acceptance or approval of the dependent SQL feature in #28275.The path walker admits growing match buffers and merged-array backing before allocation. A query result owns its backing charge until Close; a cursor releases it on ResetQuery or Close. Independently returned text owns a separate charge until its handle closes. Allocation failures are hard errors. For simple eligible scalars, the sealed reader copies directly into the existing accounted result Vector; its fixed formatting scratch is included in the reader's charge. This path does not expose document bytes or add a trusted-input flag. Both Vector and ObjectIO readers use the same path walker and scalar formatter. Their row-mapping and lifecycle implementations are still separate; broader consolidation remains a design-review item.
Composite and extended-value formatting currently reserves a conservative temporary bound of
32 * encoded data bytes + 2304, in addition to the independently charged output. A tight statement budget can therefore reject before actual peak usage reaches the bound. This limitation and its effect on large composite outputs need independent review.Review fixes at
595c99fThe latest review identified two independent regressions; the later XuPeng-SH review repeats the same findings. Both remain subject to reviewer confirmation.
FF/FEbytes and theEFBFBDresult.Local final-tree evidence: the four owning packages passed; MPool, Vector and ObjectIO full-package race tests passed, and three directly affected independent-reader/allocation tests each passed 100 race repetitions. Storage, cache and memory-source publication tests passed. The new standalone BVT passed 10/10 twice on one clean, test-owned single-CN instance after task-service readiness and teardown verification. Configured incremental lint, the repository-pinned
molint, vet andgit diff --checkpassed. The first BVT setup attempt failed because the runner cleaned its selected default database; the independently scoped case above ran successfully without that setup dependency.A local five-pair alternating MPool alloc/free microbenchmark against
4f1836dproduced paired medians 1.006x–1.041x across 64-byte and 4096-byte accounted/unaccounted cases, with unchanged allocations per operation. This is a component measurement, not a fresh combined-tree SQL or end-to-end performance acceptance run; the SQL figures below belong to their stated older trees. The earlier isolated native release failure remains unclassified. Independent D1 approval, final-head CI, reviewer acceptance and QA remain separate gates.Validation and scope
7ac7f329b85787076433bc256d7ab066ff5a1db4includes latest checked main995b843b8363c97450c8ebd4ca285904a9a4bd6fwithout conflicts. The affected query-budget regressions were reproduced failing before the fix. They now cover both reader implementations, wildcard backing and match tables, independent results, cursor reset/close, partial-admission failure, direct output, a real statement allocation account, ownership after source Close, and independent readers under scoped race. The production fix was tested before the main merge; affected packages and SQL/index boundaries were then checked again after the merge.ed025175c334b483913f87d9221b97dbf1750b26, the canonicalfunc_json_value.testpassed 153/153 andfunc_json_value_float.sqlpassed 8/8 after the main merge. The case/result SHA-256 hashes aree818a5428371071f530767cba3da80beede4878184d0b1965c0d50f999b5ace2/80f5e5078d612962fec04de4bd8e175334ed824fb960b78b854a8cf71c95027band2d9ac2c8b685d98e53c4c59a19fc9e1d7160ac48ed1cf1fcfc0173d6760291cf/1b790a0d9a019ed05fddd4bfdba93d1bee244af72798d2fab6172f01bc1deb06, respectively. Focused source publication, persisted data, functional-index composition, affected planner cases, the complete function package, incremental configured lint, scopedmolintand vet also passed locally. These are not new-head CI or deployed QA results.3aa3c20had a failed SCA job:molintrejectedunsafeimports in five new files. The imports were removed; exact platform sizes are computed safely and alias tests use behavioral checks. The repository-pinnedmolintpasses locally on the affected foundation and consumer packages; CI for that earlier head is historical.b16ffdf768e24dbb7f86e13796bddf66affa2baa; compared with the evidence branch, the JSON reader execution code is identical apart from a comment, while latest main changes SQL binary conversion and functional-index planning. After the main merge, SQL was measured again on the combineded02517tree; the resident expression measurements below are attributed to their earlierb16ffdftree.42ea0b3940fe9d9b41f9d37daee767a4de3d2fe6, based on main4df268ea5f21882599fdfd6f415b67f849b99675: focused tests passed in Vector, ObjectIO, ObjectIO/ioutil, disttae, readutil and blockio; configured incremental lint and vet passed. Tests include dictionary reorder/repetition, NULL, malformed descendant/descriptor, allocation failure and retained-owner lifetime, plus source publication and row mapping.0b0eaa2464c6268edbb4855dbbe1c33e5c7540d3(tested asd64cd4945f4a8e6fefc814b85bbd5fbaa83145bb), canonicalfunc_json_value.testpassed 153/153 andfunc_json_value_float.sqlpassed 8/8 on macOS; this is combined-feature evidence, not a standalone-dependency BVT run.Historical paired performance evidence on the combined feature tree
On Ubuntu, five alternating AB/BA pairs used the same previous harness and baseline
4df268ea5f21882599fdfd6f415b67f849b99675. Final SQL used candidateed025175c334b483913f87d9221b97dbf1750b26(tree05c54b0b4d7ffe3bf2da56696fa8ab41654aada1); resident and mutable measurements used the earlier candidateb16ffdf768e24dbb7f86e13796bddf66affa2baa(treed09648a8e9c28f299f3c99a1d4f783570eb5fed8; test snapshot095e4cb003d1d8209804002dfee2c6a70ab3d1c6). Timed SQL includes admission, copying, scanning, evaluation and result release; resident measurements exclude publication. Ratios are medians of paired ratios; each arm's ns/op, B/op and allocs/op are separately computed medians.The worst SQL, legacy-64 and contract-64 paired ratios were
[1.0655, 1.1134, 1.0129, 1.0280, 1.0617],[1.0211, 1.0936, 1.0697, 1.0644, 1.0094]and[0.9977, 1.0162, 0.9926, 1.0190, 1.0252]; all cases in those groups completed. The mutable figure remains the deliberate defensive revalidation path, not evidence of a warm immutable-reader speedup. Ten SQL benchmark rows interleaved runner logs; their metrics were recovered before the next benchmark label, with no ambiguous row.The final SQL replay completed 30 scenarios across 10 timed process windows, with zero process major faults and one global swap-in page during baseline pair 3. Excluding that pair as a sensitivity check leaves a worst median of
1.0636xover 4 pairs; peak process RSS was 467368 KiB. The five-pair figure is the primary measurement. One earlier attempt at this replay exited during compilation with an empty log while its home filesystem had approximately 0.9 GiB free; the cause is unproven. The successful rerun used a task-owned directory on a roomier filesystem and the same benchmark procedure.The preceding
b16ffdfreplay recorded zero global swap-in/out across 50 timed process windows. Five windows recorded 107 total process major faults, predominantly baseline startup/measurement (82in one SQL baseline process); the counter covers the entire process and cannot locate faults within individual timed benchmarks. Excluding affected pairs gives worst medians of1.0802xlegacy-64 (3 pairs),0.8532xwarm (4 pairs), and1.0162xcontract-64 (5 pairs). Its peak process RSS was 514764 KiB. The five-pair figures remain primary; sensitivity checks do not prove that faults had no effect.Historical pre-budget performance evidence
On Ubuntu, the same harness was replayed with five alternating AB/BA pairs, comparing main
4df268ewith combined feature tree0b0eaa2. The transfer used local parentless snapshot commits with identical tree hashes. SQL measurements include admission, copying, scanning, evaluation and result release. Resident lookup measurements exclude initial construction/admission; the legacy/contract comparison covers their shared short-text domain. Medians below are medians of the five paired ratios; displayed ns/op, B/op and allocs/op are separate per-arm medians.The original numerical targets were 1.10x for SQL and 1.20x for resident/64-row cases. The three 64-row cases exceed 1.20x; their paired ratios were
[1.2049, 1.1801, 1.2034, 1.1605, 1.2217],[1.2520, 1.2097, 1.1795, 1.2166, 1.2103]and[1.1820, 1.2039, 1.2179, 1.2007, 1.2003], respectively. The requester has accepted these measured costs for publication; this is not a claim that those numerical thresholds passed or that maintainers have approved the design. The mutable result is the retained full-validation fallback, not the admitted-reader path.All 20 timed expression windows had zero process major page faults and zero global swap-in/out. Across all 50 timed windows, two global swap-in pages occurred in one SQL baseline window; no process had a major fault. Peak observed process RSS across those windows was about 510 MiB, including the process and fixtures. A later one-profile-per-arm diagnostic showed substantial path parsing in both arms and reader/contract work in the candidate, but did not isolate a single cause. It is not an additional five-pair acceptance run.
On the combined
d64cd49tree, the existing 4096-element resident workload entered complete validation three times in total for the combined builder/snapshot cases, including setup, at each of 1, 2 and 8 paths; reader backing stayed at 237592/229618 bytes for the two cases. An earlier SQL instrumentation run on11aadf1(not a fresh run ond64cd49) observed 64 admissions for 64 integer/4096 documents at each of 1/2/8 paths, with 3422400 materialized bytes and zero snapshot bytes in that measured cache-source scenario. These are workload-specific observations, not a claim that every source requires no copies.Retained risk and QA
An earlier Ubuntu proot run of
TestJSONValueFunctionalIndexCompositionon the684413efinal-source overlay failed withdouble free or corruption/ SIGABRT. The temporary crashing test executable was not retained, so its exact binary hash is unknown. Short-path native controls of the same test passed once before and after optimization using binaries with SHA-2561b460339ee0875f6e267130e6f241a46c9d3e0585cfa29f46ebe25c1b9fcfe50andce6e2234563152d614488bc0ed8110a02f0147aa170728dd54d7c36a3e446784. The failure is unclassified and is not represented as fixed; candidate specificity is unestablished. A candidate-specific reproduction requires repair. Reviewers and QA must decide its disposition before merge.QA required: yes — immutable ownership, accounting, source publication, restart/restore and the retained native failure need independent validation. CI and exact-head review do not replace supported-upgrade and deployed QA evidence. The complete raw local logs are retained by the author but are not attached to this PR.