Repository navigation
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? |
|
Protocol allocation coordination: #28272 predates this PR, has completed review/CI, and reserves MORPC v75 for persistent data-branch database identity. Please merge #28272 first, then rebase this PR and advance typed JSON MIN/MAX to v76 (including its v75/v76 boundary tests). Sharing v75 would let either rolling-upgrade capability check falsely admit the other feature. #28272 now records this ordering explicitly and tests the immediate v74/v75 boundary. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
发现 1 个 P1 和 1 个 P2(当前 head ebdf6e2):
P1:协议版本 v75 冲突。pkg/defines/const.go:113 和 json_minmax_protocol.go:150 使用 v75,但 #28272 也声明 v75。部署一个包含 branch identity 但不包含 JSON MIN/MAX 的 worker 时,它会通过 capability gate,却仍使用字节序比较;JSON 整数 {1,256} 的 partial MIN 可能错误保留 256,正确的 1 已被丢弃。请按已有版本分配约定,在 #28272 之后 rebase,将 JSON gates 移到 v76,并补 v75 rejection / v76 acceptance 测试。
P2:缺少分布式执行证据。json_minmax_protocol_test.go:71 的测试主要 mock version response、检查序列化字段,SQL fixture 也没有保证 remote partial placement,因此不能证明混合版本下的实际 MIN/MAX 正确性。请强制 remote partial,用 1/256 验证最终 MIN/MAX、低版本 fallback 和 stale-destination rejection。
当前 exact-head CI build/UT 通过,json_type.sql 为 127 passed、0 failed、2 existing ignores;但 mixed-version execution 尚未验证。
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #26068 ## What this PR does / why we need it: ### Root cause Database-branch identity was inferred only from active ordinary-table rows in `mo_branch_metadata`. A successfully created branch database therefore lost all recognizable identity when its source had no ordinary tables, or after all cloned ordinary tables were dropped. `DATA BRANCH DELETE DATABASE` could not distinguish that database from an ordinary database and rejected the delete. ### Implementation - Persists the categorical `data-branch` identity in the existing `mo_database.dat_type` field as part of the same internal `CREATE DATABASE` operation. - Uses one cluster-wide `MORPCVersion75` gate for every producer and consumer: create, delete, publication classification, logical snapshot restore, PITR, and account/cluster restore. - Rejects branch-database creation below v75 before DDL; at v75 it writes the marker atomically. - Keeps table-receipt validation for every ordinary table. The database marker handles only the previously ambiguous empty, view-only, sequence-only, and all-tables-dropped cases. - Makes ALTER PUBLICATION classify the effective persisted database even when the statement omits a DATABASE clause, including correct cross-account owner resolution. - Preserves statement-local clone context across reusable `ExecCtx` instances. - Serializes branch database deletion against concurrent object DDL using the existing exclusive `mo_database` catalog-row lock. - Restores the marker from authoritative `dat_type` data and preflights snapshot and PITR source identities at their public restore entries before target-account creation, account deletion, session kill, view-metadata invalidation, foreign-key cleanup, table restore, or database replacement. - Adds focused unit, embedded lifecycle, concurrency, restore, multi-statement, and BVT coverage. ### Compatibility Current main owns protocol versions v64 through v74, with v74 assigned to corrected numeric HEX overload identities. This rebased PR claims the next continuous version, v75; it does not depend on #27716 or #28903. Concurrent PR #28950 must merge afterward as v76; the allocation order is recorded in both PRs. Below v75, new branch-database creation and marked restore input fail before mutation, while existing table-backed branches continue to use table receipts. Downgrade does not erase markers. Re-enabling v75 restores marker-aware behavior without migration. No catalog schema migration is required because `dat_type` already exists and is persisted by backup/checkpoint/replay. The exact design revision is `data-branch-database-identity-2026-09-16-r20`. Revision r20 keeps the v75-then-v76 allocation order and v74/v75 boundary coverage, and moves cluster, account, database, and table snapshot/PITR admission ahead of irreversible account, metadata, FK, and object side effects. ### Validation - `go test ./pkg/frontend -run 'Test(DataBranchDatabaseIdentityCapability|DataBranchCreateDatabaseRejectsBeforeExecutorBelowCapability|PrepareLogicalRestoreDatabaseCapability|NewLogicalRestoreDatabaseDefinitionRequiresTypeColumn|PreflightLogicalRestoreDatabases|ValidateDataBranchDeleteDatabaseTargetUsesDatabaseIdentity|LoadBranchDatabaseTypeRejectsMissingDatabase|InstallDataBranchCloneContextRestoresRequestContext|IsUserDatabaseType|DoAlterPublicationDataBranchIdentityCapability|MarkedDatabaseRestoreRejectsBeforeDestructiveWorkBelowCapability|MarkedAccountRestorePreflightsBeforeDestructiveWorkBelowCapability|ClusterRestorePreflightsBeforeAccountSideEffects|MarkedTableSnapshotRestorePreflightsBeforeFkSideEffects|RestorePitrPreflightsBeforeAccountCreation|RestorePitrPreflightsBeforeExistingAccountSideEffects|MarkedDatabaseRestorePreservesIdentityAtCapability)$' -count=1` - `go test ./pkg/tests/issues -run TestIssue26068DataBranchDatabaseIdentityLifecycle -count=1` - `go test ./pkg/sql/compile -run TestCreateDatabaseChecksExistingBeforeSerializingAbsence -count=1` - `git diff --check origin/main...HEAD` All commands above pass after syncing current main; `go test ./pkg/frontend -count=1` also passes on PR head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7`. Isolated `TestScope_Database` fails with the same `missing lock service` panic on both this branch and exact base `2ea4ec2e6ef4b20321a235ef416228506813e39b`; the PR does not modify that DropDatabase lineage-lock path. CI run 34948994437 passed the shared build, arm64 SCA, UT coverage, and both Compose BVT jobs. Ubuntu/x86 UT ended after 71m43s with the global timeout (Error 124) while unrelated fileservice and vm/engine tests were still active; no #28272-owned test reported a failure. The preceding rebased head 55339dc completed Ubuntu/x86 UT and all required checks successfully. On pre-rebase head `2d2af51450241340058720fe786d55a64d1db784`, all build, SCA, and BVT checks passed. The two unrelated failures were rerun after their logs established infrastructure or shared-runner causes: Ubuntu/x86 UT passed in about 49 minutes, and UT Coverage passed in about 30 minutes. On preceding head `81d463a7922448f5713ce10f9463a396e6876ba7`, build, arm64 SCA, UT Coverage, both BVT jobs, and the authorized Ubuntu/x86 UT rerun all passed. Rebased review-fix head `822050e783141dc047260991d1b8c6d67e57c474` passed build, arm64 SCA, UT Coverage, Ubuntu/x86 UT, and both Compose BVT jobs. Current restore-entry review-fix head `a1d4fa4ad6ea2a93643c665c38ceec85ae2bb0b7` is running CI. The diff is confined to data-branch database identity, its producer/consumer/restore paths, design, and tests; no CI workflow is changed. --------- Co-authored-by: XuPeng-SH <[email protected]>
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head ebdf6e20540aafde27528df5c4cb3ac33ef6a5a7, including the full 11-file diff and all existing review/comment history. The typed ByteJSON comparator, aggregate-state ownership paths, spill/merge coverage, and sender/destination fencing are internally coherent, and focused exact-head aggregate, planner-function, and compile protocol tests passed with the required CGO setup. One rolling-upgrade blocker remains: this head allocates v75 to JSON MIN/MAX, while merged PR #28272 has already allocated v75 to persistent data-branch database identity. Current main is therefore conflicted at pkg/defines/const.go, and a simple conflict resolution that keeps both features at v75 would make the JSON capability checks unsound. Please rebase after #28272, allocate v76 to JSON MIN/MAX, and change the boundary tests to reject v75 and accept v76.
ebdf6e2 to
d0b5129
Compare
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. |
|
mo-bot review · Commit: "interrupted" |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 55bf49667146269840dec7b88cf54a5f20a0dec6
Assessment: request_changes
Reviewed all 28 changed files and affected callers. Reusing the typed JSON comparator, aggregate state codec and allocation owner is reasonable, but shared type admission and global folding changes introduce two regressions outside MIN/MAX.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
-
P1
pkg/sql/plan/function/list_agg.go:831: Use JSON as the ordering or tie argument of MAX_BY or MAX_BY_NON_NULL. For rows ('one', JSON 1) and ('two_fifty_six', JSON 256), evaluate max_by(value, json_key, 0).
Impact: The newly accepted query selects 'one' instead of 'two_fifty_six'. Equal ordering keys with JSON tie keys produce the same error, including partial-state merges. Either retain the previous rejection for these aggregates or implement typed JSON key comparison with regression tests.
Evidence: maxByTypeCheck uses MinMaxSupportedTypes for both key arguments. In aggexec/maxby.go, candidateWins delegates to compareVectorValue, which has no JSON case and falls through to bytes.Compare. JSON 1 encodes as 090100000000000000 and 256 as 090001000000000000, reversing their numeric order. The retained maxby_json_counterexample.log verifies this encoding and the newly reachable source paths; it is not a SQL execution log. -
P2
pkg/sql/plan/utils.go:2095: Run SELECT NTH_VALUE(a, BIT_COUNT('3 ')) OVER (ORDER BY a) FROM t.
Impact: A previously valid non-JSON query now fails with incorrect arguments to nth_value. Preserve warning-free speculative folding for unrelated functions and keep the lazy handling scoped to ELT; apply the correction to both constant folders.
Evidence: BIT_COUNT's string overload has rowScopedDiagnostics, so CannotFold now returns early without producing a literal. validateNthValueArgs at base_binder.go:5868–5876 requires that literal and rejects the expression. The pre-change TestConstantFoldBitCountDiagnostics explicitly required the warning-free '3 ' input to fold to uint64(2); this PR changes that expectation to an executable function. folding_consumer_audit.log retains the source comparison and complete rejection path.
Validation:
-
Confirmed the assigned HEAD, clean source checkout and complete 28-file delta; inspected allocation failure/cleanup, reset, partial merge, spill, serialization, NULL handling, binary subtypes and lazy evaluation.
-
Isolation preflight, git diff --check, the encoding counterexample and the folding source audit completed successfully. Commands, HEAD fingerprints, exit receipts and retained logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/72a0be71deae00b3d693849d/attempt-1/review-evidence.json.
-
Frozen evidence reports successful build, UT, coverage, SCA and proxy/multi-CN BVT checks for this HEAD. local_validation is empty; author-reported test counts have no supplied execution receipts.
-
Checked historical compatibility concerns against the current full-shutdown upgrade contract and unchanged protocol owners.
Limitations:
-
No local Go executor, SQL server, BVT, race or restart tests were executed. Findings are established through source control flow and encoding evidence.
-
Raw CI logs and linked-issue bodies were not supplied; their detailed behavioral coverage could not be independently reconciled.
-
No performance benchmark was run. Typed comparison adds semantic comparison work; lazy ELT adds O(rows × branches) masking while avoiding unselected subtree execution. Full-shutdown persistence remains without a locally verified restart run.
aptend
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 55bf496, all 28 changed files, the delta from my prior reviewed implementation, and all historical reviews, replies and thread states.
The prior capability machinery is actually removed and upstream protocol owners are unchanged. I assessed the explicitly supported full-shutdown upgrade scope; this review does not demand or certify mixed-version rollout. Typed MIN/MAX state ownership, allocation-failure preservation, spill/merge and selected-subtree ELT paths were traced.
Two blocking regressions remain, detailed inline. Both were independently reproduced through the real SQL frontend: all four JSON-key MAX_BY variants pick the wrong row, and an existing warning-free NTH_VALUE constant expression is rejected. The latter also passes the identical planner test on the exact merge-base. Ordinary JSON MIN/MAX, numeric-key MAX_BY and lazy ELT controls pass.
Current green CI does not cover these counterexamples. Temporary diagnostics are removed; no production code was changed.
|
Validated and published ad03895 for the two current shared-consumer regressions. Native provenance, focused tests, all three owning packages, incremental vet and configured lint passed. Normal canonical BVT: MAX_BY 22/22, NTH_VALUE 31/31, JSON string consumers 59/59, each repeated twice (224/224); six same-instance teardown assertions passed. Both exact unfixed production overlays fail the new regressions. Canonical expected files were not regenerated. The first BVT attempt failed before SQL because this tester rewrote the .codex parent path; a private dot-free staging path with byte-identical canonical files fixed the harness, and the original failure is retained. @aptend: requesting re-review of the two verified regressions under the full-shutdown scope explicitly assessed in review 5609771930. The older mixed-version thread remains open and no such experiment is claimed. @XuPeng-SH: the two current P1/P2 findings have the same evidence. Your earlier explicit real remote-partial acceptance remains unverified in the ledger; please confirm whether it is retired by the current full-shutdown scope. I have not automatically re-requested your review or treated this evidence as a mixed-version/restart qualification. New-head CI and deployed full-shutdown persistence QA remain separate gates. |
aptend
left a comment
There was a problem hiding this comment.
Re-reviewed exact head ad03895, the complete 33-file diff, the 13-file increment from my previous review, all historical reviews/comments/author replies, and resolved/unresolved threads. No remaining blocking finding.
Both previous regressions are independently closed through the real SQL frontend: all four JSON-key MAX_BY/MAX_BY_NON_NULL cases now reject safely while numeric keys and JSON return values still work; warning-free BIT_COUNT('3 ') again supports NTH_VALUE, with exact row results and the warningful rejection control. Prepared ELT error->success reuse and selected/unselected warning counts also pass.
Validation: focused regressions, all eight owning packages in normal mode, the independent single-CN SQL diagnostic, go vet and formatting/diff checks pass on this head with worktree-built native artifacts. Aggregate ownership, failure atomicity, typed merge/spill/codec, NULL and lazy-selection paths were reviewed. Canonical BVT double-run receipts are author-reported, not independently replayed by me. Current full CI is still pending; local configured lint could not start because the installed linter targets an older Go version.
Approval retains the explicitly assessed full-shutdown/all-nodes-same-release scope. It does not certify mixed-version rollout, a live shutdown-upgrade/restart, or deployed persistence QA. The historical remote-partial thread is not automatically resolved by this review.
|
Published a test-only FIN-ACK fixture correction at The fixed case passed 5 normal and 5 race executions. The owning compile package, cancellation/shared-budget siblings, vet and configured incremental lint passed with no skips. Controlled old-head and virtual exact-base contrasts each reproduced the prior fixture contradiction 3/3; this is scoped fixture evidence, not attribution of the historical CI scheduler or a full historical-binary result. New-head CI remains pending; no CI rerun, thread resolution or re-review is inferred. The real remote aggregate partial/stale-destination finding remains open. |
|
Published pinned conflict integration at Six owning packages with vet and the corrected configured lint passed; two named planner test-node skips remain disclosed. The normal canonical data/error run completed all five cases twice: 716 success, 4 original annotated ignored, 0 failed/abnormal, with ten real filename-schema admission/absence/teardown checks and cluster close. Native generation was complete but local-only, not reusable provenance PASS. The independent strict-metadata diagnostic remains failed/unresolved. Original failed setup/private-oracle receipts are retained; the successful rerun changed the actual resource binding and corrected the private ownership assertion, not product source or canonical expectations. No strict-metadata PASS, fresh CI green, remote aggregate CR closure or deployed acceptance is claimed. Outstanding real remote aggregate partial/stale-destination evidence remains open; no new resolve/re-review action was taken. |
|
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-xupeng · review
Commit: 529abda180ac0312649bbf04d52fe6a1a20f7b88
Assessment: approve
Reviewed the complete 19-file delta, affected owners/callers, and supplied review history. No actionable defects remain within the declared full-shutdown, same-release deployment scope. Typed JSON comparison reuses existing aggregate and spill machinery; MAX_BY boundaries, allocation cleanup, folding behavior, and the timeout fixture are sound.
Model: gpt-6-astra / xhigh
Session: 01a14d34-4e51-79a3-a62d-6c9c16279dc8 · slot 0 · generation 0
Validation:
-
Confirmed the frozen HEAD and clean source; git diff --check passed.
-
Isolation preflight passed. Built native prerequisites through make cgo in the diagnostic checkout; repository provenance verification passed and all 192 native inputs matched.
-
Focused tests passed: 54 top-level tests, 267 tests/subtests across aggexec, group, plan, function, and compile; no failures or skips.
-
Executed typed JSON comparison, merge, codec and physical spill/reload tests; allocation rejection/cleanup, non-JSON controls, MAX_BY admission, lazy folding, and FIN-ACK timeout/cancellation checks.
-
Reconciled commands, source fingerprints, exit receipts, and retained logs in /home/xupeng/.local/state/mo-bot/jobs/c3955310c47a8073fd332e2c/attempt-1/review-evidence.json.
-
Frozen CI evidence reports successful build, UT, SCA, coverage, proxy BVT, and pessimistic multi-CN BVT.
Limitations:
-
local_validation is empty. Raw CI and author validation logs were not supplied; the reported strict-metadata diagnostic failure could not be independently diagnosed or attributed.
-
No local SQL/BVT server, restart/upgrade, mixed-version, race, or performance benchmark run. Historical mixed-version remote-partial requirements are not certified or automatically resolved.
-
Linked-issue bodies were not supplied; behavioral requirements were assessed from the frozen PR description, comments, source, and tests.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #28869. This branch includes the JSON string-consumer/opaque-rendering integration tracked in #28938; that separate open PR is unchanged, and existing merge-order coordination still applies.
What this PR does / why we need it:
Pinned conflict-integration increment
Published
529abda180ac0312649bbf04d52fe6a1a20f7b88, treeed070db4dae0746723279ed0de346420f49ffb5a, normal merge of exact mainb74ceced223bcf9ae0007445a3dd0f9ddb0cbc48. The six manual resolutions retain main's JSON protocol/fixture cleanup coverage and this PR's warning/lazy-ELT regressions, including all 44 planner mode/scenario cells. No manual production-code change was added for this conflict repair.Local validation on this exact content: six owning packages with vet passed (37,901 test-node runs; 37,899 passes and two explicitly recorded planner skips). Configured incremental lint passed after correcting its CGo include/search environment; the initial preprocessing failure remains recorded. Native artifacts were produced by the official complete local-only generation with 192 source inputs and 45 artifacts rehashed, not advertised as reusable provenance.
Five canonical cases ran twice on one task-owned instance using repository-standard data/error comparison: 716 successful comparisons, four original issue-annotated SQL statements ignored, zero failed/abnormal. The ignored statements are the unchanged two-statement issue annotation in json_type.sql, twice; this is not 720 executed PASS. Resource input was explicitly bound and hashed. All ten filename-derived database admissions, post-execution database/table absence checks, explicit fixture teardowns, entry cleanup and cluster close passed.
An additional strict metadata diagnostic remains FAIL and is preserved separately. Earlier missing-resource setup and the incorrect private positive-table postcondition were diagnosed, retained and corrected only in independent private harness attempts; no canonical SQL/result oracle was generated or weakened. This standard-mode result does not claim strict column-metadata acceptance, clean-base attribution, new-head CI success, deployed QA or full PR/CR completion. XuPeng's actual remote aggregate partial/stale-destination evidence requirements remain unfinished; no automatic thread resolution or re-review is inferred.
Earlier evidence (historical)
Deterministic FIN-ACK timeout fixture increment
Published
f9eff8254a6e67c811fe64c2f9a2675f72b2ac51, treee8d5a26a381a1527da9bb0cfa2d7afd4b342e34c; validation targeta949c88af0ed2cc4fe98e2ac32f0732a1235bd85. The only new file change is the FIN-ACK timeout test fixture. It now uses Go virtual time with the unchanged production deadline and strictly requires a live-context FIN (ID/command/status/FinishAck), deadline expiry andClose(true). No production timeout or mock obligation is weakened.Local validation: the named fixed case passed 5 normal and 5 race executions; cancellation/shared-budget siblings, the full owning compile package (3,723 test-node passes, no skips), vet and configured incremental lint passed. A controlled pre-FIN deadline reproduced the old strict-mock contradiction three times on the old head and three times with a complete-graph virtual exact-base overlay. The latter is not a clean historical checkout or full historical binary, and does not establish the exact scheduling of the original CI incident. Native provenance was reverified.
Prior functional/BVT evidence applies to unchanged product content only. New-head required CI is pending, with no rerun requested. XuPeng's real remote aggregate partial/stale-destination acceptance remains unfinished; this test-only increment does not resolve it or imply full PR/QA acceptance.
Earlier evidence (historical)
Allow MIN/MAX over JSON in ordinary, grouped, window, View and CTAS queries. The result remains JSON, SQL NULL is excluded, and JSON null participates in typed JSON ordering. The existing typed comparator replaces raw storage-byte ordering: for either input order of
{1,256}, MIN is 1 and MAX is 256. Optimizer extra values are independently owned and allocation-accounted; failed replacement preserves the previous value. Non-JSON executors and existing MIN/MAX overload identities remain unchanged.Retain JSON-aware string consumers, binary-subtype preservation, canonical opaque visible text, and lazy JSON ELT evaluation. ELT evaluates only its selected value subtree; unselected invalid JSON remains unevaluated during execution and planner/API folding. Parent CONCAT and nested ELT cases exercise that behavior.
Upgrade contract
This PR supports full shutdown upgrade: stop service, upgrade all CN/TN nodes to the same release, then resume traffic. It does not add mixed-version rollout support. The PR adds no protocol versions, capability flags, local/cached or persisted-expression version gates, sender/receiver fences, or compatibility-only test paths. The protocol ledger and existing upstream protocol owners match verified main
a949c88af0edexactly. Existing ByteJSON storage encoding is retained; no new wire fields are introduced.The earlier protocol-129/130 rebase candidate has been replaced. The original branch history was consolidated into one commit preserving its functional net changes and original author; the shutdown-upgrade cleanup removes the now-unnecessary compatibility machinery.
Current validation (2026-10-22)
Candidate
55bf49667146is rebased onto maina949c88af0ed. Go 1.27.1, Darwin arm64, CPU CGo:git diff --checkpassed.0c42439de01ae36cd58304ccf46f27c111b8aa96f57177958660d5c070885d32.Full BVT, race and an end-to-end restart were not rerun for this cleanup. Earlier public-SQL, prepared-statement, canonical-BVT and mixed-binary receipts refer to their historical heads and are not current-head evidence. The previously documented JSON partitioning compatibility limitation remains outside this PR; this change does not edit that owner. Existing reviewer threads have not been automatically resolved, and this local review is not a whole-PR approval or deployed QA sign-off.
QA required: yes — grouped/window/View/CTAS JSON ordering and NULL behavior, prepared parameter/error reuse, physical spill/reload and normal persistence after a full shutdown upgrade.