Skip to content

fix(iscp): process complete tail groups and opt-in row-budget ranges - #31372

Merged
XuPeng-SH merged 13 commits into
matrixorigin:mainfrom
jiangxinmeng1:codex/iscp-direct-26973
Nov 22, 2026
Merged

XuPeng-SH merged 13 commits into
matrixorigin:mainfrom
jiangxinmeng1:codex/iscp-direct-26973

Conversation

@jiangxinmeng1

@jiangxinmeng1 jiangxinmeng1 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #26973. This reduces repeated catch-up work and adds an opt-in soft row target. It does not close the issue's strict bounded-work requirement.

What this PR does / why we need it:

ISCP retains a partitioned change reader's Tail_wip batches until Tail_done, delivers the complete group once, and releases owned batches on error, incomplete EOF, and cancellation.

Index-sync jobs select ranges from their own watermarks. In-step indexes with the same row target share a source read; lagging indexes catch up separately. The 30-minute timestamp cap applies to every catch-up job.

A positive TriggerSpec.TargetRows opts a job into complete-timestamp-prefix probing under the same source transaction snapshot used for the final read. Zero keeps the historical behavior for both existing and new index jobs until source-read and sink-persistence costs are measured. Probes count historical insert and delete operations before PK coalescing. An oversized first commit is admitted whole. The selected endpoint is committed with the sink watermark.

Review fixes preserve the scheduled range after a probe error and reset the logical timestamp when TS.Next() crosses a physical boundary. Tests cover two successive index scheduling, read, consumer delivery, and watermark advances across that boundary. The design and limits are in docs/design/20261029-iscp-row-budget-range.md.

A scheduled iteration captures its row target and trigger policy. A catalog update between admission and execution applies to the following iteration, so an admitted group can keep sharing its source read.

Running and error updates preserve each job's committed watermark. A sink commit or a successfully completed snapshot can advance it. Terminal status batches settle eligible members even when a retired member loses its CAS. A failing fenced consumer releases its reader queue so healthy consumers finish the shared read.

An index initialization can retire its own ISCP generation and register its successor in the same transaction. Its completion CAS accepts that exact retirement when the current transaction performed it, while still checking the job generation, stage and previous LSN. That preserves the atomic commit of the rebuild and the successor registration. A retirement from another transaction still rejects the old initialization.

Validation

  • Rebased onto main at 00716de. All ten preceding patches are equivalent after rebase.
  • Reproduced the Fulltext2 COPY ALTER index rebuild failure on the rebased pre-fix code. The same public SQL test passes after the fix, including the new generation, subsequent tail changes and indexed reads.
  • Verified an externally retired initialization rolls back its SQL side effects. Verified the rebase uses Batch-owned vector leases while preserving the existing pending-tail cleanup checks.
  • The affected packages in ISCP, CDC, container types, engine, DistTAE and logtail replay passed race tests. The focused engine SQL tests and the failing Fulltext2 integration test passed with race instrumentation. The Fulltext2 test also passed with coverage enabled.
  • Repository formatting, err-check, vet, lint and molint passed.
  • All nine BVT scripts that failed in the previous PROXY job passed on a local two-CN cluster with Proxy. The scripts reported 1,020 passes, zero failures and one existing ignore.

Limits and follow-up

This is a soft row target, not a strict byte, memory, or time bound. A single large commit and initial snapshots remain unbounded. SQL index equivalence and equal-work cost measurements are still needed before enabling the target by default or treating #26973 as resolved.

Rebase and row-budget validation

  • Rebased the 11 non-merge patches onto 7431a275e9. The patch series is unchanged by the rebase.
  • Reject invalid targets before registration or spec updates go to the catalog. Reuse the execution-time rule. Invalid settings encountered during replay keep their watermarks and stay out of candidate groups until corrected, so they do not occupy a worker or delay a healthy peer.
  • The partitioned reader can assemble an entire commit even when child readers use ordinary batches. A soft row target gives no hard memory limit. #26973 remains open for strict work bounds.
  • On host 57, the final head passed the complete short Race suites for pkg/iscp and pkg/cdc, the real-engine TestUpdateJobSpec under Race, and incremental static analysis. The timestamp rollover and partition-reader Race controls also passed before the final scheduler-only telemetry correction.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 290b17149a3826211575052b05bd7ab854ddd232

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 290b17149a3826211575052b05bd7ab854ddd232

Assessment: request_changes

The reader-owned accumulation design appropriately restores partitioned catch-up progress while preserving existing sink commit boundaries. Complete delta and caller review found one confirmed cleanup-ordering defect. The documented deferral of general bounded-work support is reasonable for this scope.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 pkg/iscp/iteration.go:499: A retained Tail_wip group is abandoned on cancellation or incomplete EOF.
    Impact: The later defer changeHandelWg.Done() executes before this cleanup defer. Consequently, the wait at line 674 can finish and the iteration can return while pending batch buffers remain owned and cleanup is still running. Register Done before the cleanup defer, or otherwise signal completion only after cleanup finishes.
    Evidence: A test-only overlay exercising the unchanged production reader with a blocked vector-release callback reproduces premature return for both cancellation and incomplete EOF: cleanup-probe.log, receipt checks/1793084148994605642-4.json, exit 1. Moving only the Done defer before cleanup makes both cases pass: cleanup-control.log, receipt checks/1793084181302635975-3.json, exit 0. These artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/7b1e1f40a290a8e44c39c75f/attempt-1.

Validation:

  • Isolation preflight passed; retained native prerequisites were qualified against current inputs and output hashes.

  • All three new tests passed normally, under race detection, and in 100 individually selected race repetitions each.

  • Complete pkg/iscp passed normally and under race detection, including TestWatermarkBatchYieldsToRetirement without exclusion.

  • Matched commands, source fingerprints, exit receipts and retained logs in validation-ledger.json; source remained unchanged and git diff --check passed.

  • Saved discussion-assessment.json covering both frozen discussion items. Both are informational notices; no substantive prior findings or rebuttals exist.

  • Detailed design, ownership, test-quality and performance assessment is retained in review-notes.md.

Limitations:

  • No local partitioned-table SQL/BVT, GPU execution or performance benchmark was run; frozen CI provides status metadata rather than case-level logs.

  • Expected retry reduction and unchanged sink persistence boundaries are supported by source analysis, not throughput measurements. Dense timestamps and whole dirty iterations remain unbounded as documented.

  • The regression probe establishes premature cleanup completion reporting, not an observed production crash, permanent leak or data loss. Passing race tests do not close this lifecycle defect.

Comment thread pkg/iscp/iteration.go Resolved
@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 7bd496db4d42985b73c3c188003df743a9351fa0

New discussion was assessed; the previous review remains unchanged.

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@jiangxinmeng1

Copy link
Copy Markdown
Contributor Author

@fengttt The latest head adds TestIndexCatchupDeliversDeferredCommitAcrossIterations. It drives getCandidate → row-budget range selection → the ISCP reader/consumer loop → UpdateWatermark for two consecutive index iterations. It checks that the commit deferred at physical timestamp (30,0) is delivered exactly once on the second iteration and that the index watermark reaches (30,0).

The existing SQL BVT test/distributed/cases/vector/vector_ivfflat_include_dml_sync.sql covers the actual async IVF index sink across successive source changes and verifies active-version index entries. The new test pins the scheduler and timestamp boundary that the BVT cannot force deterministically. Post-merge CI is running on de4830c3c2.

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of de4830c3c2e589eb7a1d39a7b8d0d1ea080c117d.

The original production concerns are addressed: TS.Next resets the logical part on physical rollover, the existing two-iteration rollover control passes, and TargetRows remains opt-in for old and new jobs. The pending-tail ownership/cancellation changes also passed the focused checks, including 15 measured-budget race repetitions of TestISCPIterationWaitsForPendingTailCleanup.

One new blocker remains: TestIndexCatchupDeliversDeferredCommitAcrossIterations fails both in the focused suite and alone on this exact head. The test assumes the selected range always ends immediately before the second commit, but TargetRows=1 permits the selector's exact-target early return in the empty gap. See inline. This is a failing test oracle, not a newly demonstrated production data-loss path. Please repair it and run the exact test plus its rollover/upper-bound controls before approval.

require.Len(t, iterations, 1)
iteration := iterations[0]
require.True(t, iteration.indexJob)
require.Equal(t, expectedFrom, iteration.fromTS)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Repair the new test's selected-range oracle

This exact test fails deterministically: expected (30,0), actual (25,0). With TargetRows=1, selectRowBudgetTo returns the first exact-target prefix at (24,MaxUint32); watermark.Next() correctly schedules (25,0). Starting inside that empty gap does not skip the commit at (30,0).

Derive the next start from the published bound and assert exactly-once delivery of both commits, or use two rows per commit with target three to force the intended boundary without the exact-target early return. Preserve the separate TS.Next rollover and upper-bound controls; do not change correct scheduling only to satisfy this assumption.

@jiangxinmeng1

Copy link
Copy Markdown
Contributor Author

@aunjgr Fixed the test oracle in de2d8259ae and merged current upstream main in a365496668. The second iteration now starts at the previous published watermark's Next(), including when the selector ends in an empty timestamp gap. The test still verifies that the later commit is deferred and that both rows are delivered exactly once.

TestIndexCatchupDeliversDeferredCommitAcrossIterations, TestRowBudgetTwoIterationsKeepDeferredPhysicalCommit, and TestRowBudgetProbeFailurePreservesRetryRange pass together locally with the repository CGo wrapper. New CI is starting on this head.

@XuPeng-SH

XuPeng-SH commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · superseded

Commit: a3654966685c2b9e6e4e7fccf82854990bef50da

Review discussion changed before publication; a fresh contextual review is queued.

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex automated review

Reviewed head a365496 against origin/main, including the delta from the previously reviewed head and the merge resolution. The earlier blockers concerning tail-group ownership and cleanup ordering, timestamp rollover skipping deferred commits, probe failures corrupting retry ranges, and the two-iteration test oracle are fixed in the current code and regression tests. Row-budget probing is now opt-in, so the earlier default-rollout cost concern is withdrawn as blocking. The end-to-end coverage request is addressed by the deterministic two-iteration scheduler/consumer test together with the author-identified existing SQL BVT. Alternative sharding, scheduling, and chunking proposals remain non-blocking design follow-ups. I found no remaining reachable correctness, compatibility, concurrency, resource-ownership, or error-path defect. I could not independently run the focused Go tests because this checkout lacks the required native headers, libraries, and libmo artifacts; the author reports that the three focused tests pass with the repository CGo wrapper. Static inspection and git diff --check completed successfully.

@XuPeng-SH

XuPeng-SH commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: a3654966685c2b9e6e4e7fccf82854990bef50da

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: a3654966685c2b9e6e4e7fccf82854990bef50da

Assessment: approve

Prior cleanup, timestamp, retry-range and test-oracle defects are resolved. The design shares in-step index reads and reuses existing atomic sink/watermark commits; additional probing remains opt-in.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed all 20 changed files and assessed all 35 discussion entries.

  • Normal types, ISCP and logtailreplay suites passed; all 72 selected disttae reader/combined-reader tests passed.

  • The final full ISCP race run passed. Eight individually selected race checks passed their measured repetition budgets, including 15 cleanup-ordering repetitions.

  • Independent selector coverage passed 1,000 scenarios across 3,471 intervals; JSON round-trip and actual engine prefix/batching probes passed.

  • Dependent build including SQL compile, vet, formatting and native-input provenance checks passed. Frozen-head CI reports build, UT, SCA and multi-CN BVT success.

  • Source remained unchanged. Receipt/log reconciliation passed; see validation-reconciliation.json and checks/1794893683714782203-2.json.

Limitations:

  • The broad disttae suite timed out in an unchanged finalization test; isolated base and candidate controls both passed. That full-package run is not counted as passing.

  • No budget-enabled index SQL/BVT, GPU or source/sink cost campaign was run locally. Single-commit and snapshot work remain unbounded; default activation remains deferred.

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of a3654966685c2b9e6e4e7fccf82854990bef50da.

The selected-range test oracle is repaired without weakening its semantic checks. The next scheduled start is derived from the previously published bound's Next(), while the test still independently checks that the first range defers the later commit, each iteration delivers the intended row exactly once, the complete result is [1,2], and the final watermark is (30,0). The separate literal physical-rollover, upper-bound and failed-probe controls remain intact.

No production lifecycle code changed in this repair; the main merge is conflict-free. I reused the prior source-qualified component/race evidence for unchanged boundaries and verified current-head CI run 44010461603 passes UT, ARM64 SCA, BVT, coverage and CI Required. The original rollover/opt-in requests and the later failing-test request are now closed. No remaining blocker found.

@XuPeng-SH

XuPeng-SH commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: a3654966685c2b9e6e4e7fccf82854990bef50da

New discussion was assessed; the previous review remains unchanged.

@XuPeng-SH

XuPeng-SH commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 9c99b99b274f619f24be206830f5bbc06b39a27a

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 9c99b99b274f619f24be206830f5bbc06b39a27a

Assessment: request_changes

The earlier cleanup, timestamp rollover, probe retry, and default activation concerns are resolved. In-step indexes share a read and row-budget probing remains opt-in. A budget change after admission can still stall both jobs and advance their watermarks past an unapplied commit.

Model: gpt-6.2-sol / xhigh

Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3

  • P2 pkg/iscp/row_budget.go:52: Two in-step index jobs are admitted with the same target. UpdateJobSpec changes one target before the worker reads the catalog, and a source commit exists at the iteration's inclusive lower bound.
    Impact: The worker spends its one-hour retry window on the same incompatible group without reading any changes. The terminal status write advances both watermarks to the first unconsumed timestamp. The next iteration starts after that timestamp, so both indexes can miss the commit.
    Evidence: pkg/iscp/table_entry.go:215 groups jobs using cached targets, while pkg/iscp/iteration.go:254 checks freshly read specs. The worker probe reached the terminal status writer after one hour of simulated retries. pkg/iscp/worker.go:181 passes the inclusive fromTS, pkg/cdc/sql_builder.go:399 writes it as the watermark, and pkg/iscp/job_config.go:111 resumes at its successor. Freeze the target for the admitted iteration or reschedule the group when its targets diverge, and preserve committed watermarks when no changes were applied.

Validation:

  • Reviewed all 20 changed files, linked issue #26973, and all 39 discussion entries. The frozen patch and pinned policy matched the checkout, and git diff --check passed.

  • Isolation preflight passed. Focused timestamp, ISCP, DistTAE, and logtail replay tests passed. The full ISCP and logtail replay suites passed in normal mode, and the focused ISCP race run passed.

  • Frozen CI reports successful build, unit tests, static analysis, and PROXY and PESSIMISTIC multi-CN BVT. Local commands, logs, and exit receipts are reconciled in validation-ledger.json.

Limitations:

  • The worker probe confirmed repeated budget rejection and entry into the terminal status writer. The probe stopped on an overly strict error-message assertion, and corrected runs timed out before executing. The durable watermark consequence was verified from the SQL and scheduling code.

  • The full ISCP race run timed out in TestWatermarkBatchYieldsToRetirement, which passed in normal mode. Budget-enabled SQL index equivalence and rollout costs were outside the executed coverage.

@XuPeng-SH

XuPeng-SH commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 10dac24da0c4663b9e4275747b59dd1dc00ff816

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 10dac24da0c4663b9e4275747b59dd1dc00ff816

Assessment: request_changes

The design reuses the existing atomic sink and watermark commit, shares reads for in-step indexes, and keeps prefix probing opt-in. The prior watermark and retry-range defects are resolved. Invalid budget settings can still be persisted and tie up a worker.

Model: gpt-6.2-sol / xhigh

Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3

  • P2 pkg/iscp/iteration.go:257: A caller sets a negative index row target or a positive target on an ordinary Default job. The next dirty tail iteration validates the stored policy.
    Impact: The configuration write succeeds, but the worker retries the same validation error for up to an hour. The next iteration can repeat the cycle until the spec is corrected.
    Evidence: The UpdateJobSpec probe observed one catalog UPDATE and a nil error for each invalid input. The valid control also succeeded. The worker retry probe made 12 attempts over one simulated hour. Apply validateRowBudget in the existing registration and update paths before persisting the spec.

  • P3 docs/design/20261029-iscp-row-budget-range.md:57: An opted-in job reads a logical partitioned table with a large commit spanning partitions.
    Impact: The design gives operators the wrong expectation that the oversized commit will stream in ordinary batches.
    Evidence: DisableQuick applies to the child readers. The combined reader in pkg/vm/engine/disttae/txn_table_combined.go:678 still assembles the whole commit timestamp before Next returns. Document that the probe and final read can both materialize that commit.

Validation:

  • Verified frozen scope, policy, whitespace, isolation, and native artifact provenance. Reconciled all 41 discussion entries and matched 11 command receipts to logs in validation-ledger.json.

  • Passed the full ISCP short race suite and focused race checks for CDC, timestamps, DistTAE, and logtail replay. Fenced-consumer cleanup passed 100 repetitions and pending-tail cleanup passed 15.

  • Passed the engine tests for durable status and external retirement rollback, plus the Fulltext2 COPY ALTER SQL test covering rebuild, tail updates, and indexed reads.

  • Frozen CI reports successful build, unit, static analysis, coverage, and both multi-CN BVT checks.

Limitations:

  • The invalid-policy probe used a mock SQL executor and a simulated retry clock. Budget-enabled index equivalence and source and sink costs were outside local validation. Issue #26973 remains open for strict work bounds.

@XuPeng-SH

XuPeng-SH commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: b03a3cb7c58b2dade3a78755540c822a0a2f17c9

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: b03a3cb7c58b2dade3a78755540c822a0a2f17c9

Assessment: approve

The shared row-budget rule now rejects invalid targets before catalog writes. Replayed invalid jobs stay out of scheduling and keep their watermarks. Correcting a spec lets the job rejoin its peers from the same checkpoint. The opt-in selector reuses the atomic sink and watermark commit, and the design now explains that partitioned reads can materialize an entire oversized commit.

Model: gpt-6.2-sol / xhigh

Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3

Validation:

  • The ISCP and CDC short race suites passed 748 top-level tests. A separate race test verified that an invalid replayed index job stays out of its healthy peer’s group and rejoins after correction without moving its checkpoint.

  • The real-engine spec update, durable status, initialization retirement, and Fulltext2 COPY ALTER integration tests passed under race detection.

  • Verified the frozen patch, pinned policy, native inputs, and unchanged inputs for the reused timestamp and change-reader tests. Matched seven receipts to retained logs and reconciled all 43 discussion entries.

Limitations:

  • Independent SQL validation used one CN. Budget-enabled index equivalence and throughput were outside local validation. Probing remains opt-in, and #26973 remains open for strict work bounds.

This branch was successfully deployed

No deployments
ci — ac56a2ef Deployed Nov 22, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/enhancement kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants