Repository navigation
[4.2-dev] Fix transactional index authorization and utf8mb4 column modification - #33163
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. |
8bd8db1 to
d303c25
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 3c0e438d61e6696d60b66bb0ef8c833106d86a25
Assessment: request_changes
The change reuses existing authorization and text-storage mechanisms, and the earlier foreign-key, no-common-ancestor branch-diff, and rename concerns have targeted fixes. Two issues remain: the view migration changes a released catalog handler while missing tenants already at that catalog version, and the common-ancestor branch-diff path still rejects equivalent text selectors. The cluster-table DUMP fingerprint exception is accepted and non-blocking.
Model: gpt-6.1-terra / max
Session: 01a2110f-4081-7e00-8415-e36a337ad118 · slot 0 · generation 12
-
P2
pkg/bootstrap/versions/v4_0_6/tenant_upgrade_list.go:29: Upgrade a v4.2.9 deployment already at catalog 4.0.6/5, then create or modify a text column with CHARACTER SET utf8mb4 COLLATE utf8mb4_bin.
Impact: The existing information_schema.COLUMNS view continues to report utf8 and utf8_bin, while SHOW statements and freshly initialized tenants expose the explicit utf8mb4 declaration. Schema-inspection clients therefore receive inconsistent metadata. For deployments crossing 4.0.6 from an older catalog, the added entry also changes the effects of an already released migration.
Evidence: The released v4.2.9 catalog handler has four tenant entries and offset 5; this change adds a fifth entry while retaining that identity. service_upgrade.go:195 skips an already-current 4.0.6/5 deployment, and service_upgrade_tenant.go:58 skips tenants at the current version. The PR description confirms the old view remains after its v4.2.8 upgrade test; it does not explicitly accept that behavior. The pinned upgrade-compatibility policy freezes released migration effects. Restore the released handler and put the view refresh in a new catalog target that reaches already-upgraded tenants. v4.2.9 release -
P2
pkg/frontend/data_branch.go:1576: Create a table with an implicit VARCHAR column and a row, branch it, modify the branch column to explicit utf8mb4_bin, then update or delete the inherited row on the original table and run DATA BRANCH DIFF.
Impact: The diff can fail with an LCA column type mismatch even though the two column declarations use the same text storage and pass the new endpoint compatibility check.
Evidence: The changed endpoint check accepts scales 0 and 1 via ColumnStorageScalesEqual, but data_branch_hashdiff.go:216 still uses isDataBranchLogicalTypeEquivalent, which requires equal scales. An update or deletion of an inherited row reaches that LCA probe through findDeleteAndUpdateBat. The new SQL regression covers independent tables without a common ancestor, so it does not exercise this path. Apply the storage-equivalence rule to the LCA probe as well and cover a branched-table update or deletion.
Validation:
-
Private-runtime preflight and git diff --check passed; receipts are retained under checks/1795604898417730168-3.json and checks/1795604898417357418-3.json.
-
Compared the v4.2.9 catalog inputs with the pinned base; the checked files match. Receipt: checks/1795604898356978559-3.json.
-
Reused an earlier passing parser-formatting probe after verifying the relevant parser, common, type, and module inputs were unchanged; prior-parser-check.log and checks/1795605510917728734-3.json.
-
Verified 170 tracked native inputs against the retained stage and reconciled all 16 discussion keys; native-inputs.log and discussion-check.log.
Limitations:
-
The focused LCA probe timed out during dependency downloads before any test ran; lca-probe.log and checks/1795605429070907726-2.json. The branch finding is based on source tracing.
-
No live SQL or upgrade was executed in this review. The author-reported BVT, bootstrap, SCA, and upgrade runs have no matching receipts in the supplied local-validation evidence.
|
@XuPeng-SH The catalog decision for this release is final. The Please record the catalog item as an accepted release decision and assess the implementation against this constraint. The common-ancestor |
3c0e438 to
1995ba6
Compare
|
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: 1995ba64591b5bb9131791e999ab3a4b25db8d2d
Assessment: request_changes
The previous same-name common-ancestor issue is addressed, but a renamed-column interaction remains. The new charset selector also conflicts with an existing temporal-precision consumer and is omitted from materialized DIFF output schemas. The accepted cluster-table DUMP/LOAD and catalog 4.0.6/5 exceptions are not findings.
Model: gpt-6.1-terra / max
Session: 01a21244-6c6c-7240-bf19-37c0cdedc87d · slot 1 · generation 15
-
P1
pkg/sql/plan/build_util.go:379: Run EXTRACT(MICROSECOND FROM v) on a VARCHAR column declared CHARACTER SET utf8mb4 COLLATE utf8mb4_bin containing a timestamp with fractional seconds.
Impact: The selector makes EXTRACT interpret the text column as having one digit of fractional precision. It silently rounds the parsed value, which can change query results, predicates and values written by DML.
Evidence: CREATE assigns Scale=1 here, and the binder selects the direct VARCHAR overload. ExtractFromVarchar reads that scale as temporal precision in pkg/sql/plan/function/func_binary.go:6762. The parser in pkg/container/types/timestamp.go:130 would round .123456 to .100000; the existing scale-0 regression expects 123456. Prevent the charset selector from being interpreted as precision and add a regression comparing otherwise identical declared and legacy text columns. -
P2
pkg/frontend/data_branch_hashdiff.go:218: Fork a table, declare utf8mb4_bin on the child, rename the corresponding column on the parent, then update an inherited child row and DIFF the child against the parent.
Impact: The common-ancestor probe rejects the renamed column instead of returning the differences, even though the two text selectors use equivalent storage.
Evidence: When the LCA is the current parent endpoint, lcaProbeColumnLayout first resolves the historical name through dataBranchEndpointColumnDef. Its identity fallback in pkg/frontend/data_branch_output.go:645 requires exact Scale equality and returns nil before the new normalization at this line runs. Apply the storage-equivalence rule during that resolution as well, and cover the combined rename and selector case. -
P2
pkg/sql/plan/build_show_util.go:199: Use DATA BRANCH DIFF ... OUTPUT AS on a table whose projected text column has an explicit utf8mb4_bin declaration.
Impact: The new result table loses that declaration: its column is recreated with the legacy selector, so its SHOW CREATE and collation metadata differ from the base column even for a freshly initialized tenant.
Evidence: The new charset suffix is emitted only by this SHOW CREATE formatter. The output-table builder at pkg/frontend/data_branch_output.go:581 instead calls FormatColType, which omits the selector. Include the declaration when generating the output table's DDL while preserving the intended legacy schema-hash spelling.
Validation:
-
Preflight and the frozen-head git diff --check passed; their receipts are checks/1795611361681398846-2.json and checks/1795611447617453045-2.json.
-
The final audit verified the assigned head, a clean source status, all 19 discussion keys, and the retained check logs and receipts: final-review-audit.log and checks/1795613711385329380-2.json.
-
The reused native build inputs matched 170 tracked source files: native-inputs.log and checks/1795611476103987608-2.json.
Limitations:
-
The focused branch and EXTRACT Go probes timed out during build or linking before any tests ran. Their logs and receipts are retained in the diagnostic directory; they are not test passes or product-test failures.
-
The findings are based on source traces. The proposed public SQL scenarios and full upgrade checks were not executed locally, and the author-reported validation was not accompanied by matching local execution artifacts in the supplied evidence.
-
The later timeout receipts could not fingerprint the source because their preliminary git commands timed out. Earlier checks had clean frozen-head fingerprints, and the final audit independently verified the head and clean status.
|
mo-bot review · Commit: "interrupted" |
|
mo-bot review · Commit: "interrupted" |
|
mo-bot review · Commit: ambiguous review submission; remote marker absent; manual reconciliation required |
|
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: 867fc0a4386fd71590bc27d51e8da4664125f8a2
Assessment: request_changes
The earlier text-primary-key failure is fixed on this head, but a separate COPY ALTER history fails during DATA BRANCH DIFF. The new SQL regression catches removal of the shared comparator through its forward query; its reverse query does not reproduce the originally reported parent-as-base mismatch. The accepted DUMP/LOAD and catalog-target release decisions were honored.
Model: gpt-6.1-terra / max
Session: 01a212e9-10a4-7203-9194-162fe0e55042 · slot 0 · generation 13
-
P2
pkg/frontend/data_branch.go:1600: Create a table with an integer primary key and a VARCHAR column, branch it, insert a row into the child, COPY ALTER that VARCHAR to declare utf8mb4_bin, then insert another child row and run DATA BRANCH DIFF against the parent.
Impact: DIFF returns "invalid input: vector type mismatch" instead of comparing the branch. MERGE and PICK can encounter the same failure when their collected changes span both generations.
Evidence: The embedded SQL probe in review-branch-sql.log reproduced the error; an otherwise identical COPY ALTER without the charset change returned the expected count of 2. The new storage-equivalence check accepts the column types, but equal-layout historical batches retain their generation-specific scales, and validatePutTypesLocked still requires exact types for every inserted vector. Normalize storage-equivalent text metadata during ingestion, or otherwise harmonize the historical batches while retaining the other type checks, and cover this COPY ALTER sequence with a SQL regression. -
P2
test/distributed/cases/git4data/branch/diff/diff_1.sql:159: The new case updates only the child. Reversing DIFF makes that child the base, but it does not update the ancestor that was the base in the reported failure.
Impact: The SQL regression does not independently protect the previously failing parent-as-base update path. The existing forward query and hashmap unit test do cover the shared comparator, but a failure specific to the ancestor/base path can escape this SQL case.
Evidence: The exact reported parent-update scenario succeeds on the current head. In review-key-old-v3-control.log, a diagnostic overlay restoring the old comparator makes that original scenario fail, while the new reverse query still returns 2; the new forward query fails under the same control. Add a separate case that updates the parent after the fork and checks DIFF child AGAINST parent. This is a test-coverage finding; the reported production defect is fixed.
Validation:
-
Private /tmp and loopback preflight passed. Native library provenance matched 170 source inputs.
-
Focused Go tests for branch hash keys, text storage comparison, generated expressions, index authorization and protocol metadata passed on the assigned head; see targeted-go.log and checks/1795624424735629585-2.json.
-
Embedded SQL probes confirmed the original parent-update fix and reproduced the COPY ALTER failure against an unchanged-metadata control; see review-branch-sql.log and checks/1795624620272796529-2.json.
-
A SQL probe mirroring the new bidirectional case passed on the candidate. A deliberately reverted-comparator control established which directions detect the old mismatch; see review-key-candidate.log, review-key-old-v3-control.log and their receipts.
-
git diff --check passed. discussion-assessment.json accounts for all 24 discussion keys.
Limitations:
-
The full BVT, static-analysis and upgrade runs described by the author were not independently rerun; the supplied local_validation list contains no retained receipts for them.
-
Two initial deliberately reverted-comparator controls exited with incorrect assertions about which direction would fail. The corrected control completed successfully; those exits were not candidate failures.
|
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: e6d648f37f20ea8579ee3e53cf67eec352a98344
Assessment: approve
No actionable defects remain in the reviewed scope. The prior DATA BRANCH mixed-history failure and parent-update coverage gap are addressed. The implementation reuses a shared text-storage equivalence rule across schema and hash operations without adding durable state. The accepted cluster-table DUMP/LOAD fingerprint exception and catalog 4.0.6/5 release scope remain in effect.
Model: gpt-6.1-terra / max
Session: 01a21358-dffa-72f0-8c29-d1bc350fbb60 · slot 3 · generation 4
Validation:
-
Private /tmp and loopback preflight passed; see preflight.log and checks/1795626777407785151-2.json.
-
Staged native inputs matched 170 tracked source files, and the required native libraries were built with repository Make targets; see native-inputs.log and the corresponding checks receipts.
-
TestBranchHashmapTextKeyWithExplicitCharset passed on the assigned head with the isolated test executor; see hashmap-retry.log and checks/1795627707566526562-2.json.
-
git diff --check passed, and discussion-assessment.json accounts for all 26 discussion keys exactly once; see diff-check.log, discussion-audit.log and their checks receipts.
Limitations:
-
The author reports SQL/BVT, static-analysis and shutdown-upgrade runs, but their raw receipts were not supplied in local_validation and were not independently rerun.
-
The first focused Go run timed out while downloading dependencies from the configured proxy. The retry using the official Go proxy passed.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #29479.
What this PR does / why we need it:
INDEXprivilege.CREATE INDEXandDROP INDEXcan also use the current transaction's ownership grant for its newly created table. The target's physical and logical IDs and the role checked at the authorization snapshot must match. The local grant is never cached.utf8mb4 / utf8mb4_binon text columns inADD COLUMN,MODIFY COLUMN, andCHANGE COLUMN. Use the same persisted text selector as fix(sql): persist charset defaults and implement table conversion #29374 and the branch's existing UTF-8 storage and binary comparison. Existing implicit column declarations keep their legacy metadata.SHOW FULL COLUMNSexposes the explicit collation. Fresh tenants get the updatedinformation_schema.COLUMNSview. The tenant upgrade to catalog4.0.6/5also refreshesinformation_schema.COLUMNS. Deployments entering4.0.6/5from an earlier catalog receive the new view. Deployments already at4.0.6/5skip the step and continue to reportutf8 / utf8_binthrough their existing view. The catalog identity remains4.0.6/5for both paths. The catalog has a fixed release scope that accepts legacy metadata for clusters already at the target.SHOW CREATE TABLEpreserves the declaration through DDL replay and COPY.Review fixes
Apply the same storage-scale comparison to foreign-key cascades and
DATA BRANCH DIFF. For matching character types in 4.2, an implicit declaration and explicitutf8mb4_binuse the same text storage.Add SQL regressions for both paths and for renaming a populated column with
CHANGE COLUMN. The rename case checks the four-byte value, charset, collation, and comment.Compare equivalent text charset selectors in the ancestor probe while reading the original ancestor storage type. The SQL regression updates an inherited row after one branch changes only its charset declaration and verifies the diff returns the update.
Keep temporal precision independent of the charset selector. EXTRACT parses temporal strings at microsecond precision. ADDTIME and SUBTIME keep the precision of the typed temporal operand.
Apply the common text storage comparison to renamed-column resolution. DIFF OUTPUT AS preserves explicit column charset metadata using the same clause as SHOW CREATE TABLE.
Permit INPLACE widening of compatible character columns with explicit charset metadata. The same physical table retains its data and records the declaration requested by ALTER.
Keep the charset selector out of the MySQL protocol Decimals field for string columns.
Keep charset selectors out of data-branch hash ingestion, key matching and generated-expression comparisons. A branch change stream can read both pre-ALTER and post-ALTER batches. DIFF, PICK and MERGE continue to use the same text key after a charset-only ALTER. Generated columns keep their catalog declarations, and data-branch compatibility ignores selector-only casts.
Validation
mainand4.2-dev.GOFLAGS=-p=4 GOMAXPROCS=5 make static-check-selected GOLANGCI_LINT_CONCURRENCY=4 STATIC_CHECK_PACKAGES=./...completed successfully.4.0.6/5. After altering a populated LONGTEXT column, the tenant from v4.1.4 returned the new charset and collation throughinformation_schema.COLUMNS. The tenant from v4.2.8 retained the old view. Both SHOW statements reported the explicit collation and the four-byte value was preserved on both paths.