[NO ISSUE][TXN] Remove Synchronization on TransactionContext
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Currently the flag indicating if a transaction timed out
synchronizes on the transaction context which makes it
a hot spot when multiple threads on the same transactions
attempting to access that flag. This change removes that
synchronization and replaces it with a volatile variable.
Change-Id: Ib14c07a051d27a5b47c62ff35769670e6ab01fd2
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3579
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/AbstractTransactionContext.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/AbstractTransactionContext.java
index a0944ea..104f9a7 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/AbstractTransactionContext.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/AbstractTransactionContext.java
@@ -41,7 +41,7 @@
private final AtomicLong lastLSN;
private final AtomicInteger txnState;
private final AtomicBoolean isWriteTxn;
- private boolean isTimeout = false;
+ private volatile boolean isTimeout;
protected AbstractTransactionContext(TxnId txnId) {
this.txnId = txnId;
@@ -80,12 +80,12 @@
}
@Override
- public synchronized void setTimeout(boolean isTimeout) {
+ public void setTimeout(boolean isTimeout) {
this.isTimeout = isTimeout;
}
@Override
- public synchronized boolean isTimeout() {
+ public boolean isTimeout() {
return isTimeout;
}