Navigation Menu

Skip to content

Commit

Permalink
0001305: Possible lock up during extraction. If the max number of loc…
Browse files Browse the repository at this point in the history
…ks are reached on a batch the extract method can hang forever
  • Loading branch information
chenson42 committed Jul 1, 2013
1 parent cb9806f commit d9aaf3f
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -551,10 +551,11 @@ public OutgoingBatch extractOutgoingBatch(ProcessInfo processInfo, Node targetNo
if (currentBatch.getStatus() == Status.NE ||
!isPreviouslyExtracted(currentBatch)) {
int maxPermits = parameterService.getInt(ParameterConstants.CONCURRENT_WORKERS);
String semaphoreKey = streamToFileEnabled ? Long.toString(currentBatch.getBatchId()) : currentBatch.getNodeBatchId();
Semaphore lock = null;
try {
synchronized (locks) {
lock = locks.get(currentBatch.getBatchId());
lock = locks.get(semaphoreKey);
if (lock == null) {
lock = new Semaphore(maxPermits);
locks.put(currentBatch.getBatchId(), lock);
Expand Down Expand Up @@ -592,10 +593,10 @@ public OutgoingBatch extractOutgoingBatch(ProcessInfo processInfo, Node targetNo
}
throw ex;
} finally {
lock.release();
synchronized (locks) {
lock.release();
if (lock.availablePermits() == maxPermits) {
locks.remove(currentBatch.getBatchId());
locks.remove(semaphoreKey);
}
}
}
Expand Down

0 comments on commit d9aaf3f

Please sign in to comment.