Skip to content

Querier: ignore HA replica label matchers in remote read - #7905

Open
cvas22 wants to merge 1 commit into
cortexproject:masterfrom
cvas22:feat/3714-remote-read-strip-ha-replica
Open

cvas22 wants to merge 1 commit into
cortexproject:masterfrom
cvas22:feat/3714-remote-read-strip-ha-replica

Conversation

@cvas22

@cvas22 cvas22 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What this PR does:

When HA deduplication is enabled for a tenant, the distributor removes the HA replica label (__replica__ by default) from the samples it stores. Prometheus adds its external labels, including that replica label, to the matchers of every remote read request. So a Prometheus HA pair that remote writes to Cortex and also remote reads from it gets no data back. The docs worked around this by saying to keep the replica label out of the external labels used for remote read.

As @yeya24 suggested on the issue, I made the querier's remote read handler ignore matchers on the tenant's HA replica label (-distributor.ha-tracker.replica, or the per-tenant override), but only for tenants with HA deduplication enabled (accept_ha_samples). Other tenants behave as before. With multiple tenants in the org ID, the replica labels of every HA-enabled tenant are dropped. If dropping them would leave a query with no matchers at all, the original matchers are kept, so a request never turns into a match-everything query.

RemoteReadHandler now takes the overrides as an extra argument (pkg/api and pkg/cortex/modules.go pass them through). I also updated the HA pair handling guide.

Which issue(s) this PR fixes:
Fixes #3714

Checklist

  • Tests updated
  • Documentation added
  • 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

Notes

  • I added TestRemoteReadHandler_HAReplicaLabel. It covers a tenant with HA deduplication enabled, a tenant without it, and a request where the replica matcher is the only matcher. It passes, as do go vet and go test ./pkg/api/.
  • Locally, the existing TestRemoteReadHandler panics inside gogo protobuf's Marshal (makeslice: cap out of range) under Go 1.27.3. It panics the same way on master without this change, so I'm relying on CI for it.
  • No new flags. This always applies to tenants that have HA deduplication enabled. Happy to put it behind a flag if you'd prefer, as mentioned on the issue.

When HA deduplication is enabled for a tenant the distributor removes the
replica label from the stored series, so a remote read query carrying that
label (Prometheus adds its external labels to the matchers) never matches
anything. Drop matchers on the tenant's HA replica label in the remote read
handler for tenants with HA deduplication enabled.

Fixes cortexproject#3714

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22
cvas22 requested a review from a team as a code owner October 30, 2026 03:23
@cvas22
cvas22 requested a review from danielblando October 30, 2026 03:23

This branch has not been deployed

No deployments
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.

Remote Read Fails when HA dedup is enabled

1 participant