>From Wail Alkowaileet <[email protected]>:
Wail Alkowaileet has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17540 )
Change subject: [ASTERIXDB-3187][STO] Clear ByteBuffer position/limit of
confiscated pages
......................................................................
[ASTERIXDB-3187][STO] Clear ByteBuffer position/limit of confiscated pages
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
Confiscated pages could have posititon/limit different
from 0/capacity(), respectively. This patch ensures
the ByteBuffers of confiscated pages are cleared
before returned to LSM bulk loaders
Change-Id: I41081562479412096f812b330111a40e8e6c43a9
---
M
hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
1 file changed, 34 insertions(+), 37 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/40/17540/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 5578d27..93ec8f3 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
@@ -233,13 +233,9 @@
try {
cPage = bucket.cachedPage;
while (cPage != null) {
- if (DEBUG) {
- assert bucket.cachedPage != bucket.cachedPage.next;
- }
+ assert !DEBUG || bucket.cachedPage != bucket.cachedPage.next;
if (cPage.dpid == dpid) {
- if (DEBUG) {
- assert !cPage.confiscated.get();
- }
+ assert !DEBUG || !cPage.confiscated.get();
cPage.pinCount.incrementAndGet();
return cPage;
}
@@ -321,9 +317,7 @@
bucket.bucketLock.unlock();
}
- if (DEBUG) {
- assert !victim.confiscated.get();
- }
+ assert !DEBUG || !victim.confiscated.get();
return victim;
}
int victimHash = hash(victim.dpid);
@@ -360,9 +354,7 @@
} finally {
bucket.bucketLock.unlock();
}
- if (DEBUG) {
- assert !victim.confiscated.get();
- }
+ assert !DEBUG || !victim.confiscated.get();
return victim;
} else {
/*
@@ -412,9 +404,7 @@
victimBucket.bucketLock.unlock();
bucket.bucketLock.unlock();
}
- if (DEBUG) {
- assert !victim.confiscated.get();
- }
+ assert !DEBUG || !victim.confiscated.get();
return victim;
}
}
@@ -424,9 +414,7 @@
if (cPage.dpid == dpid) {
cPage.pinCount.incrementAndGet();
victim.pinCount.decrementAndGet();
- if (DEBUG) {
- assert !cPage.confiscated.get();
- }
+ assert !DEBUG || !cPage.confiscated.get();
break;
}
cPage = cPage.next;
@@ -1077,9 +1065,7 @@
if (curr == victim) {
// we found where the victim
// resides in the hash table
- if (DEBUG) {
- assert curr != curr.next;
- }
+ assert !DEBUG || curr != curr.next;
if (prev == null) {
// if this is the first page in the bucket
bucket.cachedPage = curr.next;
@@ -1087,9 +1073,7 @@
// if it isn't we need to make the previous
// node point to where it should
prev.next = curr.next;
- if (DEBUG) {
- assert prev.next != prev;
- }
+ assert !DEBUG || prev.next != prev;
}
curr.next = null;
found = true;
@@ -1106,9 +1090,7 @@
}
synchronized (cachedPages) {
ICachedPageInternal old = cachedPages.set(victim.cpid, null);
- if (DEBUG) {
- assert old == victim;
- }
+ assert !DEBUG || old == victim;
}
return true;
}
@@ -1143,7 +1125,9 @@
}
private ICachedPage confiscatePage(long dpid, int multiplier) throws
HyracksDataException {
- return getPageLoop(dpid, multiplier, true);
+ ICachedPage page = getPageLoop(dpid, multiplier, true);
+ page.getBuffer().clear();
+ return page;
}
private ICachedPage confiscateInner(long dpid, int multiplier) {
@@ -1152,9 +1136,7 @@
if (victim == null) {
return victim;
}
- if (DEBUG) {
- assert !victim.confiscated.get();
- }
+ assert !DEBUG || !victim.confiscated.get();
// find a page that would possibly be evicted anyway
// Case 1 from findPage()
if (victim.dpid < 0) { // new page
@@ -1187,9 +1169,7 @@
if (!victim.pinCount.compareAndSet(0, 1)) {
break;
}
- if (DEBUG) {
- assert curr != curr.next;
- }
+ assert !DEBUG || curr != curr.next;
if (prev == null) {
// if this is the first page in the bucket
bucket.cachedPage = curr.next;
@@ -1197,9 +1177,7 @@
// node point to where it should
} else {
prev.next = curr.next;
- if (DEBUG) {
- assert prev.next != prev;
- }
+ assert !DEBUG || prev.next != prev;
}
curr.next = null;
found = true;
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17540
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: I41081562479412096f812b330111a40e8e6c43a9
Gerrit-Change-Number: 17540
Gerrit-PatchSet: 1
Gerrit-Owner: Wail Alkowaileet <[email protected]>
Gerrit-MessageType: newchange