Skip to content

Follow up of #4068: Fixed race condition causing queries to fail right after querier startup with the "empty ring" error + Memberlist #4798

Closed
@alanprot

Description

@alanprot

When using Memberlist, we are starting the ring service before the ring information is propagated causing query failing with "empty ring" right after the querier has started.

The ring services tries to make sure the ring data is populated before starting the other modules (see #4068) but this is not working well with memberlist as it's service is only joining the cluster when is already running:

func (m *KV) running(ctx context.Context) error {
// Join the cluster, if configured. We want this to happen in Running state, because started memberlist
// is good enough for usage from Client (which checks for Running state), even before it connects to the cluster.
if len(m.cfg.JoinMembers) > 0 {
// Lookup SRV records for given addresses to discover members.

The comment about is good enough for usage from Client (which checks for Running state), even before it connects to the cluster. seems to not hold true as the service states flips to running before calling the running function:

b.mustSwitchState(Starting, Running, func() {
// unblock waiters waiting for Running state
close(b.runningWaitersCh)
b.notifyListeners(func(l Listener) { l.Running() }, false)
})
stoppingFrom = Running
if b.runningFn != nil {
err = b.runningFn(b.serviceContext)
}

When this happens we can also see this log line (which should not happen):

level.Info(r.logger).Log("msg", "ring doesn't exist in KV store yet")

To Reproduce
Use memberlist and restart queriers.

Expected behavior
Queriers should start to process request only after the ring information is propagated.

Environment:

  • Infrastructure: [e.g., Kubernetes, bare-metal, laptop]
  • Deployment tool: [e.g., helm, jsonnet]

Storage Engine

  • Blocks
  • Chunks

Additional Context

Metadata

Metadata

Assignees

No one assigned

    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