Skip to content

Commit

Permalink
logging permits again
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Sep 14, 2024
1 parent 85e3f46 commit a9203b1
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.support.ContextPreservingActionListener;
Expand Down Expand Up @@ -149,13 +150,16 @@ private Releasable acquireAll(final long timeout, final TimeUnit timeUnit) throw
}
if (semaphore.tryAcquire(TOTAL_PERMITS, timeout, timeUnit)) {
final Long acquireId = -permitsSeqNo.getAndIncrement();
permitsTracking.put(acquireId, threadPool.absoluteTimeInMillis() + ", " + Thread.currentThread());
// logger.info("--> [{}] acquiredAll [{}]", shardId, acquireId);
// permitsTracking.put(
// acquireId,
// Thread.currentThread() + "\n" + ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace())
// );
logger.info("--> [{}] acquiredAll [{}]", shardId, acquireId);
return Releasables.releaseOnce(() -> {
assert semaphore.availablePermits() == 0;
semaphore.release(TOTAL_PERMITS);
permitsTracking.remove(acquireId);
// logger.info("--> [{}] released all [{}]", shardId, acquireId);
// permitsTracking.remove(acquireId);
logger.info("--> [{}] released all [{}]", shardId, acquireId);
});
} else {
throw new ElasticsearchTimeoutException("timeout while blocking operations after [" + new TimeValue(timeout, timeUnit) + "]");
Expand Down Expand Up @@ -268,12 +272,15 @@ private Releasable acquire() throws InterruptedException {
assert Thread.holdsLock(this);
if (semaphore.tryAcquire(1, 0, TimeUnit.SECONDS)) { // the un-timed tryAcquire methods do not honor the fairness setting
final Long acquireId = permitsSeqNo.getAndIncrement();
permitsTracking.put(acquireId, threadPool.absoluteTimeInMillis() + ", " + Thread.currentThread());
// logger.info("--> [{}] acquired [{}]", shardId, acquireId);
// permitsTracking.put(
// acquireId,
// Thread.currentThread() + "\n" + ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace())
// );
logger.info("--> [{}] acquired [{}]", shardId, acquireId);
return Releasables.releaseOnce(() -> {
semaphore.release();
permitsTracking.remove(acquireId);
// logger.info("--> [{}] released [{}]", shardId, acquireId);
// permitsTracking.remove(acquireId);
logger.info("--> [{}] released [{}]", shardId, acquireId);
});
} else {
// this should never happen, if it does something is deeply wrong
Expand Down

0 comments on commit a9203b1

Please sign in to comment.