Skip to content

test(store): a settled cross-shard read's budget waits for the reads it cut off - #2379

Merged
thesyncim merged 2 commits into
mainfrom
fix/shard-budget-counts-wait-for-cut-off-reads
Nov 24, 2026
Merged

thesyncim merged 2 commits into
mainfrom
fix/shard-budget-counts-wait-for-cut-off-reads

Conversation

@thesyncim

@thesyncim thesyncim commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Problem
CallBridges.Claim and CallResources.Select read every shard at once and return as soon as one shard's answer settles the read; the other shards' reads are cancelled and not waited for (answeringShards, #2256). TestABridgeIsClaimedOnceFromAnyShardAndSweptOnceExpired and TestCallResourceQueryBudgets counted statements straight after the call returned, so in the sharded suite the cut-off read was sometimes not counted yet (1 for 2), and then landed in the next count (Pin, 3 for 2). Main's store job went red on it.

Fix

  • The two budgets that wrap a settled read count with countSettledReads, which waits, up to a deadline, until a statement from every shard is in, then counts. No assertion changes: each still expects one statement a shard.
  • The code stays as it is. Waiting in answeringShards for the cancelled reads was tried and brings back the stall AI-3506: one unreachable shard no longer stops sessions and bridges on the others #2256 removed: pgdriver lets go of a read on a host that accepts and never answers only at its deadline, not on cancel, and TestACallPlacedOnAShardThatAnswersIsFoundWithoutWaitingOnOneThatDoesNot failed with it (2.0s against a 2s bound).

Tests

  • On main, -count=30 of the two tests in the sharded suite failed in at least five runs (the kept output does not hold the full count): Select expected 2, got 1, followed by Pin expected 2, got 3, and Claim asks every shard once expected 2, got 1. With the change, -count=30 of both tests in both store suites passed.
  • A mutant that reads only this shard in answeringShards fails both budgets ("a statement from every shard" never satisfied).

…it cut off

Claim and CallResources.Select return once one shard's answer settles them and
do not wait for the other shards' reads (#2256). Their query budgets counted
straight after the call returned, so the cut-off read was sometimes not in yet
(1 for 2) and then landed in the next count (3 for 2). The budget now waits, up
to a deadline, for one statement from every shard before it counts.
@thesyncim
thesyncim marked this pull request as ready for review November 24, 2026 13:15
@thesyncim thesyncim added the data-layer-review: ready Data layer review fix: passed automated review, merges cleanly, ready for a human review label Nov 24, 2026

@martinmitrevski martinmitrevski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No findings at a48efe8.

Checked and sound:

  • answeringShards runs one statement per shard. bun calls afterQuery even when the context is cancelled, so a read the answer cut off is still counted.
  • Waiting for one statement per shard therefore keeps the exact Equal strict. An extra statement still fails it, and a missing shard read fails at the deadline.
  • Pin uses everyShard, so nothing from the Select count spills into it.

@thesyncim
thesyncim merged commit 4ee1228 into main Nov 24, 2026
15 of 16 checks passed
@thesyncim
thesyncim deleted the fix/shard-budget-counts-wait-for-cut-off-reads branch November 24, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-layer-review: ready Data layer review fix: passed automated review, merges cleanly, ready for a human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants