import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
this.state = state;
this.semaphore = semaphore;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[state=" + state + ", semaphore=" + semaphore + "]";
+ }
}
private class TransactionManager {
return req;
}
+ private long askWriteTransactionCount = 0;
/*
* This method cannot be synchronized since it waits and must support multiple entries
* by query thread(s) and internal transactions such as snapshot saver
TransactionRequest req = queue(TransactionState.WRITE, semaphore);
try {
- semaphore.acquire();
+ while (true) {
+ boolean acquired = semaphore.tryAcquire(1, TimeUnit.MINUTES);
+ if (!acquired) {
+ if (askWriteTransactionCount < 10) {
+ LOGGER.error("Could not acquire semaphore for askWriteTransaction for TransactionRequest {}", req);
+ LOGGER.error("Current clusters.state.headChangeSetId is {}", clusters.state.headChangeSetId);
+ LOGGER.error("Current clusters.state.transactionId is {}", clusters.state.transactionId);
+ LOGGER.error("Current amount of requests is {}", requests.size());
+ if (requests.size() < 100) {
+ LOGGER.error("Current requests {}", requests);
+ }
+ LOGGER.error("Current transaction state is {}", currentTransactionState);
+ askWriteTransactionCount++;
+ }
+ } else {
+ askWriteTransactionCount = 0;
+ break;
+ }
+ }
} catch (InterruptedException e) {
throw new IllegalAcornStateException(e);
}