JMX monitoring to detect commits carrying over from previous GC generation can block other threads from committing
Always handle commits as queued even when the lock is free to avoid races between checking the number of available permits and actually acquiring the lock
@@ -253,26 +253,17 @@ public class LockBasedScheduler implements Scheduler {
@Override
public NodeState schedule(@NotNull Commit commit, SchedulerOption... schedulingOptions)
throws CommitFailedException {
- boolean queued = false;
-
try {
commitSemaphoreLogging.warnOnBlockingCommit();
- long queuedTime = -1;
-
- if (commitSemaphore.availablePermits() < 1) {
- queuedTime = System.nanoTime();
+ long queuedTime = System.nanoTime();
stats.onCommitQueued(Thread.currentThread());
- queued = true;
- }
commitSemaphore.acquire();
commitSemaphoreLogging.commitStarted(commit);
try {
- if (queued) {
long dequeuedTime = System.nanoTime();
stats.onCommitDequeued(Thread.currentThread(), dequeuedTime - queuedTime);
- }
long beforeCommitTime = System.nanoTime();
