Repository navigation
fix(cdc): fence target resets and reject keyless sources - #28521
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head e6a554e. Request changes for two concrete consequences of admitting a schema without a sink-visible row identity: invalid tail DELETEs and non-idempotent snapshot replay, detailed inline.
Reviewed both changed files in full change-map scope, and traced construction into table-change stream PK extraction, snapshot/tail processing, DELETE-before-INSERT execution, intermediate snapshot commits, durable epoch reuse, error propagation and batch cleanup. Ordinary real-PK upserts and existing secondary-unique-index REPLACE selection remain unchanged. Constructor-only immutable state adds no new race, lock, goroutine or asymptotic work; existing iterator/command cleanup remains in place. However, REPLACE does not synthesize a conflict key, and permitting the fake key crosses the prior admission boundary without making either deletes or retry effects valid.
Evidence: source-level counterexamples against exact-head code and the emitted statement construction; no fresh live CDC/MySQL reproduction or native full-package execution is claimed. Exact-head CI reports successful UT/BVT jobs, but the only added test asserts insertStem/insertSuffix and never executes INSERT/DELETE or replays a snapshot. Public CDC regression coverage is required for this changed SQL/data contract. The PR rationale correctly disclaims fixing the broader incidents, but these failures arise specifically from the newly accepted no-user-PK schema, not from requiring unrelated incident fixes.
e6a554e to
28ad288
Compare
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of the complete current diff and the delta from the previously reviewed e6a554e62693c2c0d18b8274d54a82bcf30782ff, after reading both prior inline findings and their resolved thread state. The exact head correctly rolls back admission of __mo_fake_pk_col: that closes both the invalid DELETE-key and non-idempotent replay blockers rather than merely trusting the resolved markers. The remaining blocker is the PR contract itself: the title/body still claim that this change enables REPLACE INTO for no-PK tables and fixes #26949, while the exact code rejects those tables and the current base already contains that rejection. Please align the title, issue relationship, and body with the actual fail-closed test-only/comment change, or implement the advertised feature with a stable sink identity and request another review.
Exact head reviewed: f3f258d8ba4d921d809bb19bd73737854aa77dd1. git diff --check passed. Local exact-head targeted builder tests passed both normally and under -race. GitHub's Summary check is green, while the aggregate CI Required check currently reports the unrelated full-UT timeout/failure.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 8ec68abc02df78533b306ed8150fa876d4140e96. I reread the complete historical review/comment/thread record, compared the increment from my prior reviewed head 012421dece0181dd3daa6fed43d08ffd9e9837b8, and rechecked the full 22-file diff. The increment fixes the prior compile errors and now routes the regression through public CREATE CDC; it also keeps markers visible to a subscriber that failed before consuming them. Two blockers remain: an acknowledgement already made before a partial callback failure is discarded on retry, and the new public-path regression deterministically panics in the required race-enabled UT before reaching the no-PK rejection assertion. Details are inline.
Validation: make thirdparties; go test ./pkg/cdc ./pkg/frontend ./pkg/sql/compile ./pkg/taskservice ./pkg/pb/task -count=1 -timeout=600s passed; the new marker retry test passed under -race; a temporary partial-success/retry counterexample failed because IdChanged remained true and was removed afterward; the public integration test passed without race but go test -race ./pkg/tests/sqlintegration -run "^TestCDCNoPrimaryKeyRejected$" -count=1 -timeout=180s -v reproduced the CI panic at ddl_test.go:260; git diff --check is clean. The exact-head Ubuntu UT and aggregate CI Required checks are red on that same panic.
| s.lastMp = nil | ||
| } | ||
| s.processingCallbacks = false | ||
| s.markerAcks = nil |
There was a problem hiding this comment.
[P1] markerAcks is recreated for every fan-out and then discarded even when a callback already consumed a marker before returning an aggregate error. A production callback can successfully add the replacement reader for db.a, call ClearTableIdChanged, then fail to add db.b; on retry the existing-reader fast path skips db.a, so it does not acknowledge that marker again. If db.b now succeeds, this pass has no acknowledgement for db.a, lastMp is dropped, and s.Mp[db.a].IdChanged remains true indefinitely. A later reader recreation can therefore treat the stale marker as another truncate and DROP the NoFull target again, losing rows replicated after the first reset. I reproduced this with a temporary exact-head test whose one callback acknowledged then failed on pass 1 and returned success without re-acknowledging on pass 2: the final marker was still true. Preserve acknowledgements across failed passes (or track them per callback/source generation) and add this partial-success regression.
| require.NoError(t, err) | ||
| res.Close() | ||
| defer cleanupSQLIntegration(t, cn, "drop database if exists "+badDB) | ||
| res, err = exec.Exec(ctx, "create pitr if not exists cdc_pitr_bad for database "+badDB+" range 3 'h' internal", executor.Options{}.WithDatabase(badDB)) |
There was a problem hiding this comment.
[P1] This second PITR setup makes the newly executed public-path regression fail the required race-enabled UT before the no-PK CREATE is reached. Once the first PITR has created sys_mo_catalog_pitr, this statement takes CheckSysMoCatalogPitrResult; its uint64 read sees the actual TINYINT UNSIGNED vector and race builds panic with type mismatch: casting TINYINT UNSIGNED vector to []uint64. Exact-head Ubuntu UT fails at this line, and I reproduced it with go test -race ./pkg/tests/sqlintegration -run "^TestCDCNoPrimaryKeyRejected$" -count=1 -timeout=180s -v (the non-race run passes because the no-type-check accessor does not validate). Use a single PITR scope that covers both databases, or otherwise repair/avoid this second-PITR path, so the required job is green and the public no-PK/no-task-row assertions actually execute.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the complete current diff at exact head 6aa057a against base 57c280e. The final admission path validates user-visible primary keys, handles concrete/wildcard/account sources consistently, preserves FK-child behavior, and keeps sink-side fail-closed checks. The final TableDetector snapshot and marker-ack lifecycle retains markers across partial callback failure and clears them only after successful fan-out; the public no-PK integration path and exact-head green CI address the prior blockers. No remaining blocking lifecycle, correctness, or validation issue found.
There was a problem hiding this comment.
Deep re-review of exact head 6aa057a3d25dd9df8d871a437d66bed76d23d3ca against merge-base 57c280ed48fdccec3c2eb25042820deaf1eca3c1. I read the complete historical reviews, inline comments, author-reply state, and resolved/unresolved threads; compared the increment from my previous reviewed head 8ec68abc02df78533b306ed8150fa876d4140e96; and rechecked the full diff. The increment correctly preserves acknowledgements across a partial callback failure, and the public integration test no longer enters the second-PITR race panic. One lifecycle/resource blocker remains in that retention change: acknowledgements for obsolete source generations accumulate without a bound while any subscriber remains transiently failing. Details and a deterministic counterexample are inline.
Exact-head validation: required third-party/CGo artifacts built; full ./pkg/cdc ./pkg/frontend ./pkg/sql/compile ./pkg/taskservice ./pkg/pb/task tests passed; the focused marker retry test passed under -race; TestCDCNoPrimaryKeyRejected passed under -race; and git diff --check passed. A review-only boundedness regression produced 1,000 retained entries for 1,000 obsolete generations and was removed.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed 2999b09 against merge-base 57c280e.
The previous ownership-loss blocker is fixed: taskservice now invokes the optional non-destructive cancellation path, so an obsolete source-pattern executor stops local work without deleting a replacement generation's shared watermark. Terminal cancellation still owns catalog cleanup.
The later detector changes give each subscriber an immutable snapshot, retain generation markers until the full callback fan-out succeeds, carry acknowledgements across retries, and prune them when their table generation is no longer current. The acknowledgement set is bounded by the current published table map. Current CI and diff checks pass. No remaining lifecycle or correctness blocker found.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 326eec3f3ed4224e19debc8c5a90bb801aeaee1c against base/merge-base 6d3d588bc1d2c8aedd5302dda39c6c17eef39988: REQUEST_CHANGES.
Blocking correctness finding
The detector's acknowledgement is still global rather than consumer-specific. Retaining a truncate marker until every callback succeeds fixes the previously reported failing-subscriber retry, but also redelivers an already-consumed reset to a healthy subscriber that pauses/resumes while another callback keeps failing. The resumed pipeline can DROP its target again and then continue from its existing watermark, losing already-replicated rows. The deterministic detector counterexample and production continuation are described inline.
Historical comments
I read all 33 existing review bodies, all 39 inline comments, the 3 issue comments, and the complete 22-file diff. The earlier concrete failures concerning fake/composite PKs, both CREATE paths, wildcard/FK/system/Exclude candidate selection, N+1 queries, case-mode/Unicode/invalid-byte matching, persisted-format fencing, generated protobuf descriptors, direct metadata races, scan-publication lost updates, failed-pass acknowledgement retention, obsolete-ack boundedness, public test routing/build errors, the second-PITR race panic, and ownership-loss watermark deletion have corresponding fixes. However, the broader subscriber/reset ownership issue is not fully closed, as the new counterexample shows. GitHub currently has 37/39 threads marked resolved; the two remaining unresolved threads (4068202528 and 4068202529) concern fixes already present in code. Thread state alone was not treated as evidence.
The executor-code rebase is consistent: lossless NoFull retains code 15 and source-pattern capability uses code 16 in both producers, the generated descriptor, registration and taskservice classification. The distinct capability fence has a concrete mixed-version purpose; it is not unnecessary abstraction.
Engineering / performance follow-ups
Two non-blocking observations are inline: cloning all tenants' metadata for every callback introduces avoidable multiplicative allocations, and runtime no-PK failure points users at a watermark error that this branch never writes. Also remove the unused claimLossActiveRoutine helper at pkg/taskservice/daemon_task_test.go:56: the supersession tests now use claimLossRoutine. This is a source-level cleanup observation; I did not claim a completed full SCA result.
Evidence and limits
- Reused the same-head rebase checks: focused CDC/frontend/compiler/taskservice tests, protobuf descriptor test, focused detector race tests, and public
TestCDCNoPrimaryKeyRejectedin normal mode. - Fresh full
go test -race -p 2 -count=1 -timeout=240s ./pkg/cdcthrough the repository CGo wrapper: PASS (13.504 s test execution). - Fresh deterministic review-only test: healthy subscriber observes
[true,true]across unregister/re-register, where one-time reset requires[true,false]; the still-failing subscriber correctly observes[true,true]. This is a detector-level reproduction plus a traced production DROP/watermark continuation, not a claimed live-sink data-loss run. - Fresh normal-mode fan-out benchmark, 10 tables per tenant and one task per tenant: 100 tenants = 18,262,816 B / 141,808 allocations per pass; 200 tenants = 72,715,850 B / 563,608 allocations per pass. Timings were approximately 7.6 ms / 29.3 ms on this machine.
- Review-only files removed;
git diff --checkand worktree cleanliness pass. - Current-head full SCA, full frontend/taskservice race suites, and a live mixed-version cluster were not newly validated in this review. CI is still running; no CI wait or all-green claim.
This PR enforces the supported-source boundary; it does not add correct no-PK CDC support or resolve #26949's cross-table replication-lag incident. #26949 remains open, consistently with the PR's disclaimer.
| for marker := range s.markerAcks { | ||
| s.clearTableIdChangedLocked(marker) |
There was a problem hiding this comment.
[P1] Do not replay a consumed target reset when another subscriber keeps failing
markerAcks has no task/subscriber identity, and this condition keeps the shared IdChanged marker set whenever any callback fails. Concrete sequence: A and B subscribe to a truncated source (generation 7); A resets its target, acknowledges, and subsequently replicates/checkpoints rows; B keeps returning a transient error before consuming the marker. Pause and resume A on the same CN while B is still failing. Pause unregisters A and drains its readers, Resume retains durable progress, and startup registers A again. The next callback still gives A IdChanged=true, so its replacement pipeline reaches createMysqlSinker2's DROP TABLE IF EXISTS again. addExecPipelineForTable retains the existing watermark, so previously checkpointed rows are not replayed into the emptied target (in particular for NoFull).
A temporary deterministic test on this exact head used the real detector's processCallback -> UnRegister("healthy") -> RegisterIfAbsent("healthy") -> processCallback sequence. A observed [true,true], failing the [true,false] one-time-reset oracle; B correctly observed [true,true]. No source generation changed between passes. The existing-reader fast path avoids the second reset only while A's original reader survives.
Make completion specific to the task/source generation, or use equivalent durable reset completion, so B can retry without rearming A's destructive side effect. Cover successful consumption + checkpoint + healthy-task pause/resume while another subscriber remains failed, and preserve the current obsolete-generation bound. The earlier failed-subscriber regression alone does not prove this ownership contract.
There was a problem hiding this comment.
Addressed by the durable generation admission. The detector can still deliver an old IdChanged marker, but admission overwrites it from the durable source generation. Equal generations verify the target identity and cannot enter DROP; a changed acknowledged generation stops for explicit recovery. Thus the healthy task cannot reset its target after pause/resume while another subscriber keeps the shared marker. The source-replacement and target-replacement embedded regressions pass; xhigh review independently checked this path.
|
|
||
| for _, cb := range callbacks { | ||
| if cbErr := cb(tables); cbErr != nil { | ||
| if cbErr := cb(cloneTableSnapshot(tablesSnapshot)); cbErr != nil { |
There was a problem hiding this comment.
Non-blocking performance follow-up: scope snapshot copies to the callback's data
This clones the entire CN-wide map for every subscriber, after already cloning it once at line 735. The production callback immediately selects only allAccountTbls[accountId], and then clones each matched descriptor again. With N tenants each owning one task and T tables, this adds O(N*T) descriptor/map allocation per scan/retry even when the tenant table sets are disjoint.
A review-only normal-mode benchmark using the actual processCallback and 10 tables per tenant measured 18,262,816 B / 141,808 allocations per pass for 100 tenants and 72,715,850 B / 563,608 allocations for 200 (roughly 7.6/29.3 ms on this host). Doubling independent tenants quadruples this copying. Consider retaining callback/account identity and cloning only the relevant account/subscription snapshot while preserving isolation; a shared immutable representation is another option. This measurement is allocation evidence, not a claim of an observed production outage.
There was a problem hiding this comment.
Addressed in the current detector: tablesSnapshot[account] clones only that account's table map once, and each callback receives its own account-scoped copy. It no longer clones the CN-wide table map for every subscriber; the prior allocation probe in the PR description measured the resulting reduction.
| exec.stopRemovedReader(key, key, reader) | ||
| } | ||
| } | ||
| return exec.failTaskForPermanentTableError(ctx, newTableInfo) |
There was a problem hiding this comment.
Non-blocking operational follow-up: preserve the actual no-PK failure reason
For a newly discovered keyless table, this returns before pipeline construction or UpdateWatermarkErrMsg. failTaskForPermanentTableError persists only the generic message directing users to mo_catalog.mo_cdc_watermark.err_msg; the new table has no watermark row, and an existing table that loses its PK can still have an empty error there. The task correctly fails closed, but the persisted diagnostic does not say that the source lacks a user primary key and points to absent details. Pass/persist the concrete cause at task level (or write a correctly fenced table diagnostic), with an assertion for the future-table/PK-loss error text.
There was a problem hiding this comment.
Addressed. The no-PK path calls failTaskForPermanentTableError with the concrete source table has no user primary key cause, which is written into the task diagnostic even when the newly discovered table has no watermark row. The wildcard no-PK regression covers this path.
|
Updated PR #28521 after the rev5 design approval and a clean rebase onto The blocking repeated-DROP case is now addressed with a durable per-task source-generation acknowledgement. The detector marker only schedules work; an acknowledged target is verified under its target lock and preserved across retries/takeover. Replacement replay uses a fixed epoch and ignores the retired generation's watermark. Ambiguous legacy progress fails closed. Local evidence includes the full CDC/frontend normal and race suites, compiler/disttae tests, targeted vet and golangci-lint, plus real embedded MatrixOne tests for target collation and source-table replacement. In the replacement test, an old watermark is durably forced beyond the new snapshot epoch before resume; the final target contains only the new rows and the new durable generation/watermark is below the injected value. The scanner allocation probe measured 19.7 MB to 0.43 MB per 100-tenant pass. The separate finite-EndTs wildcard diagnostic is tracked in #29382. #26949's broader cross-table replication-lag behavior remains open. |
|
Included #29382 in this PR at The real wildcard/finite-EndTs test exposed a stronger cause than the initial issue report: Local evidence: real single-CN test passes for both a historically present table (row replayed) and a later table (diagnostic; no target or epoch); focused initial-full/NoFull/explicit-start tests pass; full |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of c73a2eb485cb304e1b96fa12a795fd60eef1d1a2
Request changes: two correctness issues reproduced against real MO, plus two concrete unhappy-path/performance defects. An independent gpt-6-sol / xhigh review participated; findings were checked against the complete caller paths and approved rev5 contract.
Findings
- P1 — A replacement target is accepted as the acknowledged table. A public-SQL CDC task replicated rows 1 and 2 and persisted a nonzero watermark. After PAUSE, DROP/CREATE of the target with the identical schema, insertion of source row 3, and RESUME, CDC replicated row 3 but never restored rows 1 and 2. Result: source count 3, target count 1. The acknowledged source generation and matching structure do not identify the target incarnation.
- P1 — Fresh, valid MO targets fail type verification. Real MO tables with
YEAR,FLOAT(5,2), andDOUBLE(6,5)reportYEAR(4),FLOAT(5), andDOUBLE(6)respectively throughinformation_schema.columns.column_type. All three failed the production verifier with “column 2 differs” against their identical source definitions. Admission invokes this verifier before acknowledging the generation. - P2 — Initial full admission can retain unbounded old epochs. Until its first target ACK, durable generation remains zero. If the source table is recreated after an interrupted target initialization, each new table ID gets an epoch, while lower-generation deletion is skipped because
resetTargetdepends only ongeneration>0. A successful later ACK still leaves all earlier epochs. Repeated source recreation and interrupted admission grow catalog state without a bound. The same case with a changed source schema can leave an unacknowledged prior target table in place and permanently fail target verification. - P2 — Mode-2 admission scans all task watermarks once per table. Restarting an N-table task performs N full-result queries and scans N² rows. Completed historical replacement tables also repeat this on detector scans because the completion cache is checked after the query. This is a code-derived bound; I have not measured production latency.
See the inline comments for the exact paths and repair boundaries.
Previous comments
Read all 42 previous inline comments and 5 issue-level comments, including resolved/outdated threads. The original concerns have corresponding changes:
| Previous concern | Current handling |
|---|---|
| Fake/no primary key, hidden composite key, wildcard/FK/system-table selection | Shared candidate SQL returns PK status; both creation paths and runtime reject eligible keyless sources. |
| Exclude ordering/escaping, case mode 2, Unicode and malformed identifier bytes | Raw Exclude is retained; catalog results are filtered using the persisted identifier policy; byte encoding survives metadata serialization. |
| N+1 primary-key queries | PK status comes from the candidate query. The new all-watermark query in finding 4 is a separate regression. |
| Shared callback mutation, consumed-marker resurrection, partial-success ACK loss, ACK growth | Independent account snapshots, locked publication/reconciliation, retained failed-pass ACKs, and obsolete-generation pruning. |
| A succeeds / B fails / A resumes and DROP repeats | Destructive initialization now consults the durable per-task source generation instead of the shared marker. This addresses the original path; it does not establish target incarnation identity (finding 1). |
| Full-CN copies for each subscriber | Copies are restricted to the subscriber account. |
| Keyless-table diagnostic points to an absent watermark row | The task-level error now includes the concrete no-primary-key cause. |
| Broken fixtures, public frontend route, second PITR race panic, stale protobuf descriptor | Corrected fixtures/public route, one account PITR, regenerated descriptor; the descriptor test passed in this review. |
GitHub still has 5 unresolved threads: partial-success ACK, second PITR, repeated DROP, fan-out copying, and diagnostics. Code changes and thread resolution are different statuses; this review does not claim the PR is fully closed.
Unhappy-path and engineering audit
| Resource/state | Cleanup and waiting | Bound / conclusion |
|---|---|---|
| Target session, lock, metadata rows | Sinker initialization closes on failure; historical verification defers executor close; query rows close before the next query; target waits support cancellation. | Target identity proof is missing, despite lock/fence protection. |
| Historical transactions | Pinned snapshot is checked; rollback has a cleanup timeout. | No new leak/hang found in the reviewed path. |
| Reader replacement and checkpoint ownership | Old reader is drained; target DDL precedes fenced generation ACK; reader publication follows ACK. | These ordering changes are useful; structural equivalence is insufficient for external replacement. |
| Detector snapshots, marker ACKs, epoch state | Account-scoped copies; obsolete ACK pruning; lower epochs removed before replacement admission. | Generation-zero interrupted admissions leave obsolete epochs; mode-2 query work is quadratic. |
Excluding generated code/docs, this PR adds a net 1,470 production lines and 1,791 test lines. The real source-replacement and EndTs tests add useful evidence, but the type-domain tests missed ordinary supported types. Also, classifyStableSnapshotRestart and shouldCompactStableSnapshotEpochs now have only test callers. Removing obsolete logic and moving its useful assertions onto the live admission path would improve the test signal.
Validation and limits
- Fresh review-only embedded test
TestReviewCDCIdenticalTargetReplacement: reproduced silent 3-versus-1 divergence through public CREATE/PAUSE/RESUME SQL. - Fresh review-only embedded test
TestReviewCDCTargetTypesOnMO: all three identical-target cases rejected using real MO metadata and the production verifier. TestTaskDescriptorIncludesCDCProtocolCodes: PASS with the repository CGo wrapper.- Reused existing relevant evidence: full
pkg/cdcandpkg/frontendrace suites PASS; SCA on cdc/frontend/compile/disttae/embed reports 0 issues; the real EndTs late-table regression PASS. These results do not cover the newly reproduced failures. - Review covered all 34 changed files and related ownership/caller paths. No fresh cross-process takeover or MySQL-server run was performed in this review. Temporary reproducers were removed from the worktree and retained with local evidence.
| // A durable generation acknowledgement owns target state. A detector hint | ||
| // must not drop a target that already belongs to this generation. | ||
| if dbTblInfo.targetReady { | ||
| if err = verifyCDCTargetTable(ctx, executor, dbTblInfo, tableDef, sinkUri.SinkTyp); err != nil { |
There was a problem hiding this comment.
[P1] Bind the acknowledged target to its incarnation before resuming
generation == sourceTableID sets targetReady, but this check only compares the table's current columns/indexes. It cannot distinguish the acknowledged table from an empty replacement with the same schema. I reproduced this through public SQL on the exact head: replicate rows 1 and 2 and persist W>0; PAUSE; DROP the target and CREATE it with identical columns/PK; insert source row 3; RESUME. Row 3 replicates, but the final counts are source=3 and target=1 because the reader keeps W. Rev5 invariant 1 explicitly promises failure when the CDC-owned target was externally removed (only external row mutation is excluded). The advisory lock does not identify a replacement created during pause. Bind validation to durable target-incarnation evidence, or explicitly revise the supported recovery contract/runbook to require rebuilding this case; matching structure must not be presented as proof that the acknowledged target survived. Cover this with final rows/checkpoints, not only schema-mismatch mocks.
There was a problem hiding this comment.
Addressed in rev7. A durable target_identity is recorded at first ACK and checked inside the target transaction before the next write or resumed pipeline. The real MO and MySQL 8 same-schema DROP/CREATE regressions stop the task and preserve the replacement target rows.
| break | ||
| } | ||
| if columnCount >= len(visible) || name != visible[columnCount].GetOriginCaseName() || | ||
| !cdcTargetColumnTypeMatches(visible[columnCount].Typ, typ, sinkType) { |
There was a problem hiding this comment.
[P1] Compare MO type metadata without rejecting identical valid targets
The new mandatory verifier rejects ordinary targets created from the source definition. On a real MO target I tested (id INT PRIMARY KEY, v YEAR), v FLOAT(5,2), and v DOUBLE(6,5): information_schema.columns.column_type returns YEAR(4), FLOAT(5), and DOUBLE(6), while FormatColType produces YEAR, FLOAT(5,2), and DOUBLE(6,5). All three calls to the production verifier fail with column 2 differs. createMysqlSinker2 now calls this after CREATE and before generation ACK, so valid tables cannot start replication or resume. Normalize genuine display-only differences and compare authoritative precision/scale metadata where COLUMN_TYPE omits information; simply ignoring scale would admit incompatible targets. Add real-metadata coverage for supported type families.
There was a problem hiding this comment.
Addressed. Target type comparison now normalizes metadata representations that describe the same valid source/target type (including omitted float scale). Focused verifier tests and real embedded target metadata regression pass.
| } | ||
| readCtx := defines.AttachAccountId(ctx, catalog.System_Account) | ||
| res := exec.ie.Query(readCtx, | ||
| cdc.CDCSQLBuilder.GetTaskWatermarksSQL(key.AccountId, key.TaskId), ie.SessionOverrideOptions{}) |
There was a problem hiding this comment.
[P2] Load mode-2 watermark keys once per admission batch
Every addExecPipelineForTable calls this query, which returns every watermark row for the task, and the following loop scans the full result. A mode-2 database/account task with N tables therefore performs N full-task queries and scans N² rows on restart/takeover. There is also recurring work: after a finite-EndTs source replacement is classified complete, no reader is installed, and completedHistoricalTargets is checked only after this function, so subsequent detector scans repeat the full query for each such table. With 1,000 completed tables this is 1,000 queries / about 1 million result rows per scan (a structural bound, not a latency measurement). Fetch/index the keys once for the callback/admission batch while preserving the exact CDCSourceIdentifierKey semantics; make the completed fast path avoid repeating this work.
There was a problem hiding this comment.
Addressed. Mode-2 watermark keys are loaded into one cdcSourceKeyIndex per detector admission batch and reused for each matched table; the uncertain key is added conservatively after a catalog effect.
| return state, nil | ||
| } | ||
| } | ||
| if state.resetTarget { |
There was a problem hiding this comment.
[P2] Cleanup must also cover source replacement before the first target ACK
For a new full task, source_table_id stays 0 until target initialization is acknowledged. If an interrupted initialization for source ID g1 has already inserted its fixed epoch, and the source is DROP/CREATEd as g2 before ACK, resetTarget=(generation>0) remains false, so this block does not delete g1's epoch. The epoch helper accepts an older other generation and inserts g2. Repeat for g3...gN: N retained epoch rows, including after gN finally ACKs. A retry budget is no bound because pause/restart can interrupt admission before an error is recorded and can be repeated. This contradicts rev5's explicit one-epoch-per-table bound and repeated-replacement/failed-DDL requirement. If g1 CREATE reached the target and g2 has different columns, resetTarget=false also prevents a safe reset and g2's verification fails on the unacknowledged g1 table. Delete only epochs below the current source ID before inserting E when an older epoch exists, even if acknowledged generation is 0; classify that proven pre-ACK source replacement for target reset without changing same-generation retries.
There was a problem hiding this comment.
Addressed in rev7. First admission durably records pending_source_table_id and the target pre-identity before target effects. The source catalog transaction pins the exact table ID through the synchronous first target ACK; a restarted admission requires the same pending source generation and target identity, otherwise it stops for explicit recovery. The two-CN first-ACK test held the lock while another CN's DROP timed out.
fengttt
left a comment
There was a problem hiding this comment.
These kind of work need serious tests. What is the test strategy, means, you need to create test cases, serious ones, that repro in the old code and fixed in new code. Coverage.
So we don't have bvt tests? Was all covered by embed? Concurrency tests and fail/recovery tests?
This maybe a question on overall CDC test strategy.
|
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 560698f (merge-base 0782faf). I read the historical reviews/inline threads and author replies, compared the CDC changes since my previous reviewed head 326eec3, and traced the new generation/target-identity admission through both CREATE paths, sink ACK, and restart. REQUEST_CHANGES for a concrete producer/consumer mismatch and red exact-head tests.
[P1] pkg/sql/compile/ddl.go:7125 still writes GenerationProtocol=CDCGenerationAwareProtocolV1 for an internal/EXEC_IN_ENGINE CREATE CDC task, whereas pkg/frontend/cdc_exector.go:3846-3856 now accepts only CDCGenerationAwareProtocolV2. The compiler path also runs the older stable-snapshot capability check instead of the new v97 target-identity/column gate used by frontend CREATE. Reproducer: CREATE CDC ... {'Level'='database','NoFull'='true'} internal succeeds and persists the task, then the daemon immediately enters Failed with CDC task has no durable target identity; recreate it with a clean target to resume safely; no table reader is registered and post-CREATE source rows never reach the target. This is visible in the exact-head coverage job's TestCDCNoFullPublicLifecycle log and follows directly from the two constants. Make both task producers emit the same supported V2 protocol and enforce the same v97/catalog-capability gate before persistence; add an executed compiler-path regression that asserts the task actually starts and replicates.
[P1 validation gate] pkg/frontend/cdc_test.go:718 (and :1647/:4474) still has fixtures for the old startup behavior. At this exact head, the new column probe in cdc_dao.go:147-160 is not expected by Test_handleCreateCdc, and the startup fixtures lack V2, so the three focused frontend tests fail. I reproduced these exact failures locally after make thirdparties with CGO enabled; the current exact-head coverage job also lists them and is red. Update the mocks to exercise the supported protocol/capability path and make the owning tests pass. The same coverage run has other CDC/embedded failures, which need triage rather than being counted as green evidence.
The earlier shared-detector repeated-DROP issue is addressed in direction by deriving reset from durable per-task generation, and the new target ID check is materially stronger than schema-only verification; those observations do not close the two blockers above.
aptend
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES — deep re-review at exact head 5dd1e29 (base 0782faf). I read the historical reviews, all inline/issue comments and author replies, and resolved/unresolved thread state; compared the two-commit increment after my previous head 560698f against the 48-file change map and the generation/target-identity lifecycle.
The previous compiler V1/V2 mismatch is corrected in source: pkg/sql/compile/ddl.go now emits generation-aware-v2 and probes v97/catalog capability before task persistence. That is meaningful progress, but the new head still fails required exact-head validation:
-
[P1 validation] pkg/sql/compile/cdc_options_test.go:72-88 —
TestValidateCDCTargetIdentityCatalog/row_iteration_errorconfiguressqlmock.NewRows(columns).RowError(0, ...)without adding row 0. The productionLIMIT 0probe iterates no row;rows.Err()is nil, so the test asserts an error that cannot occur with this fixture.go test ./pkg/sql/compile -run TestValidateCDCTargetIdentityCatalog -count=1fails at line 88 (An error is expected but got nil), also listed in this head's failed UT Coverage report. Supply an actual row if testing the defensive iteration-error path, or remove/correct that case; make the owning package and coverage producer pass. -
[P1 validation] pkg/frontend/cdc_test.go:718,1051-1054,1647 — the new catalog-column probe
SELECT pending_source_table_id, target_identity FROM mo_catalog.mo_cdc_watermark LIMIT 0is absent from the mock expectations for both frontend CREATE and executor startup. On this exact head, focusedTest_handleCreateCdc/t1returnsnot supported: CDC target identity catalog columns are not available;TestRegisterCdcExecutor/t1panics fromtestIE.Querywhen the same unexpected query arrives. The V2 option added to the latter fixture does not cover its next mandatory probe. Update both fixtures to exercise the supported capability path and verify their task behavior; these failures also occur in the exact-head UT Coverage job.
Validation: make thirdparties completed, CGo-enabled focused tests reproduced both failures (the selected CDC package tests passed), and git diff --check passed. The same coverage report lists additional embedded-cluster admission and upgrade failures; their attribution still needs triage. I am not treating the red coverage producer as a green gate or claiming those additional failures were caused by this diff. Earlier CDC source/target-generation objections have corresponding code changes, but passing design intent does not close these executable regressions.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head dc5391345cd91ef927a3472cf9cc0eb979d8e993 (base/merge-base 0782fafc3efd01eca0d78fa3701d74eb5b7b0eaa). I checked all historical reviews, inline comments/replies and all 46 thread states (37 resolved, 9 unresolved; no new thread reply since my previous review), compared the one-commit delta from 5dd1e29ff3c489bf6f02d15ea71633c8e2793a10, and rechecked the full CDC generation/target-identity closures. The compiler V2 mismatch and two prior fixture failures are repaired in direction; the latter still has a new exact-head failure.
-
[P1]
pkg/embed/cdc_target_generation_verification_test.go:650-654/pkg/frontend/txn.go:705-728— optimistic CREATE remains outside the CDC catalog guard. On the optimistic/SI configuration used by this new public test,BEGIN; CREATE TABLE cdc_optimistic_probe.rejected (id INT PRIMARY KEY)succeeds; the test expects rejection and fails at line 653 with “An error is expected but got nil.”requiresPessimisticObjectLifecycleTxnandrequiresPessimisticLifecycleModeTxnomit persistentCreateTable;isImplicitCommitStatementalso excludes it. The CREATE path callslockMoDatabase/lockMoTable, butlockop.LockRowsreturns immediately for an optimistic transaction. Thus an optimistic CREATE can change an absent name-to-ID mapping without waiting for the source/target catalog guard held during first CDC acknowledgement, contradicting rev7's required DDL exclusion/capability contract. Route persistent CREATE through the pessimistic-RC admission gate (or reject an already-active optimistic transaction), and make this real two-CN test pass. Do not just weaken its assertion. -
[P1 validation]
pkg/frontend/cdc_test.go:1538-1539— the new zero-row probe mock still panics inTestRegisterCdcExecutor/t1. The added expectation returns zero rows, but this test'stestIE.Queryunconditionally panics “must have data” whenrows.Next()is false (cdc_test.go:1053-1130).mo-cgo-test -count=1 -run '^(TestValidateCDCTargetIdentityCatalog|Test_handleCreateCdc|TestRegisterCdcExecutor)$' ... ./pkg/frontend ./pkg/sql/compilereproduced the panic on this clean head; the exact-head Coverage UT producer reports it too. A review-only temporary handler for this particular empty capability probe makesTestRegisterCdcExecutorpass; I removed it afterward. Model the probe as an empty successful result without breaking the existing row-bearing fixture, then keep the test green. -
[P1 validation]
pkg/embed/cdc_target_generation_verification_test.go:38,114,212,314,520— the new single-CN and two-CN tests overlap incompatible shared fixtures. The first test startsRunSingleCNBaseClusterTests, which retains its process-wide lease. The next two-CN test callsRunBaseClusterTestswithout closing the one-CN fixture; another one-CN test runs before the second two-CN case. In the exact-head Coverage UT job, bothTestCDCTenantCatalogGuardBlocksOtherCNDropandTestCDCFirstAckHoldsSourceGenerationAcrossCNfail at setup with “another complete test cluster is already active in this process,” so neither required cross-CN guard regression runs. Separate/close topology generations before switching (with cleanup even on failure), and verify normal package-order execution rather than only isolated runs. -
[P1 validation]
pkg/tests/upgrade/upgrade_v4_0_8_statistics_test.go:243,274— the new 4.0.9 handler invalidates the login-compensation oracle. This PR registersv4_0_9.Handleras the final upgrade, while this test still setsfinal := v4_0_8.Handler.Metadata()and expects the compensated tenant'screate_versionto equal 4.0.8. The exact-head Coverage UT reports actual 4.0.9 versus expected 4.0.8. Update the oracle to the appropriate current final version while retaining the 4.0.8-specific migration assertions.
Evidence: make thirdparties and make cgo completed in an isolated worktree; the separate Test_handleCreateCdc and TestValidateCDCTargetIdentityCatalog passes, and git diff --check is clean. The exact-head Coverage UT job failed; other failing packages exist, but I do not attribute them to this PR without further proof. Review-only changes and downloaded diagnostics have been removed.
aptend
left a comment
There was a problem hiding this comment.
Reviewed exact head 92fe921, including the full CDC generation and target-identity path, the changes since the last review, prior threads and author replies, and exact-head CI. The source/target guard direction is substantially improved, but this head is not mergeable yet:
-
pkg/bootstrap/versions/v4_0_9/cluster_upgrade_list.go:39-40 adds two CDC watermark upgrades, while pkg/bootstrap/versions/v4_0_9/upgrade_test.go:32 still asserts that clusterUpgEntries has exactly one item. Any run of TestSnapshotQuotaIndexUpgrade now fails deterministically (CI reports 3 entries versus 1), so the versioned upgrade package and the coverage UT job are red. Update the test contract for all three entries and verify their protocol gates and SQL.
-
pkg/frontend/cdc_test.go:4412-4424 and 4488-4490: the retrieveCdcTask fixture only sets the stable-epoch option, but retrieveCdcTask now requires CDCGenerationAwareProtocolV2 before its capability query. The recently added zero-row probe expectation cannot be reached: TestCdcTask_retrieveCdcTask/t1 fails with the durable-target-identity NotSupported error and then fails its stableInitialSnapshot assertion in exact-head CI. Give the fixture a valid v2 task config, and add a separate expected-rejection case for legacy tasks so both branches are tested.
-
The same exact-head coverage run also fails TestRestartTimeoutWinsInFlightCatalogPublication and two new embedded CDC generation tests (TestCDCGenerationReplacementOnMO and TestCDCFirstAckHoldsSourceGenerationAcrossCN). Please diagnose and provide passing results for these lifecycle paths; the test names alone do not establish whether each is an implementation fault or a fixture issue.
The failed run is https://github.com/matrixorigin/matrixone/actions/runs/36510545244 . I will re-review the fixes against a new exact head.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 85ce9b5. I read the historical reviews, inline comments/replies and resolved/unresolved threads, checked the changes since the last aptend review and the full CDC admission/target guard/upgrade path. The previous fixture failures are repaired: focused bootstrap/frontend/compile/CDC tests passed, and the two exact-head embedded generation/first-ACK tests passed locally. Two independent upgrade blockers remain:
[P1] New watermark columns are added to an already-completed version. pkg/bootstrap/versions/v4_0_9/cluster_upgrade_list.go:39-40 adds pending_source_table_id and target_identity only to the 4.0.9 handler. But this PR's own base already registers 4.0.10 as final (pkg/bootstrap/upgrade.go:69), and CheckAndUpgradeCluster returns when the persisted final version/offset is ready (pkg/bootstrap/service_upgrade.go:194-197); it never replays an older 4.0.9 handler. Repro: start from a current-main cluster whose mo_version is ready at 4.0.10 and whose watermark table has the old columns, then deploy this head. No ADD COLUMN runs; every new CREATE CDC reaches the column probe in pkg/frontend/cdc_dao.go:147-151 and fails CDC target identity catalog columns are not available. Existing clusters cannot create new CDC tasks. Put these additions in a new reachable upgrade step after the already-published final version and test upgrade from an actual base/current-main 4.0.10 catalog, not only the 4.0.9 handler in isolation.
[P1] The V2 task capability is falsely fenced by MORPC v97. pkg/frontend/cdc_options.go:301-305 and pkg/sql/compile/ddl.go:7177-7181 accept v97 as proof of target-identity-aware executors; cluster_upgrade_list.go:49 uses the same floor. Yet this exact base/main already assigns v97 to decimal-division semantics and advertises v100 without V2 CDC. For a concrete (non-pattern) source, BuildTaskMetadata emits existing InitCdc/InitCdcStableEpoch/InitCdcLosslessStart codes (cdc_options.go:338-346), all registered by the old CN. Repro: after the columns exist, create a V2 task on this head while a base v100 CN remains; the new frontend passes 100>=97, then the old task runner can claim the existing task code. Its retrieveCdcTask has no GenerationProtocol V2 check, so it executes the old target path without the persisted identity fence; a same-schema target replacement or stale detector marker can again go undetected or reset data. The exact CommitID query-worker filter does not protect daemon-task scheduling. Use a genuinely new cumulative capability and an executor/task-code admission fence (or an enforced all-old-CN drain) before V2 task persistence; include a mixed old/new daemon-claim counterexample.
No additional confirmed lifecycle blocker is claimed. git diff --check passed. Current-head required CI was still running at review time; the local focused and embedded passes above do not represent a CI pass.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head aad7757 (base 0870004). I rechecked the historical reviews, inline replies/thread states, the two-commit increment since my prior review at 85ce9b5, and the full CDC target-generation/upgrade path. The two previous blockers are fixed in direction: the watermark columns now have a reachable 4.0.11 cluster upgrade after published 4.0.10, and every new V2 task uses code 16, which old CNs cannot claim. The mixed-runner taskservice test passes. A review-only 4.0.10-ready upgrade case also passed and was removed.
[P1 validation] pkg/bootstrap/service_statistics_upgrade_test.go:59-64,104-123 — the new final version is 4.0.11, but the expected hop list still omits 4.0.10 for every starting version <= 4.0.9. Because 4.0.11 has MinUpgradeVersion 4.0.10, doCheckUpgrade correctly queues 4.0.9 -> 4.0.10 (tenant) -> 4.0.11 (cluster); the test expects an invalid direct 4.0.9 -> 4.0.11 step. Reproducer on this exact, unmodified head: go test ./pkg/bootstrap -run 'TestDoCheckUpgradeQueuesStatisticsRefresh/current_4.0.9$' -count=1 fails at line 123 (one expected upgrade row vs two actual rows). The other older-version rows fail for the same missing hop, so the owning bootstrap package/UT gate is red even though the production upgrade chain is right. Update the test's expected hop construction to include 4.0.10 when appropriate, and retain an explicit 4.0.10-ready case so the original migration regression stays covered.
Focused frontend/compile/CDC and v4_0_11 tests passed; TestStableEpochCDCTaskRejectsLegacyRunnerBeforeClaim passed. git diff --check is clean. Current-head CI is still running, so I do not claim a green CI gate.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 190088b (base/merge-base 0870004), compared with my prior reviewed head aad7757. I checked the historical reviews, inline/issue replies and thread state, the three-commit test-only increment, and the earlier full CDC upgrade/generation closures. The previous doCheckUpgrade hop mismatch is fixed: focused bootstrap and cnservice tests pass. The reachable 4.0.11 catalog migration and new-code-16 mixed-CN executor fence remain intact; no production lifecycle path changed in this increment.
[P1 validation] pkg/tests/upgrade/upgrade_v4_0_8_statistics_test.go:244,275 still pins final := v4_0_10.Handler.Metadata() and expects a compensated tenant's create_version to be 4.0.10, although this PR now registers 4.0.11 as the final version. Reproducer on this exact unmodified head: mo-cgo-test -count=1 -run '^TestV408LoginRepairsTenantCreatedAfterUpgradeSnapshot$' ./pkg/tests/upgrade fails at line 275 with expected 4.0.10, actual 4.0.11. The exact-head Coverage UT job also fails solely this upgrade-package test, so the required validation gate is red. In an isolated review-only worktree, changing that fixture's final metadata to v4_0_11 makes the same embedded login/compensation test pass; that temporary edit was removed. Update the committed oracle to the actual final version while retaining the v4.0.8-specific recovery assertions. Please also add the explicit 4.0.10-ready starting case requested in the previous review, so the originally missed published-version migration remains guarded.
The previous head's full CDC lifecycle evidence remains semantically valid because these three commits change only tests; git diff --check is clean. Current-head remaining CI jobs are still pending, and no green CI claim is made.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 78ed4f1 (base/merge-base 76862df), compared with my previous reviewed head 190088b. I revisited the historical reviews, inline/issue comments and author replies, all 46 resolved/unresolved thread states, the merge increment, and the full 58-file CDC source/target-generation and upgrade change map. No remaining blocking finding.
The last blocker is closed by executed evidence: TestV408LoginRepairsTenantCreatedAfterUpgradeSnapshot now uses the actual final v4_0_11 metadata and passes unmodified at this head. The explicit current_4.0.10 starting case has also been added to TestDoCheckUpgradeQueuesStatisticsRefresh and passes. Focused v4_0_11 metadata and TestStableEpochCDCTaskRejectsLegacyRunnerBeforeClaim tests pass as well. These were run with the repository CGo wrapper in an isolated detached worktree, reusing provenance-checked, platform-matched native artifacts. No production edits or temporary counterexample changes were retained.
The earlier production closures remain intact: the new columns have a reachable 4.0.11 migration after published 4.0.10; creation and migration gates now consistently use the genuinely new v102 capability after main consumed v101; every V2 task still uses executor code 16, excluded from old runners before claiming. Durable per-task generation, pending admission/pre-identity, guarded first ACK, and target-incarnation checks prevent a stale shared detector marker or same-schema target replacement from silently continuing/resetting an acknowledged target. Source replacement needing destructive recovery fails closed; finite-EndTs completion retains its historical visibility/progress proof. I also checked the merged lifecycle/DDL paths and retained ownership, cancellation and resource bounds. An unresolved UI thread is not counted as a defect when its original counterexample is closed in the implementation and executable evidence.
Current-head CI evidence: SCA and UT Coverage passed. I checked the coverage incident artifact: producer exit 0, 490 packages discovered, and no package/test failure event. Its progress includes the real embedded CDC generation/target guard/first-ACK tests and public CDC SQL lifecycle paths. This closes the earlier red owning-test gate; git diff --check is clean. The ordinary Ubuntu UT and the two enabled multi-CN BVT jobs are still running at submission, so this approval does not claim that all required CI checks have passed. The opt-in external MySQL 8 BVT was not rerun locally in this review; its target implementation is unchanged from the previous reviewed head.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 83154c49e4f1db4b81eeb164cfb75a94709ef7a9 (merge-base 1a2e591d95489fdb51fe2b0c5c0bf012201c7c1e; current main fdf96ba0be2a40fb2726800fa3c32a8567118ca0). Single-agent review; production source unchanged.
REQUEST_CHANGES: two confirmed blockers are attached inline. The durable source/target tuple and removal of detector markers are sound, but retry policy is still split between admission and runtime. Preserving the cause is insufficient when the admission consumer recognizes fewer transient classes; the previous PASS missed this boundary. The latest SCA also fails the repository error-construction gate, despite the narrower local golangci run passing.
QA evidence: extending the existing SQL-boundary test with MySQL1159/1161 and MO RPC-timeout/service-unavailable gives12 failing cases across3query boundaries; adding2native MO transport cases to the existing source-guard test also fails. Existing retry/permission/cancel controls pass. Tests were supplied through external Go overlays, with no tracked edits. Final catalog persistence-to-task-failure was source-traced, not newly injected in a live cluster. The existing public no-PK SQL test passes with -race at this head (14.229s).
I reconciled all46 historical threads and reused the unchanged58-file change map and valid owning-package/race/embedded/restart/upgrade evidence. The9old unresolved GitHub threads are outdated and substantively addressed; their UI state is separate from these2new blockers. Full PR net increments remain implementation+2329,tests+2373,docs+94,generated+4; this repair alone removed269implementation and398test lines. Accepted rev7 guard costs remain: no new production-throughput claim. UT/coverage CI were still running at the final snapshot; local75.33% is not a remoteCI-pass claim.
| if cdcTargetSQLRetryClassifier.IsRetryable(err) { | ||
| return newRetryableConnectionError(err) | ||
| } | ||
| return err |
There was a problem hiding this comment.
[P1] Classify transport failures before the admission retry decision
This classifier marks only the two MO transaction-retry codes plus the shared MySQL allowlist. MySQL1159/1161 and MO ErrRPCTimeout/ErrServiceUnavailable therefore return unmarked. A live first/resumed admission encountering one of these errors in the new mandatory identity query reaches cdc_exector.go:3148, where none of the four retry wrappers matches. UpdateWatermarkErrMsg persists non-retryable N: metadata, and the next GetTableErrMsg/ShouldRetry fails the whole task permanently. TableChangeStream.determineRetryable has a timeout/unavailable fallback, but admission never calls it; the new runtime-only fallback tests do not close this path.
Executed on this exact head: expanding TestCDCTargetIdentityRetryContract with these4codes fails12query-boundary cases while its existing controls pass. withCDCSourceGenerationGuard has the same omission:2native MO transport cases fail its retry contract. MO's SQL protocol preserves the internal20500/20506codes for these errors. Reuse a coherent transient classification at both guard boundaries and admission/runtime consumers, with a persisted-error oracle; keep permission/unsupported/cancel controls and avoid a blanket retry of all errors. MySQL1159/1161 are documented communication timeouts: https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html
| rows, err := conn.QueryContext(ctx, | ||
| "SELECT TABLE_ID FROM information_schema.INNODB_TABLES WHERE NAME = ?", "__mo_cdc_capability_probe__/__absent__") | ||
| if err != nil { | ||
| return fmt.Errorf("CDC target InnoDB table identity is unavailable (PROCESS privilege required): %w", err) |
There was a problem hiding this comment.
[P1] Remove forbidden production fmt.Errorf calls without dropping their causes
The repository's Makefile err-check rejects production fmt.Errorf, and static-check-analysis requires that gate. This change adds6calls (this file75/159; source_guard89/94/98/102). The exact-head Linux/arm64 SCA has now failed at Makefile1546 with Use moerr instead; local make err-check reproduces it. The other timeout/deadline lines are accompanying diagnostics, not the triggering condition. The focused golangci run does not execute this gate.
Return the original typed error where appropriate, or use a repository-compliant cause-preserving mechanism. Do not restore the old %v cause erasure or suppress the check. Validate through the actual repository SCA entrypoint.
Consolidate the reviewed PR matrixorigin#28521 implementation before rebasing. Original reviewed head: 9752186
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 62123ee436ec3267fd20871bc918474bb804aef7 against fdf96ba0be2a40fb2726800fa3c32a8567118ca0. Root-only review, no subagents or production edits.
APPROVE: no unresolved material findings. I reconciled the complete60-file change map, approved rev7 design, and all48 review threads (46historical plus the2last blockers). The shared typed classifier now governs admission, source/target guards, durable error publication and runtime; unknown runtime fallback remains separate by explicit contract. The original backend causes survive, owner/context gates still precede durable writes, and the complete SCA violations—including the orphan fixture—are removed. Eleven thread UI entries remain unresolved (10outdated); this is separate from their substantive code disposition.
Independent QA on this head:6new database/sql result-stream fault cases cover first-row, trailing-row and close failures with transient and permission controls. No target identity escapes any failure, causes/classification survive, and rollback expectations pass. I also extended the real source-guard -> owned watermark UPDATE -> actual GetTableErrMsg test: cancellation does not replace metadata or consume retry budget; the next callback is blocked exactly after MaxRetryCount is exceeded. All cases pass (CDC2.598s,frontend1.090s) using external Go overlays, with source unchanged.
Reused semantically valid exact-head evidence: owning suites, focused race, six embedded MO cases, public no-PK/NoFull restart SQL tests, full repository SCA and75.64% local changed-block coverage. Remote SCA, Coverage and the enabled BVT jobs are also SUCCESS; only the Ubuntu UT job remains in progress at the final snapshot and is not claimed passed by this review.
Design/cost: the detector publishes immutable discovery; the durable source/target/epoch/owner tuple owns recovery; guards cover first ACK and target writes. No duplicate admission state machine is added. The error-policy correction adds no successful-path SQL or background state. The full PR intentionally retains per-target-transaction guard I/O; the historical~298us local measurement is not a production throughput guarantee. Previously approved first-CREATE/ACK and asynchronous-checkpoint boundaries remain documented tradeoffs. Full PR increments were assessed separately: implementation+2305,tests+2388,docs+94,generated+4; test volume was not used as proof of correctness.
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
CDC must not apply an old source's progress to a replacement source or write into a replacement target merely because the names and schema match. It also must not permanently fail a task when an identity query encounters a retryable connection or transaction error.
fdf96ba0be2a; CDC catalog/task admission uses protocol 106 without overwriting main's protocol allocations. The new 4.0.11 handler owns CDC columns; unrelated 4.0.9 metadata is restored.Approved design:
docs/design/20260925-cdc-target-identity-rev7.md, SHA-256c13b04d4e5a02cc55498561ab8da58faa580954be1859ba6bc8f0b4b10871908. This repair's design and code review used gpt-6-astra / xhigh.Validation
Current correction and rebase:
GetTableErrMsgreload proves transient errors allow the next callback while unsupported/unknown errors block it. The fixture uses one catalog key and no live cluster. Historical EndTs read failure preserves its cause before target effects.make static-check-analysispassed:err-check, molint and full-graph golangci-lint (0 issues). Removed the unreferenced sinker fixture identified by the complete check; frontend full suite passed again.Reused unchanged-path evidence from the prior repair: compiler/taskservice tests; full CDC/frontend race suites; 100 immutable callback-isolation race repetitions; six embedded source/target generation, EndTs, tenant/cross-CN and first-ACK tests; protocol upgrade gates and registration; public SQL no-PK rejection and NoFull CN-restart lifecycle. The prior six production
fmt.Errorfviolations have been removed while retaining original causes; the narrower old golangci-only result is not represented as a complete SCA pass.Earlier branch evidence: real MySQL 8.0.44 replacement BVT; a 200-transaction local microbenchmark measured about 298 microseconds per transaction for the target SELECT/identity guard. This is not a production-throughput claim. The correction adds no normal-path SQL, lock, background state or retry loop. MySQL BVT remains opt-in via
MO_CDC_MYSQL8_TEST_URI.The repository CI coverage parser reports 75.64% (742/981 changed executable blocks) using fresh coverage for changed files and reused coverage only for byte-unchanged files.
This correction removes 24 net implementation lines, adds 15 net test lines, and changes no tracked documentation. New tests replace the runtime-only fallback suite and exercise the persisted consumer. Remote CI for the updated revision remains pending.