Repository navigation
fix: improve JDBC cursor, metadata, and auto-increment compatibility - #27315
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? |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Follow-up review of head 18d9195; the authored surface since my prior reviewed head c567391 is commit d1e8dbe ('fix prepared cursor persistence and statement generated IDs') plus an upstream merge with no conflict-resolution delta. Both of my remaining findings are resolved. (1) P1 parallel preinsert first-generated-ID: fixed via statement-wide coordination — genAutoIncrCol now publishes through proc.SetStatementLastInsertIDIfEarlier, a mutex-guarded min-publish on the shared BaseProcess (all parallel child procs share Base, verified in process2.go); remote CNs return their min in the remote terminal envelope and the client merges it with the same coordinator; prepareRetryTransition resets the value and restores the session baseline so a rolled-back attempt cannot win; the per-statement reset in doComQuery and the per-execute fill-callback rebind in Compile.Reset cover operator reuse. The new parallel race test, multi-batch INSERT...SELECT and all-manual BVT cases, and -race runs (-count=5) all pass. (2) P2 cursor query-result persistence bypass: fixed by reusing the DML RETURNING staged-writer lifecycle — the cursor output callback stages batches into fileservice, the meta is published only after transaction finalization succeeds and before the cursor wire response, and every error path (executeStmtWithResponse error, publish failure, ExecCtx.Close) aborts and deletes staged blocks; the canSaveQueryResult/limitResultSize gates and empty-result metadata (ses.rs set before execution) match the normal SELECT path. All my earlier blockers from rounds 3c63fdd/698e2b7/9ee0452/2b75043 (cursor protocol terminators, empty-cursor lifecycle, TEXT DDL round-trip and catalog recovery, temporal FSP incl. LOCALTIMESTAMP, multi-batch LAST_INSERT_ID, all-manual generated-key clearing, cursor memory accounting for array/decimal/geometry, zero-budget, LONGTEXT row-size overflow, SHOW COLUMNS rendering, legacy-EOF packet ordering, cursor advertisement before txn finalization) were fixed and accepted in prior rounds. Other reviewers' raised findings (aptend's budget/multi-batch/CASE-IF/dynamic-limit, XuPeng-SH's five blockers plus EOF-ordering and finalize-ordering, aunjgr's geometry accounting) are likewise all addressed per the review record and are not re-raised. Verification on this head: pkg/sql/colexec/preinsert (full, plus -race -count=5 on TestGenAutoIncr*), pkg/vm/process (full and -race), pkg/frontend (full), pkg/sql/plan (new control-flow TEXT-family test), and focused pkg/sql/compile remote-run tests all pass with the repository CGo wrapper. No blocking or non-blocking findings remain.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 56c8ce4edd81dcfed7817bfe2a53401de4a852e4. I read the complete review/comment/reply/thread history (all four inline threads are resolved), compared the increment since my prior reviewed head 698e2b7ea397c58af5e26fed1cf4c24198528c54, and re-audited the full cursor, JDBC metadata, and auto-increment diff.
The earlier blockers are closed in the integrated code: cursor retention is bounded and session-accounted (including array/decimal/geometry materialization, explicit zero and live budget changes), cursor execute/fetch now uses a single protocol-valid terminator after transaction finalization and preserves query-result staging, BIT fetches use binary encoding, cursor ownership is released across fetch/reset/close/reexecute/error/panic/session teardown, TEXT-family and temporal/YEAR metadata propagate through planner/protocol/show/recovery paths without LONGTEXT row-size overflow, and statement generated-key state is separated from session LAST_INSERT_ID and coordinated across batches/parallel/remote scopes and retries. I did not find a remaining blocking counterexample.
Verification on the exact head: affected packages (./pkg/frontend ./pkg/incrservice ./pkg/sql/colexec/preinsert ./pkg/sql/plan ./pkg/vm/process ./pkg/sql/compile ./pkg/container/types) pass under the required locally built thirdparties/CGo environment; focused cursor/generated-key race tests pass at -race -count=5; go vet passes for the same packages. The only git diff --check findings are the repository test-result format trailing spaces in existing tabular golden rows.
XuPeng-SH
left a comment
There was a problem hiding this comment.
P1: gate remote auto-increment PRE_INSERT execution on a protocol version that can return statement_last_insert_id.
The previous cursor-response/finalization blocker is closed on this head. However, d1e8dbe adds StatementLastInsertID only to the JSON remote terminal envelope and does not bump or check the deployment MORPC version (latest is still v22). During a rolling upgrade, a new coordinator can send PRE_INSERT{HasAutoCol:true} to an old CN. That old CN generates the auto-increment value but its terminal envelope cannot return statement_last_insert_id, so the coordinator keeps the statement value at 0. INSERT ... SELECT generated keys therefore become wrong and scheduling-dependent in a mixed-version cluster.
I confirmed the missing compatibility gate with a temporary focused regression: set MOProtocolVersion to MORPCVersion22, convert a PreInsert with HasAutoCol=true to a remote pipeline instruction, and require rejection. The test fails because convertToPipelineInstruction returns nil error. The temporary test was removed after verification.
Please introduce the next negotiated MORPC version (or force the generated-ID-owning PRE_INSERT onto a compatible/coordinator path below that version), gate both remote construction/decode as appropriate, and test old-version rejection/fallback plus new-version remote ID propagation. JSON unknown-field compatibility only protects new-server/old-client decoding; it cannot make an old remote server produce the newly required terminal value.
# Conflicts: # pkg/sql/plan/legacy_tinytext_test.go
|
已处理本轮 P1 并更新 PR:
请再次 review。 |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 84fea3d. The previous rolling-upgrade blocker is fixed: MORPC v25 gates remote auto-increment PRE_INSERT execution, the sender/decoder checks are symmetric, and the focused old/new protocol test passes. One test-stability blocker remains in the latest commit.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head c6b2eb3b89497570e6e67768f5c8ef2423372137.
The cursor protocol/lifecycle, JDBC metadata propagation, generated-ID local/parallel/retry/remote paths, and unhappy-path ownership checks are otherwise closed. Focused tests, all affected owning-package tests, amplified race tests, and full -race runs for frontend/compile/preinsert/process pass.
P2 — test/distributed/cases/plan_cache/plan_cache.test:4: the latest stabilization evaluates NOW() once into @plan_cache_now, so the repeated cached statements no longer contain a real-time expression. The expected count = 4 is now tautological because every input is intentionally identical; a regression that incorrectly folds/caches NOW() across executions would still pass. Please preserve deterministic coverage of per-execution current-time evaluation—for example, a focused frontend/plan-cache test that drives proc.Base.UnixTime through known values—while testing the new default FSP=0 behavior separately.
|
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed exact head 911228f. The outstanding deterministic NOW()/plan-cache concern is closed by TestBuiltInCurrentTimestampReadsStatementTimePerExecution, which reuses an overload while varying Base.UnixTime. The exact head preserves the cursor, JDBC metadata, and statement generated-ID lifecycle fixes. No blocking issue found.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Approved exact HEAD 911228f after deep re-review.
The final plan-cache coverage blocker is closed: the distributed case again executes real NOW(6) expressions repeatedly, while TestBuiltInCurrentTimestampReadsStatementTimePerExecution deterministically reuses one overload ID across two statement timestamps and verifies execution-time values. The merge with current main also correctly moves remote statement LAST_INSERT_ID propagation to MORPC v26 because v25 is now owned by UPDATE changed-row counting; old-version rejection and v26 propagation checks are symmetric.
Revalidated focused cursor packet/commit-failure/geometry accounting, generated-ID local/parallel/process semantics, remote protocol gating, and current-time execution tests. Exact-head CI is green. No blocking issue found.
Merge Queue Status
This pull request spent 21 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #27286
#27292, and #27295.
What this PR does / why we need it:
Validation: full pkg/frontend, pkg/incrservice, and pkg/sql/plan tests pass with the repository CGo test wrapper; focused frontend and incrservice race tests pass; git diff --check passes.