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

Add check to avoid query 5xx when closing tsdb #6616

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

danielblando
Copy link
Contributor

@danielblando danielblando commented Feb 28, 2025

What this PR does:
When an idle tsdb is closing, we mark the userDB as closing (or closed) and ask to close tsdb. While the tsdb is clossing and userDb is still on the ingester list, it can happen that a query request is received by the ingester and it will fail with

open querier for head range head (mint: X, maxt: Y): open querier for block range head (mint: X, maxt: Y): open chunk reader: can't read from a closed head

To avoid this from happening, we are adding a readLock similar to the acquireAppendLock, that will make sure no query request is inflight when closing an idle tsdb and it will return a empty response if the request is received after the tsdb is already closing

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Daniel Deluiggi <[email protected]>
@danielblando danielblando changed the title Add an readLock on ingester Add check to avoid query 5xx when closing tsdb Feb 28, 2025
Signed-off-by: Daniel Deluiggi <[email protected]>
@danielblando danielblando marked this pull request as ready for review February 28, 2025 01:11
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Thanks!

@SungJin1212
Copy link
Contributor

LGTM!

@yeya24 yeya24 merged commit 72bfc29 into cortexproject:master Mar 3, 2025
17 checks passed
@danielblando danielblando deleted the readLock branch March 3, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants