Add a resource group lock to avoid duplicated creation#4318
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a per-resource-group lock mechanism to check_or_create_resource_group to prevent race conditions when multiple threads attempt to create the same Azure resource group simultaneously. This can happen when LISA runs for the first time with certain notifier configurations that trigger shared resource group creation from multiple threads.
Changes:
- Introduces a two-level locking scheme: a global lock (
_global_resource_group_creation_lock) to safely manage a dictionary of per-resource-group locks (_global_resource_group_locks), enabling fine-grained concurrency control per resource group name. - Refactors the existence check into a helper function
_check_existence()and restructures the creation flow to check-then-create under the per-resource-group lock.
You can also share your feedback on Copilot code review. Take the survey.
a36264a to
5f5813c
Compare
LiliDeng
approved these changes
Mar 6, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If it is the first time to run LISA and the runbook has lsgstorage notifier, there will be a possibility to create the same lisa shared resource group at the same time. This PR is to add a lock to prevent it from happening.