Skip to content

Commit

Permalink
TEIID-3106 preventing a tight loop
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 9, 2014
1 parent 3ebe848 commit d42bc03
Showing 1 changed file with 13 additions and 10 deletions.
Expand Up @@ -106,11 +106,8 @@ public void run() {
impl.cleaning.set(true);
try {
long evicted = impl.doEvictions(impl.maxProcessingBytes, false, impl.initialEvictionQueue);
if (evicted != 0) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Asynch eviction run", evicted, impl.reserveBatchBytes.get(), impl.maxReserveBytes, impl.activeBatchBytes.get()); //$NON-NLS-1$
}
continue;
if (evicted != 0 && LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.TRACE)) {
LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Asynch eviction run", evicted, impl.reserveBatchBytes.get(), impl.maxReserveBytes, impl.activeBatchBytes.get()); //$NON-NLS-1$
}
} catch (Throwable t) {
LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, t, "Exception during cleaning run"); //$NON-NLS-1$
Expand Down Expand Up @@ -868,14 +865,20 @@ long doEvictions(long maxToFree, boolean checkActiveBatch, LrfuEvictionQueue<Cac
boolean evicted = true;
try {
evicted = evict(ce);
if (!evicted && !checkActiveBatch) {
//there's not much more that we should do as the head is being evicted by someone else
break;
}
} catch (Throwable e) {
LogManager.logError(LogConstants.CTX_BUFFER_MGR, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30017, ce.getId() ));
} finally {
synchronized (ce) {
if (evicted && memoryEntries.remove(ce.getId()) != null) {
freed += ce.getSizeEstimate();
activeBatchBytes.addAndGet(-ce.getSizeEstimate());
queue.remove(ce); //ensures that an intervening get will still be cleaned
if (evicted) {
synchronized (ce) {
if (memoryEntries.remove(ce.getId()) != null) {
freed += ce.getSizeEstimate();
activeBatchBytes.addAndGet(-ce.getSizeEstimate());
queue.remove(ce); //ensures that an intervening get will still be cleaned
}
}
}
}
Expand Down

0 comments on commit d42bc03

Please sign in to comment.