Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loki: Use a new context to update the ring state after a failed chunk transfer #2330

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/ingester/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ func (i *Ingester) TransferChunks(stream logproto.Ingester_TransferChunksServer)

// Enter PENDING state (only valid from JOINING)
if i.lifecycler.GetState() == ring.JOINING {
if err := i.lifecycler.ChangeState(stream.Context(), ring.PENDING); err != nil {
level.Error(logger).Log("msg", "error rolling back failed TransferChunks", "err", err)
// Create a new context here to attempt to update the state back to pending to allow
// a failed transfer to try again. If we fail to set the state back to PENDING then
// exit Loki as we will effectively be hung anyway stuck in a JOINING state and will
// never join.
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
if err := i.lifecycler.ChangeState(ctx, ring.PENDING); err != nil {
level.Error(logger).Log("msg", "failed to update the ring state back to PENDING after "+
"a chunk transfer failure, there is nothing more Loki can do from this state "+
"so the process will exit...", "err", err)
os.Exit(1)
}
cancel()
}
}()

Expand Down