Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

swamirishi
Copy link
Contributor

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.

Change-Id: I97e0e0e28736cc51bfb23c45d3750cf721a9689e
Change-Id: Ia5ecb2b863ba2ea2482ac2824aa7b6df98939bb5
this.readLock = lock.readLock();
this.writeLock = lock.writeLock();
this.snapshotRefThreadIds = new ConcurrentHashMap<>();
this.lockTimeout = lockTimeout;
Copy link
Contributor

@smengcl smengcl Jan 25, 2025

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();
Copy link
Contributor

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?

Comment on lines +277 to +282
while (lockCnt > 0) {
try {
lockReleased.await(lockTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new IOException("Error while waiting for locks to be released.", e);
}
Copy link
Contributor

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.

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants