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

store-gateways: extract read locking during Series #3546

Merged

Conversation

dimitarvdimitrov
Copy link
Contributor

Series() acquires a per-tenant lock when starting to read from a block.
The reason is to prevent a race between addBlock, removeBlock, and
reading from these blocks (for example a block is unloaded after Series()
has already selected it for querying; when accessing this block's
index header we will be using an mmaped file which was deleted from
disk). It needs to release this lock once it has opened an indexReader
because blocks will wait for all open indexReaders to close before
being unloaded.

This PR moves this locking outside of Series() so we can use further
simplify the code in #3540 (see comment)

Signed-off-by: Dimitar Dimitrov dimitar.dimitrov@grafana.com

Series() acquires a per-tenant lock when starting to read from a block.
The reason is to prevent a race between addBlock, removeBlock, and
reading from these blocks (for example a block is unloaded after Series
() has already selected it for querying; when accessing this block's
index header we will be using an mmaped file which was deleted from
disk).

This PR moves this locking outside of Series() so we can use further
simplify the code in PR 3540 (see [comment](#3540 (comment)))

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM!

@dimitarvdimitrov dimitarvdimitrov merged commit 2d484fc into main Nov 28, 2022
@dimitarvdimitrov dimitarvdimitrov deleted the dimitar/move-blocks-locking-into-its-own-function branch November 28, 2022 17:38
masonmei pushed a commit to udmire/mimir that referenced this pull request Dec 16, 2022
Series() acquires a per-tenant lock when starting to read from a block.
The reason is to prevent a race between addBlock, removeBlock, and
reading from these blocks (for example a block is unloaded after Series
() has already selected it for querying; when accessing this block's
index header we will be using an mmaped file which was deleted from
disk).

This PR moves this locking outside of Series() so we can use further
simplify the code in PR 3540 (see [comment](grafana#3540 (comment)))

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
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.

None yet

2 participants