-
Notifications
You must be signed in to change notification settings - Fork 517
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
HDDS-12134. Implement Snapshot Cache lock for OM Bootstrap #7745
base: master
Are you sure you want to change the base?
Conversation
Change-Id: I97e0e0e28736cc51bfb23c45d3750cf721a9689e
Change-Id: Ia5ecb2b863ba2ea2482ac2824aa7b6df98939bb5
this.readLock = lock.readLock(); | ||
this.writeLock = lock.writeLock(); | ||
this.snapshotRefThreadIds = new ConcurrentHashMap<>(); | ||
this.lockTimeout = lockTimeout; |
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.
Let's print an INFO level log here that the snapshot cache lock timeout is set to X ms.
@@ -97,10 +122,21 @@ public void invalidate(UUID key) { | |||
if (v == null) { | |||
LOG.warn("SnapshotId: '{}' does not exist in snapshot cache.", k); | |||
} else { | |||
readLock.lock(); |
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 is in invalidate()
. Should it use writeLock
instead?
while (lockCnt > 0) { | ||
try { | ||
lockReleased.await(lockTimeout, TimeUnit.MILLISECONDS); | ||
} catch (InterruptedException e) { | ||
throw new IOException("Error while waiting for locks to be released.", e); | ||
} |
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.
Does Condition await()
throw InterruptedException
upon timeout? I don't think so. You should check the return value instead if that is the intention.
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.
Can we add more test cases to verify that the states of those new internal structures are behaving as expected upon cache operations? e.g. snapshotRefThreadIds
What changes were proposed in this pull request?
Implementing a lock for this snapshot cache would prevent any newer threads from requesting a snapshot rocksdb handle from the snapshot cache. Thus any operation under this lock will have a consistent view of the entire snapshot.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-12134
How was this patch tested?
Adding unit tests.