Fixed race condition causing queries to fail right after querier startup with the "empty ring" error #4068
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:
We just experienced a query failing with "empty ring" right after the querier has started. This is caused by the fact that the querier worker may connect to the query-frontend (or query-scheduler) and get a job before the ring client has initialised its state (which is when the
WatchKey()
callback is called for the first time).In this PR I'm proposing to fix it introducing a
starting()
function to theRing
client service and read the initial read state while in the starting phase. Due to how dependencies are started and given the ring is a dependency of the querier, the ring is started before the querier worker service and this guarantees that, when the querier worker will be started, the ring has already initialised.I've also made a change to fast fail the ring if an error occurs while fetching the initial ring state (ring key not existing is still OK). I think having a Cortex service fast failing if unable to talk to the ring backend should be fine (and probably a nice to have property), but if you foresee any potential issue I can change it.
Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]