Skip to content

Commit

Permalink
Add assertion message when decrementing cache file (#67561) (#67567)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrx authored Jan 15, 2021
1 parent f92e5d4 commit 3a76ffc
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,21 @@ private boolean assertNoPendingListeners() {

private void decrementRefCount() {
final boolean released = refCounter.decRef();
assert released == false || (evicted.get() && Files.notExists(file));
assert assertRefCounted(released);
}

private boolean assertRefCounted(boolean isReleased) {
final boolean isEvicted = evicted.get();
final boolean notExists = Files.notExists(file);
assert isReleased == false || (isEvicted && notExists) : "fully released cache file should be deleted from disk but got ["
+ "released="
+ isReleased
+ ", evicted="
+ isEvicted
+ ", file not exists="
+ notExists
+ ']';
return true;
}

/**
Expand Down Expand Up @@ -487,7 +501,7 @@ public SortedSet<Tuple<Long, Long>> fsync() throws IOException {
}
}
} finally {
refCounter.decRef();
decrementRefCount();
}
} else {
assert evicted.get();
Expand Down

0 comments on commit 3a76ffc

Please sign in to comment.