>From Wail Alkowaileet <[email protected]>: Wail Alkowaileet has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18289 )
Change subject: [NO ISSUE] Ensure confiscated pages ...................................................................... [NO ISSUE] Ensure confiscated pages - user model changes: no - storage format changes: no - interface changes: no Details: Simple patch to check if we suffered from confiscating a page that is already confiscated. There's a potetntial of a race condititon here. Change-Id: I771f29d7709d94f0c6683886edcd3a8ab0e9eec2 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18289 Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Reviewed-by: Ian Maxon <[email protected]> --- M hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java 1 file changed, 33 insertions(+), 6 deletions(-) Approvals: Ian Maxon: Looks good to me, approved Jenkins: Verified; Verified Objections: Anon. E. Moose #1000171: Violations found diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java index d47b8e3..53e27a9 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java @@ -1176,7 +1176,7 @@ } private ICachedPage confiscateInner(long dpid, int multiplier) { - ICachedPage returnPage = null; + CachedPage returnPage = null; CachedPage victim = (CachedPage) pageReplacementStrategy.findVictim(multiplier); if (victim == null) { return victim; @@ -1197,7 +1197,7 @@ return null; } returnPage = victim; - ((CachedPage) returnPage).dpid = dpid; + returnPage.dpid = dpid; } else { // Case 2a/b int pageHash = hash(victim.getDiskPageId()); @@ -1240,7 +1240,7 @@ } if (found) { returnPage = victim; - ((CachedPage) returnPage).dpid = dpid; + returnPage.dpid = dpid; } //otherwise, someone took the same victim before we acquired the lock. try again! } finally { bucket.bucketLock.unlock(); @@ -1248,12 +1248,17 @@ } // if we found a page after all that, go ahead and finish if (returnPage != null) { - ((CachedPage) returnPage).confiscated.set(true); + int pinCount = returnPage.pinCount.get(); + if (!returnPage.confiscated.compareAndSet(false, true)) { + throw new IllegalStateException("Returned page is already confiscated"); + } else if (pinCount != 1) { + throw new IllegalStateException("Returned page's pinCount is not 1. It is " + pinCount); + } if (DEBUG) { confiscateLock.lock(); try { - confiscatedPages.add((CachedPage) returnPage); - confiscatedPagesOwner.put((CachedPage) returnPage, Thread.currentThread().getStackTrace()); + confiscatedPages.add(returnPage); + confiscatedPagesOwner.put(returnPage, Thread.currentThread().getStackTrace()); } finally { confiscateLock.unlock(); } -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18289 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Change-Id: I771f29d7709d94f0c6683886edcd3a8ab0e9eec2 Gerrit-Change-Number: 18289 Gerrit-PatchSet: 3 Gerrit-Owner: Wail Alkowaileet <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Ian Maxon <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Wail Alkowaileet <[email protected]> Gerrit-MessageType: merged
