>From Wail Alkowaileet <[email protected]>:

Wail Alkowaileet has uploaded this change for review. ( 
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
---
M 
hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
1 file changed, 26 insertions(+), 6 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/89/18289/1

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..f297bc5 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,14 @@
         }
         // if we found a page after all that, go ahead and finish
         if (returnPage != null) {
-            ((CachedPage) returnPage).confiscated.set(true);
+            if (!returnPage.confiscated.compareAndSet(false, true)) {
+                throw new IllegalStateException("Returned page is already 
confiscated");
+            }
             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: 1
Gerrit-Owner: Wail Alkowaileet <[email protected]>
Gerrit-MessageType: newchange

Reply via email to