Skip to content

test: stabilize branch index readiness and snapshot fixture lifetime - #31072

Closed
XuPeng-SH wants to merge 4 commits into
mainfrom
codex/fix-branch-index-restore-waits
Closed

XuPeng-SH wants to merge 4 commits into
mainfrom
codex/fix-branch-index-restore-waits

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 25, 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:

Fixes #31065
Fixes #31075

What this PR does / why we need it:

The branch-index restore BVT can observe an earlier durable index generation before the branch UPDATE and INSERT reach its reader. Its storage-existence checks allowed FULLTEXT2 to return only ID 1 instead of IDs 1 and 3, or HNSW to use its table-scan fallback before the required index plan became ready. Wait for the complete FULLTEXT2 result and the HNSW index plan with bounded wait_expect. During this serial BVT, use the existing cluster-wide freshness cadence at 1s, check partial RPC failures, and restore the default cadence at exit. Preserve the exact results, both index-plan assertions, independent distance-expression control, branch diff, and failed-job assertions.

The snapshot rollback fixture also shared a separate 60-second deadline across engine bootstrap, setup, flush/merge, transfer and commit. In issue #31075, the mixed-tombstone/transferring-statement cell exhausted that deadline at commit after 60.21s. Reuse the existing EnginePack five-minute context, created after bootstrap, without renewing the work budget per operation. Register acquired transactions and the pack immediately with t.Cleanup; active rollback gets a bounded cleanup context that preserves tenant values after work cancellation, and a rollback error cannot suppress pack cleanup. Release locally owned batches and log stage durations/remaining budget. Keep all nine merge/rollback cells, the original fixture size, and every result oracle.

Production code is unchanged. The original CI log proves deadline exhaustion; the underlying I/O latency cause remains unknown. Bootstrap, synchronous merge helpers and pack shutdown still rely on the outer test timeout. The BVT assumes a clean serial instance with the default cadence; 1s is the base cache ticker, not a one-second freshness guarantee.

Validation on Linux amd64, Go 1.27.1 and clang 19.1.7 CPU native libraries:

  • Original rollback baseline: all nine cells passed (6.96s); final focused consumers and cleanup tests: 10 top-level tests / 38 subtests passed (26.028s).
  • Full ./pkg/vm/engine/test normal suite: 168 top-level tests / 48 subtests passed (147.845s); two unchanged existing skips are excluded from the pass count.
  • Full owning package under race: 168 top-level tests / 48 subtests passed (204.627s), with the same two existing skips. All ten exact-name adaptive race commands also passed (197 top-level executions / 774 subtests); the original merge regression ran three repetitions with all 27 leaf cells passing.
  • Incremental gofmt, go vet, repository molint and golangci-lint passed (0 issues), including the staged new test file.
  • Normal mo-tester comparison: single-CN twice, 27/27 each (20.948s, 16.678s); two-CN result twice, 27/27 each (20.417s, 20.946s).
  • A real warm remote FULLTEXT2 cache returned ID 1 while the writer returned 1,3 and the remote base-table query saw all three rows. After enabling the existing freshness cadence, the remote index returned 1,3 in 4.226s without reindexing, cache eviction or restart. HNSW plan and both 3,2 result controls passed.
  • Impossible FULLTEXT2-result and HNSW-plan controls each hit their 60-second wait timeout and failed only the intended assertion (26/27 passed). Both CNs restored the default cadence, dropped the database and had no active index ISCP jobs.
  • A temporary constructor failure control canceled the work context and called FailNow after transaction acquisition. Real rollback reached Aborted; an injected returned rollback error was reported; pack.Close still returned. The expected failing control was excluded from UT pass totals.
  • Design: gpt-6.1-sol / xhigh. Final independent review: gpt-6-astra / xhigh, PASS with no unresolved blockers at commit 2e3b374469 (agent /root/pr31072_astra_review, record review.md).
Reproduction commands and artifact identity

Validated commit: 2e3b374469c5536315c0414e152b27786ebf008a. The complete intended change is four test files against merge base aeaa273daf588a9988ba423915d3ae6b8c82124a. The two Go test files have SHA256 9182f26f7a74d32f2b48c7e83e871890a86912e222ca0fa2f8cb5b720f43fbf8 and 2c5c286437a29aa58199d3802dbd67b2093c0f875c847c1b88fe2f383a49401e. The SQL/result pair remains the existing PR revision, with SHA256 c5212b4b63dca8d2011084f742b898d4f0f5f9a235c70c540f854a979dee75b6 / 2b7324c7ff91e28ec93b900c500abeb8854f051f0e2580b2f1b890b32db42d54.

export GOTOOLCHAIN=go1.27.1 GOMAXPROCS=4
.agents/skills/mo-dev/scripts/mo-cgo-test -p=2 -json -count=1 -timeout=20m ./pkg/vm/engine/test
.agents/skills/mo-dev/scripts/mo-cgo-test -p=2 -race -c -o /mnt/nvme/pr31072-tmp/engine-race.test ./pkg/vm/engine/test
# Run from pkg/vm/engine/test, preserving the same native-library environment:
go tool test2json -t -p github.com/matrixorigin/matrixone/pkg/vm/engine/test \
  /mnt/nvme/pr31072-tmp/engine-race.test -test.v -test.count=1 -test.timeout=20m
go tool test2json -t -p github.com/matrixorigin/matrixone/pkg/vm/engine/test \
  /mnt/nvme/pr31072-tmp/engine-race.test -test.v \
  -test.run '^TestRCSnapshotRollbackAcrossMerge$' -test.count=3 -test.timeout=120s

Each exact adaptive run uses the same race binary with N = clamp(floor(30 / T), 1, 100) from the owning-race measurement and a 120-second outer timeout:

Exact top-level test Repetitions
TestSnapshotAdvanceCleanup 100
Test_RCSnapshotAdvancePreservesUncommittedDeletes 12
Test_RCSnapshotAdvanceHarnessRollback 13
Test_RCSnapshotAdvanceHarnessCommit 11
Test_RCSnapshotAdvanceHarnessSubsequentStatement 12
Test_RCSnapshotAdvanceHarnessStatementRollback 5
TestRCLineageSnapshotPreservesUniqueReplacements 12
TestTransferPartialIORecovery 16
TestRCMemoryTransferWidePKBoundary 13
TestRCSnapshotRollbackAcrossMerge 3

Service binary SHA256: fd7d3e0d492d136cb1e97b7a73be9751faa4e501822750b52dd7398939d9313e, built from a7fcc6d5de0c48e27022c96e1eff60380ed2ba1a; subsequent changes are Go test files only. Release build uses GOAMD64=v3 / GOEXPERIMENT=simd. Fresh DISK-V2 local storage, RC/pessimistic configuration; separate CN processes on SQL ports 16772 and 16773. SQL and ISCP readiness were checked before comparison.

mo-tester clean revision: 309a0ca650e0c55e90292767fd61e4976818d66d; executed JAR SHA256: 905cf05154295eaed552bd445f122206c48d6f22debf2bc55872fff388a9f3f5. Run io.mo.Tester with the verified configuration/classpath and path=test/distributed/cases/git4data/branch/edge/branch_multi_index_restore_init.sql method=run rate=100 nometa ignore pprof. The second run used the same running instance and checked database absence before starting.

Actual mo-tester terminal excerpts:

single first:  cost: 20.948s, total:27, success:27, failed:0, ignored:0, abnoraml:0
single second: cost: 16.678s, total:27, success:27, failed:0, ignored:0, abnoraml:0
two-CN first:  cost: 20.417s, total:27, success:27, failed:0, ignored:0, abnoraml:0
two-CN second: cost: 20.946s, total:27, success:27, failed:0, ignored:0, abnoraml:0
FULLTEXT control [row:47]: wait_expect timeout, result did not match expected
  cost: 61.948s, total:27, success:26, failed:1, ignored:0, abnoraml:0
HNSW control [row:54]: wait_expect timeout, result did not match expected
  cost: 79.846s, total:27, success:26, failed:1, ignored:0, abnoraml:0

After each final drop, both CNs reported zero databases and zero active index ISCP jobs. One cached entry remained under the existing five-minute TTL/default housekeeping cadence; immediate eviction is not claimed. Both test-owned service processes then shut down gracefully and all four SQL/debug ports closed.

Both CN logs recorded default restoration after the FULLTEXT timeout at 01:52:39, HNSW timeout at 01:57:27 and final normal run at 01:57:49 (2026-10-25, UTC−04:00).

The full logs, reports, control variants, configuration hashes, source fingerprints and independent design/review records are retained locally at /home/xupeng/.codex/issue-to-pr/matrixone/pr31072-31075/. Expected-failing controls, canceled builds and ineffective probe setups are recorded separately and are not counted as passing UT/BVT runs.

CI for the updated head is pending.

Wait for the complete FULLTEXT2 result and HNSW index plan instead of
storage rows that can predate the last branch write. Use the existing
freshness cadence control during this serial BVT and check both its
application and restoration across CNs.

Preserve the result, plan, branch diff, and failed-job assertions while
removing obsolete readiness variables and prepared statements.

Validated with single-CN and separate-process two-CN BVT runs, a warm
remote-cache challenge, and a timeout/cleanup negative control.
@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 →

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 25, 2026
@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Oct 25, 2026
@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: d151c0e427b71112528837e185d13df378604449

Review belongs to an older commit; it is not a review of the current head.

@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: a7fcc6d5de0c48e27022c96e1eff60380ed2ba1a

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: a7fcc6d5de0c48e27022c96e1eff60380ed2ba1a

Assessment: request_changes

Complete source review found a coherent design and no confirmed code defect. The change strengthens readiness checks, preserves existing oracles, and removes obsolete guards. Required live BVT evidence remains unverified.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 test/distributed/cases/git4data/branch/edge/branch_multi_index_restore_init.sql:45: Validation requirement: exercise the new waits with a stale remote reader and verify cleanup when either wait times out.
    Impact: Source and comparator checks cannot establish actual cross-CN convergence, successful cadence restoration, or clean same-instance reuse.
    Evidence: The current evidence.json has empty local_validation and no completed BVT result. The PR describes successful macOS runs and failure controls but supplies no matching source/build identities, commands, reports, service logs or exit records. The repository testing-contract requires real normal-comparison execution and teardown proof. Attach the existing single-/two-CN runs, same-instance reruns and failure-cleanup controls with candidate provenance; rerun only evidence that cannot be recovered.

Validation:

  • Preflight passed: checks/1792903838064702902-4.json and preflight.log.

  • Parser/comparator probe passed on byte-identical candidate files: 27 statements, two bounded waits, expected results accepted, missing FULLTEXT2 ID 3 and HNSW table-scan plan rejected. Receipt checks/1792903838613156114-3.json; log case-contract.log.

  • Frozen-range git diff --check passed: checks/1792903870880107245-3.json and diff-check.log.

  • All check receipts matched the assigned head and clean source fingerprint. Detailed review record: /home/xupeng/.local/state/mo-bot/jobs/a9e9a686513c44bfe0801eca/attempt-1/review-evidence.json.

Limitations:

  • No live SQL or native test was executed; the comparator probe does not replace BVT execution.

  • The linked issue's full text was absent from the supplied evidence.

  • Production code is unchanged. Faster cache sweeps and repeated queries add test-fixture work; no runtime measurements were supplied.

@XuPeng-SH XuPeng-SH changed the title test: wait for branch index query readiness test: stabilize branch index readiness and snapshot fixture lifetime Oct 25, 2026
@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 2e3b374469c5536315c0414e152b27786ebf008a

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: 2e3b374469c5536315c0414e152b27786ebf008a

Assessment: request_changes

Complete source review found a coherent test-only design and no confirmed implementation defect. Existing oracles are preserved and cleanup ownership improves. Required execution evidence remains unverified because the referenced artifact bundle is unavailable.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 test/distributed/cases/git4data/branch/edge/branch_multi_index_restore_init.sql:45: Validation requirement: verify stale-reader convergence and wait-timeout cleanup, together with the changed snapshot fixture's cancellation/FailNow cleanup.
    Impact: Make the retained validation bundle accessible before approval: single-/two-CN comparisons and same-instance reruns, timeout controls and teardown logs, and focused/owning normal/race fixture results with source/build/exit provenance. Recover existing runs first; rerun only missing validation. This is an evidence requirement, not an observed production failure.
    Evidence: All four source hashes match the PR description, but /home/xupeng/.codex/issue-to-pr/matrixone/pr31072-31075 does not exist on the coordinator host. local_validation is empty, and the frozen CI snapshot supplies no completed relevant UT/BVT result. The recovered comparator receipt verifies identical SQL/result bytes and negative oracles but explicitly executed no SQL. The PR's commands and terminal excerpts cannot be reconciled with the missing receipts, reports and logs.

Validation:

  • Verified frozen HEAD, clean source, complete four-file patch equivalence, advertised SHA256 values, Go formatting and git diff --check.

  • Reconciled retained comparator evidence against unchanged SQL/result bytes: 27 statements, two bounded waits, expected results accepted, missing FULLTEXT2 ID 3 and HNSW table-scan plan rejected.

  • Traced all snapshot harness consumers, EnginePack lifetime, transaction/batch ownership, cleanup order, freshness-control fanout and mo-tester timeout continuation.

  • Audit receipt checks/1792909286688242763-2.json matches the current HEAD, clean source fingerprint and evidence-audit.log. Evidence and review-map.json are retained in /home/xupeng/.local/state/mo-bot/jobs/9784e4d1ac9d18dc4de696f2/attempt-1.

Limitations:

  • No local native tests or live SQL were executed. Author-reported normal/race, warm-reader, timeout-control and runtime results remain unverified pending artifact recovery.

  • Production code is unchanged. Additional polling and cache sweeps affect the test fixture; bootstrap, synchronous merge helpers and pack shutdown still depend on the outer test timeout.

  • Full linked-issue bodies were not supplied; review used preserved PR descriptions, frozen sources and available comments.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Incorporated into #31076 at 69fa7e5f7c3cce0b8eb1872a3dfd5125992d0e6c, rebased onto main 12eeeb0205b5e87faef48660ddbcd8cb5e18baea, as requested by the maintainer. All four files match this PR head byte-for-byte. #31076 now carries the fixes for #31065 and #31075 and explicitly retains the outstanding validation-artifact requirement from the latest review. Closing this PR as superseded; it was not merged independently. Combined-head CI remains pending.

@XuPeng-SH XuPeng-SH closed this Oct 25, 2026
XuPeng-SH added a commit that referenced this pull request Oct 25, 2026
)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue #31074 — Closes #31074
issue #31063 — Closes #31063
issue #31065 — Closes #31065
issue #31075 — Closes #31075

## What this PR does / why we need it:

Async index initialization can conflict with account teardown, and
periodic watermark publication can deadlock against database retirement.
Branch-index readiness also needed to cover the actual writes, while the
snapshot fixture consumed a second deadline before bootstrap.

- Keep one standalone account-drop transaction owner. Retry nested
database FastFail only after nonblocking proof of successful abort
cleanup for the captured generation. Preserve the target account ID,
rebuild attempt-local work, and exclude borrowed transactions, uncertain
commits and postcommit replay. Limit to five attempts with cancellable
backoff.
- Make periodic watermark writes use the existing FastFail option,
whole-batch transaction/reservation rollback and next flush tick.
- Wait for complete FULLTEXT2 results and an HNSW index plan; preserve
indexed/exact-distance, branch-diff and failed-job assertions.
Temporarily shorten the existing cluster-wide freshness cadence and
verify restoration.
- Reuse EnginePack's bounded lifetime after bootstrap, immediately
register cleanup, and give rollback a separate cancellation-independent
bound. Preserve all snapshot/merge/rollback scenarios.
- Incorporate #31072. Rebase the three original patches onto main
`1732bb3297f598bc9a90a41b8c5e4c9557cf0e9c`; stable patch IDs and the
28-file PR delta are unchanged. Resulting head:
`d4917342ad2496d455d8265a46172c861a0ca2dd`.

Ordinary SELECT/DML gains no additional SQL, transaction or polling.
Persistent contention can exhaust the bounded account retry or defer
watermark publication. The temporary `1s` cache ticker produces a
freshness sweep every fourth tick plus housekeeping; no throughput
benchmark is claimed.

### Validation on the rebased head

Linux amd64, Go 1.27.1 / clang 19.1.7, CPU build. New main changes ISCP
initialization and internal session/temporary-table access, so affected
runtime and SCA checks were rerun.

- **Owning/consumer race:** full `frontend`, `iscp`, `txn/client`,
`vm/process`, `vectorindex/sqlexec`, `sql/compile` suites pass: 4,888
top-level passes, one existing in-test skip
(`TestRuleCacheDoubleCheckLocking`). No test exclusion or short mode.
Includes same-generation cleanup, watermark rollback/retry, session
lending/masking, clone allocator context restoration and executor reuse.
- **Targeted race:** 14 roots across integration/multicn, engine tests,
planner and table functions pass. Covers real async DROP contention,
session owner/attacker isolation with background index maintenance and
teardown, all snapshot roots, temporary-access controls and long
physical identities.
- **Independent CN processes:** B warms both old index generations
before A's writes. B logs stale decisions and generation-change
evictions, then HNSW reloads from two to three rows. Fulltext returns
`1,3`; indexed and independent distance results are `3,2`; branch diff=2
and failed jobs=0. Convergence **5.303 s**. Settings restore on both
CNs, B's active ticker resets, catalog/job teardown succeeds and both
processes exit normally.
- **Exact original BVT:** normal mo-tester comparison on the same
surviving process pair **27/27**, zero failed/ignored/abnormal.
Previously validated timeout/recovery, constructor FailNow/cancellation
and adaptive stress controls are reused where their mechanisms are
unchanged.
- **SCA/build:** standard vet, custom molint and configured incremental
lint pass across the 11-package affected/consumer closure. Configured
lint has zero issues; all 27 custom diagnostics match unchanged base
functions/files. New service binary identifies this head with
`vcs.modified=false`; matching native provenance, formatting and diff
checks verified.
- Required `gpt-6.1-sol / xhigh` rebase design:
`01a17315-1bcd-7552-9b24-30c103344318`. Final overall review **PASS**:
session `01a17327-06ae-7852-880a-22a23bf8dd08`; no unresolved material
blocker.

Commands, source fingerprints, terminal receipts and raw evidence are
retained outside tracked source at
`/home/xupeng/.codex/issue-to-pr/matrixone/31076/rebase/`
(`validation-audit.json`, `remote-proof-audit.json`,
`integration-audit.json`).

Rebased-head GitHub CI results are not yet verified; local checks do not
claim green merge CI. No merge or GPU validation is claimed.
@XuPeng-SH
XuPeng-SH deleted the codex/fix-branch-index-restore-waits branch November 1, 2026 05:02

This branch was previously deployed

1 inactive deployment
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/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

2 participants