-
Notifications
You must be signed in to change notification settings - Fork 117
Prevent parallel file lock clear #3714
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
b1198bc
267a744
e81f7d2
4d5d581
903d058
9460bfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,8 @@ protected static class FDBDirectoryLock extends Lock { | |
| */ | ||
| private FDBRecordContext closingContext = null; | ||
| private final Object fileLockSetLock = new Object(); | ||
| private boolean clearingLockNow = false; | ||
| private final Object clearingLockNowLock = new Object(); | ||
|
|
||
| private FDBDirectoryLock(final AgilityContext agilityContext, final String lockName, byte[] fileLockKey, int timeWindowMilliseconds) { | ||
| this.agilityContext = agilityContext; | ||
|
|
@@ -210,6 +212,13 @@ private void fileLockCheckNewLock(byte[] val, long nowMillis) { | |
| } | ||
|
|
||
| private void fileLockClearFlushAndClose(boolean isRecovery) { | ||
| synchronized (clearingLockNowLock) { | ||
ScottDugas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ohadzeliger marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Here: this function is being called from too many paths. Until cleanup, this guard is here to avoid recursions | ||
ohadzeliger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (clearingLockNow) { | ||
|
||
| return; | ||
| } | ||
| clearingLockNow = true; | ||
| } | ||
| Function<FDBRecordContext, CompletableFuture<Void>> fileLockFunc = aContext -> | ||
| aContext.ensureActive().get(fileLockKey) | ||
| .thenAccept(val -> { | ||
|
|
@@ -244,6 +253,10 @@ private void fileLockClearFlushAndClose(boolean isRecovery) { | |
| } finally { | ||
| closed = flushed; // allow close retry | ||
| closingContext = null; | ||
| synchronized (clearingLockNowLock) { | ||
| // clearing under lock to avoid spotbugsMain's "Inconsistent synchronization" issue. | ||
|
||
| clearingLockNow = false; | ||
ohadzeliger marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
It sounds like there are some concurrency challenges with
FDBDirectoryLock, it would probably be good to add some tests that try to clear this lock concurrently.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 don't think that there are concurrent calls for this (within the same session) but recursive calls.
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.
ok, in that case, it would be good to have tests that cause this to happen recursively. that might be very hard at the higher levels, but should be doable at this level, right?
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 cannot recreate it and wondering if one the two rebases eliminated the scenario. Switching to draft for a full unit testing ...