Skip to content

Ring: read one DynamoDB row for self-only ingester readiness - #7984

Merged
yeya24 merged 5 commits into
cortexproject:masterfrom
HudsonHumphries:ring/readiness-single-row
Dec 4, 2026
Merged

yeya24 merged 5 commits into
cortexproject:masterfrom
HudsonHumphries:ring/readiness-single-row

Conversation

@HudsonHumphries

@HudsonHumphries HudsonHumphries commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

With -ingester.readiness-check-ring-health=false, the readiness check looks only at the instance's own ring entry. But it still reads the whole ring from the KV store to get
that entry. With the DynamoDB KV store, each readiness probe is then a Query of every row of the ring key until the instance is ready.

This PR makes that check read one row:

  • kv.Client gets a GetInstance method. The DynamoDB client implements it with a sort-key condition on the Query, and the read does not update the ring that the client
    caches. Consul, etcd and memberlist keep the ring as one value, so they read the whole value as before.
  • The lifecycler uses it in the self-only check and measures the heartbeat age from the time of the check. A one-row read does not refresh the DynamoDB client's
    LastUpdateTime, which can then be older, or unset, and would make an expired heartbeat look healthy.

The readiness decision does not change: same entry, same state and heartbeat checks. The check with readiness_check_ring_health enabled still reads the whole ring.

kv.Client has a new method, so an implementation outside this repository must add it.

On a DynamoDB test table with 952 ring rows, the whole-ring read consumed 306.5 read capacity units and the one-row read 0.5.

I used an AI coding assistant for much of this change, and I reviewed and tested it.

Which issue(s) this PR fixes:
N/A

Checklist

  • Tests updated
  • Documentation added (not needed: no flag or config change)
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
  • docs/configuration/v1-guarantees.md updated if this PR introduces experimental flags

When readiness only checks the local ingester, query DynamoDB with the
ring key and the ingester ID. Use the time of that read to check heartbeat
age. Keep the whole-ring read for the full readiness check and as a
fallback for stores without a single-instance lookup.

Exercise the query keys, fallback, and readiness decisions in unit tests.

Signed-off-by: Hudson Humphries <hudsohum@amazon.com>
@HudsonHumphries
HudsonHumphries requested a review from a team as a code owner December 3, 2026 00:45
Signed-off-by: Hudson Humphries <hudsohum@amazon.com>
Comment thread pkg/ring/kv/client.go Outdated
// InstanceGetter is implemented by clients that can read one instance of a
// multi-key value, such as one member of a ring, without reading the others.
// Call it through GetInstance.
type InstanceGetter interface {

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.

I dont know if this is the best approach.

I feel this should be related to https://github.com/cortexproject/cortex/blob/master/pkg/ring/kv/codec/multikey.go#L7

Any implementation that is running with multiKey would be able to have a GetInstance call.

Maybe the kv client can check and fallback to Get if not multkey codec.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I updated to use kv client,

  • It follows how LastUpdateTime was added in Add dynamodb multikey kv #5026. The DynamoDB client reads the one row and decodes it with DecodeMultiKey. Consul, etcd and memberlist return Get. InstanceGetter and the helper are gone.
  • I did not key it on the codec. The ring value is a codec.MultiKey on every store, but only DynamoDB stores one row per ID, so only the store's client can tell.
  • GetInstance returns no time now. The self-only check passes time.Now() to IsReady after the read, because a one-row read does not refresh LastUpdateTime. The other stores already return time.Now() there.

lmk if you think it should be done a different way

Every KV client now implements GetInstance. The DynamoDB client stores a
MultiKey value as one row per ID and reads the one row. Consul, etcd and
memberlist keep the value as one entry and read the whole value, like Get.
This replaces the optional InstanceGetter interface and the kv.GetInstance
helper.

GetInstance returns no time, so its signature matches Get. The self-only
readiness check measures the heartbeat age from the time of the check.

Signed-off-by: Hudson Humphries <hudsohum@amazon.com>
The DynamoDB client also sets LastUpdateTime after a CAS and a watch poll,
not only after a read of the whole ring. A one-row read returns at most the
one entry, with the type that Get returns.

Signed-off-by: Hudson Humphries <hudsohum@amazon.com>

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

Thanks

…ngle-row

Conflict in CHANGELOG.md: keep both new entries.

Signed-off-by: Hudson Humphries <hudsohum@amazon.com>

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

Great

@yeya24
yeya24 merged commit 1cf568a into cortexproject:master Dec 4, 2026
74 of 75 checks passed
HudsonHumphries added a commit to HudsonHumphries/cortex that referenced this pull request Dec 5, 2026
Brings in the self-only ingester readiness read (cortexproject#7984) and the
READONLY fix for token renewal (cortexproject#7982), which merged after this
branch was made.
HudsonHumphries added a commit to HudsonHumphries/cortex that referenced this pull request Dec 5, 2026
Brings in the self-only ingester readiness read (cortexproject#7984) and the
READONLY fix for token renewal (cortexproject#7982), which merged after this
branch was made.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants