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

fix: wait for ongoing queries to finish at close #3030

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

kolesnikovae
Copy link
Collaborator

@kolesnikovae kolesnikovae commented Feb 27, 2024

This change forces block querier to wait until all outgoing queries to finish at Close call. Resolves #2845

The solution does not completely address the issue of block ownership. Since our queries involve stateful processes (block iteration + series iteration + deduplication + merge), and our replicas (ingesters and store gateways) lack awareness of the query context, there is a possibility that a block may be closed while the query is still running. This occurs because replicas may not retain any references to the block in-between query stages.

For instance, if a block is evicted immediately after the list of replica blocks has been returned to the querier, attempting to retrieve profiling data from the block will result in an empty response. This is to be solved in a separate PR. I plan to introduce a graceful period for block eviction. Instead of immediate eviction, the plan is to mark the block and initiate eviction only after a reasonable grace period, such as 5 minutes, has expired.

@kolesnikovae kolesnikovae marked this pull request as ready for review February 27, 2024 05:59
@kolesnikovae kolesnikovae requested a review from a team as a code owner February 27, 2024 05:59
@@ -1627,6 +1639,9 @@ func (b *singleBlockQuerier) SelectMergeByLabels(
if err := b.Open(ctx); err != nil {
return nil, err
}
b.queries.Add(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we should update Open to be a function with a call back like Query(fn ...) error and all of this is handled there.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@kolesnikovae kolesnikovae merged commit 685506f into main Feb 27, 2024
19 checks passed
@kolesnikovae kolesnikovae deleted the fix/inflight-query-close branch February 27, 2024 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in store-gateways
2 participants