Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

meta tags: avoid frequent write locks #1881

Merged
merged 4 commits into from
Aug 24, 2020

Conversation

shanson7
Copy link
Collaborator

This is a branch for a concept change. Right now we need to frequently relinquish the write lock to avoid deadlock scenarios when adding/deleting series within the meta tags component.

As discussed before acquiring the write lock can be very expensive. This change is designed to reduce the number of times we need to acquire the write lock within batching operations.

Open question: is calling getOrgMetaTagIndex under lock a potential deadlock?

@replay
Copy link
Contributor

replay commented Aug 12, 2020

Open question: is calling getOrgMetaTagIndex under lock a potential deadlock?

I don't think so. .getorgMetaTagIndex() only requires the lock on metaTagIdx. This lock only gets acquired by .getOrgMetaTagIndex() and .stop().

getOrgMetaTagIndex() is very straight-forward, it never waits for something else, it will always releases the lock very quickly again.

.stop() is more complex because it waits for the enrichers to shutdown, this shutdown happens by sending a shutdown command through the enricher queue, so if that queue were blocked by the lock on the main index then this would result in a dead lock. but since #1834 it shouldn't be possible anymore for the enricher queue to get blocked on waiting for the main index lock.

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

LGTM

@shanson7
Copy link
Collaborator Author

Could someone merge or take a look?

@Dieterbe Dieterbe changed the title Avoid frequent write locks meta tags: avoid frequent write locks Aug 24, 2020
@Dieterbe Dieterbe merged commit 25fd2ed into grafana:master Aug 24, 2020
@shanson7 shanson7 deleted the avoid_frequent_write_locks branch October 22, 2021 16:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants