-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
improve mutex locking when writing index in boltdb-shipper #5830
improve mutex locking when writing index in boltdb-shipper #5830
Conversation
The code of this PR would be helpful. After the PR is merged, we will release boltdb-shipper again to observe the optimization effect. |
I am waiting for this PR to be merged, please help to speed up the merge of this PR. |
@sandeepsukhani Thanks for the quick response |
It would be great if this PR could be merged in the 2.5 release. |
@cyriltovena Please help to review this PR as soon as possible,thanks! |
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.
LGTM
cla stuck, will see if reopening PR fixes it. |
ok bool | ||
) | ||
|
||
var err error | ||
db, ok = lt.dbs[name] | ||
if !ok { |
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.
I might invert this if
so that the read-lock and write-lock cases look the same. Also this would outdent the remainder of the function which is more idiomatic Go.
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.
Sorry, I merged the PR already. Will open a follow-up PR.
ok bool | ||
) | ||
|
||
var err error |
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.
This could be moved inside the scope where it is used.
What this PR does / why we need it:
We currently take an exclusive lock for each index write to check whether desired index file exists which can cause contention. This PR improves the code by checking index file exists with a read lock and then takes a write lock to create if it does not exist.