Skip to content

fix(tests): make replay and shard read setup deterministic#26051

Merged
XuPeng-SH merged 3 commits into
mainfrom
fix/tae-replay-prepared-dml
Jul 23, 2026
Merged

fix(tests): make replay and shard read setup deterministic#26051
XuPeng-SH merged 3 commits into
mainfrom
fix/tae-replay-prepared-dml

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Test and CI

What this PR does / why we need it

This PR fixes two independent nondeterministic test setups without relaxing production behavior.

TAE checkpoint replay

TestAppendAndGC2 created its database and tables through low-level TAE catalog APIs. Those APIs mutate the in-memory catalog but do not append rows to mo_database, mo_tables, and mo_columns. After a forced checkpoint truncates the DDL WAL, checkpoint replay can therefore lose the still-live database.

The prepared-DML replay fence added by #26027 exposed this invalid setup as ExpectedEOB. The previous version of this PR skipped missing catalog entries, but diagnostics proved the missing IDs were the live test database and table. That production-code relaxation was removed.

The test now uses the full DDL helpers and, after restart, opens both relations and scans every column to verify that each still contains all 99 rows.

Shard read compatibility test

TestReadValidatesAllRemoteShardsBeforeSending could create its table before all three CNs reported to the shard server. In the failed Ubuntu job, all shards were initially allocated to cn1 and balancing the second shard took 60 seconds. The shared setup context expires after 10 seconds, so the first remote compatibility check returned context deadline exceeded after one Adjust call instead of reaching the intended incompatible CN.

The test now waits for every CN before creating shards, bounds every replica wait, uses separate setup and read contexts, and asserts the exact incompatibility error. This keeps the test fast and prevents unrelated timeout errors from satisfying require.Error.

No production code is changed.

Validation

  • TAE focused replay test: count=20
  • TAE focused replay test: race count=10
  • pkg/vm/engine/tae/db/test full package
  • pkg/vm/engine/tae/txn/txnimpl full package
  • shard compatibility test: count=30
  • shard compatibility test: race count=10
  • pkg/shardservice full package
  • go build ./pkg/shardservice
  • go vet ./pkg/shardservice
  • git diff --check

@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 changed the title fix(tae): tolerate pruned catalog entries during replay fix(tae): use replayable catalog DDL in append GC test Jul 22, 2026
@XuPeng-SH
XuPeng-SH requested a review from iamlinjunhong as a code owner July 23, 2026 02:02
@XuPeng-SH XuPeng-SH changed the title fix(tae): use replayable catalog DDL in append GC test fix(tests): make replay and shard read setup deterministic Jul 23, 2026
@XuPeng-SH
XuPeng-SH merged commit ff7e6f0 into main Jul 23, 2026
28 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/tae-replay-prepared-dml branch July 23, 2026 02:46
XuPeng-SH pushed a commit that referenced this pull request Jul 23, 2026
…#26063)

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

Fixes #26045

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

`TestReadValidatesAllRemoteShardsBeforeSending` was added with #25872 to
protect a specific ordering contract: when a binary prepared-parameter
read targets multiple remote shards, every selected target must pass
commit compatibility validation before the first RPC is sent.

The observed failure was initially reported as a remote-read timeout,
but no remote read had started: the counting client remained at zero
`AsyncSend` calls. The roughly 60-second delay came from the test setup.
It created a real three-CN shard topology through asynchronous
heartbeat, allocation, rebalance, and read-cache refresh. If allocation
started before all CNs were visible, replicas first accumulated on one
CN; subsequent balancing could wait for the one-minute CN freeze
interval. The test then chose an incompatible target from asynchronously
maintained state, while `Read` could observe a different target ordering
and return after the first incompatible shard, leaving only one `Adjust`
observation.

#26051 improved that setup by waiting for all CNs and separating
setup/read contexts. This PR narrows the test further to the contract it
owns:

- install two single-replica remote shards directly in the read cache;
- make the first target compatible and the second target incompatible;
- keep the real `service.Read`, replica selection, cluster compatibility
lookup, and counting RPC client;
- require both shard adjustments, the exact incompatibility error, and
zero `AsyncSend` calls.

This deliberately does not increase timeouts, add retries, or change
production behavior. Scheduler, heartbeat, rebalance, and real
remote-handler behavior remain covered by their owning tests, including
`TestBinaryReadUsesVersionedRemoteHandler`; they are not prerequisites
for this preflight-ordering regression. A regression that validates and
sends in the same loop will send after the first compatible shard and
fail the zero-send assertion.

Validation after the final edit:

- focused regression: `-count=100` passed in 4.407s;
- focused race regression: `-race -count=20` passed;
- full `./pkg/shardservice` package passed in 17.895s;
- `go build ./pkg/shardservice` passed;
- `go vet ./pkg/shardservice` passed;
- `git diff --check` passed.

For comparison, current `main` with the asynchronous setup passed 100
repetitions locally but took 109.544s.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants