This repository was archived by the owner on Mar 6, 2024. It is now read-only.
Fix race condition#9
Open
DarthMax wants to merge 1 commit intomadeintandem:masterfrom
DarthMax:fix_check-then-set-race-condition
Open
Fix race condition#9DarthMax wants to merge 1 commit intomadeintandem:masterfrom DarthMax:fix_check-then-set-race-condition
DarthMax wants to merge 1 commit intomadeintandem:masterfrom
DarthMax:fix_check-then-set-race-condition
Conversation
Author
|
I have noticed, that this might not be the best attempt to solve the issue, as it will not prevent the race condition it multiple distinct programs try to access the same metrics. Furthermore will the the mutex slow down all metric operations, although the race condition is only present when the metric is first accessed. A better approach might be to prevent the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
There is a race condition in the following functions
All function check if the requested metric exist. If not they try to create it, but in the mean time it is possible that an other thread has already created it. This results in the following code to fail repeatedly with a
Tabs::DuplicateMetricErrorAdding a get_or_create_metric function using a shared mutex prevents this race condition.