Skip to content

test(shardservice): make remote compatibility preflight deterministic - #26063

Merged
XuPeng-SH merged 4 commits into
mainfrom
fix/26045-deterministic-shard-read-test
Jul 23, 2026
Merged

XuPeng-SH merged 4 commits into
mainfrom
fix/26045-deterministic-shard-read-test

Conversation

@aptend

@aptend aptend commented Jul 23, 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 #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.

@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 →

@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Jul 23, 2026

@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.

Reviewed the complete test-only diff and the production path it exercises. The deterministic cache setup preserves the intended service.Read preflight-ordering contract while removing unrelated heartbeat/rebalance timing. Resource cleanup is safe, the focused race/stress and full package tests pass, and a mutation that sends after the first compatible target is correctly caught by the zero-send assertion. No blocking findings.

@mergify mergify Bot added the queued label Jul 23, 2026
@mergify

mergify Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-23 05:06 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-23 05:11 UTC · at 9d1b9c197c2100724c813a1c2358861e3fae9579

This pull request spent 5 minutes 15 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)

Reason

Pull request #26063 has been merged manually at 67adb75

Hint

You were too fast!

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 67adb75 into main Jul 23, 2026
23 of 25 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/26045-deterministic-shard-read-test branch July 23, 2026 05:11
@mergify mergify Bot removed the queued label Jul 23, 2026
@mergify mergify Bot added the dequeued label Jul 23, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…matrixorigin#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 matrixorigin#26045

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

`TestReadValidatesAllRemoteShardsBeforeSending` was added with matrixorigin#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.

matrixorigin#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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…matrixorigin#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 matrixorigin#26045

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

`TestReadValidatesAllRemoteShardsBeforeSending` was added with matrixorigin#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.

matrixorigin#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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…matrixorigin#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 matrixorigin#26045

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

`TestReadValidatesAllRemoteShardsBeforeSending` was added with matrixorigin#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.

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

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/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TestReadValidatesAllRemoteShardsBeforeSending flaky — remote shard read timeout

3 participants