Skip to content

[Bug]: TestReadValidatesAllRemoteShardsBeforeSending flaky — remote shard read timeout #26045

Closed

Description

@matrix-meow

Problem

TestReadValidatesAllRemoteShardsBeforeSending in pkg/shardservice/service_read_test.go:270 fails intermittently:

Error: "map[1:1]" should have 2 item(s), but has 1
Test elapsed: 60.08s

The test reads from 2 remote shards and expects both to respond. One shard fails to respond within the timeout, resulting in only 1 result in the map.

Recent Occurrences

Date PR/Run Job
2026-07-22 PR #25815 Coverage

Root Cause

Race condition or resource contention on CI runners causes one remote shard's read to exceed the 60s timeout. The shard service test creates multiple mock CN nodes and relies on inter-node communication completing within the timeout.

Suggested Fix

  1. Increase the timeout for CI environments
  2. Or add retry logic for transient shard read failures
  3. Or use synchronization barriers to ensure all shards are ready before the read

Activity

  1. aptend commented on Jul 22, 2026

    @aptend
    Contributor

    Additional reproduction and corrected diagnosis from PR #25843 UT failure:

    The evidence does not support a remote read timing out: the test verifies client.asyncCalls == 0, and the failure occurs before any remote request is sent.

    Observed timing explains the ~60s duration. In the slow setup path, all three replicas are initially allocated to cn1; one shard moves to cn2, then the balance freeze delays the second move to cn3 by about 60 seconds. After setup, the test chooses an incompatible remote CN from asynchronously maintained shard/cache state. Read interleaves Adjust and compatibility validation and returns as soon as the incompatible shard is encountered, so depending on the selected ordering only one shard reaches Adjust, producing map[1:1].

    This is reproducible independently of PR #25843's resource-accounting changes; that PR does not modify pkg/shardservice. Suggested fix: make the test topology and incompatible shard deterministic, avoid relying on asynchronous rebalance/cache ordering, and assert the actual contract that no AsyncSend occurs before compatibility validation succeeds.

  2. self-assigned this
    on Jul 23, 2026
  3. added a commit that references this issue on Jul 23, 2026
    67adb75
  4. added 3 commits that reference this issue on Sep 17, 2026
    bd7e247
    1c76706
    03a471c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions