Repository navigation
ring: honor the heartbeat timeout in shuffle-sharding subrings - #7976
Open
HudsonHumphries wants to merge 1 commit into
Open
HudsonHumphries wants to merge 1 commit into
HudsonHumphries wants to merge 1 commit into
Conversation
Health checks compare heartbeats with the KV store's last update time for the ring key. shuffleShard built subrings without the key, so with the DynamoDB KV store, which returns the zero time for an unknown key, every instance in a subring passed the heartbeat check. Record the KV store's last update time in the subring when it copies the instances, when it is built and at each cache refresh, and compare the subring's heartbeats with that time. Signed-off-by: Hudson Humphries <hudsohum@amazon.com>
HudsonHumphries
force-pushed
the
ring-subring-heartbeat-timeout
branch
from
November 27, 2026 23:01
e03b493 to
bafcfe3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
Health checks compare an instance's heartbeat with the KV store's last update time,
r.KVClient.LastUpdateTime(r.key)(#5026).shuffleShardbuilds the subring without the parent ring'skey, so a subring asks the KV store for a key it has no timestamp for. The DynamoDB client returns the zero time in that case, andIsHeartbeatHealthythen always returns true. So with the DynamoDB KV store, an instance with a stale heartbeat passes health checks in any tenant subring that contains it, while the full ring treats it as unhealthy after the heartbeat timeout. Consul, etcd, memberlist, and the in-memory client returntime.Now()for any key, so only a DynamoDB primary is affected. The testMockClientalso returnstime.Now(), which is why the existing tests pass.Copying
keyinto the subring is not enough. A subring copies its instances from the parent, and the DynamoDB client's last update time moves forward at each poll. A subring that a caller keeps across the next poll would compare heartbeats from the previous poll with the new time, and could reject every instance. So this PR records the KV store's last update time in the subring when it copies the instances, both whenshuffleShardbuilds it and when the subring cache refreshes it. A subring compares its heartbeats with that time, and the full ring keeps reading the KV store. Subrings now also share one existing timing window of the full ring. The DynamoDB client updates its last update time just before the ring applies a poll, and after each successfulCASfrom the same process, such as its own lifecycler's heartbeat, which the ring sees only at the next poll. A check in that window compares the previous heartbeats with the newer time. The full ring recovers when it applies the poll; a subring built or refreshed in the window keeps that pair until its next cache lookup. This PR does not change the window.This affects every caller of shuffle sharding: distributor writes and queries to ingesters, ingester ownership, querier and store-gateway, compactor, ruler, and parquet converter. With Consul, etcd, and memberlist, a subring that a caller keeps now judges health as of the time it copied its instances. Before, its copied heartbeats aged against the wall clock, so the ruler's subrings, which it keeps while it lists rule groups, reported every instance as unhealthy when the listing took longer than the heartbeat timeout. Now an instance that times out while the caller keeps the subring stays in it until the caller's next lookup.
TestRing_ShuffleShard_ShouldHonorHeartbeatTimeoutuses a KV client that, like the DynamoDB client, returns a last update time only for its own key. It checks thatShuffleShardandShuffleShardWithLookbacksubrings exclude an instance with a stale heartbeat. Then the KV store polls again: that instance recovers and another one misses the poll. A subring that the caller kept still uses the heartbeats and the time it copied, and a subring from the cache uses the new ones. The test fails without this change, with onlykeycopied into the subring, and without the cache refresh.This change was prepared with AI assistance; I reviewed and tested every line.
Which issue(s) this PR fixes:
None filed.
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags