-
Notifications
You must be signed in to change notification settings - Fork 753
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
chore: drop guard when acquire lock failed #16616
Conversation
Docker Image for PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @dantengsky and @zhyass)
src/query/service/src/locks/lock_manager.rs
line 214 at r1 (raw file):
))) } else { Ok(Some(Arc::new(guard)))
If the guard
is only returned when the lock is successfully acquired, there's no need to create it at the beginning of the function. Instead, create the guard
immediately after acquiring the lock and just before returning it. This approach is more efficient and clearly ties the guard's lifetime to the lock's acquisition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dantengsky and @zhyass)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dantengsky and @zhyass)
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Drop guard when acquire lock failed, to avoid drop lock twice.
Tests
Type of change
This change is