Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T 1987 m #1071

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,6 +23,7 @@
package org.infinispan.atomic;

import org.infinispan.AdvancedCache;
import org.infinispan.DecoratedCache;
import org.infinispan.batch.AutoBatchSupport;
import org.infinispan.container.entries.CacheEntry;
import org.infinispan.context.Flag;
Expand Down Expand Up @@ -65,6 +66,7 @@ public class AtomicHashMapProxy<K, V> extends AutoBatchSupport implements Atomic
private static final boolean trace = log.isTraceEnabled();
protected final Object deltaMapKey;
protected final AdvancedCache<Object, AtomicMap<K, V>> cache;
protected final AdvancedCache<Object, AtomicMap<K, V>> cacheForWriting;
protected volatile boolean startedReadingMap = false;
protected final FlagContainer flagContainer;
protected TransactionTable transactionTable;
Expand All @@ -76,6 +78,7 @@ public class AtomicHashMapProxy<K, V> extends AutoBatchSupport implements Atomic

AtomicHashMapProxy(AdvancedCache<?, ?> cache, Object deltaMapKey, FlagContainer flagContainer) {
this.cache = (AdvancedCache<Object, AtomicMap<K, V>>) cache;
this.cacheForWriting = new DecoratedCache<Object, AtomicMap<K, V>>(this.cache, Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_CACHE_LOAD);
this.deltaMapKey = deltaMapKey;
this.batchContainer = cache.getBatchContainer();
this.flagContainer = flagContainer;
Expand Down Expand Up @@ -147,7 +150,7 @@ protected AtomicHashMap<K, V> getDeltaMapForWrite() {
// copy for write
AtomicHashMap<K, V> copy = map == null ? new AtomicHashMap<K, V>(true) : map.copy();
copy.initForWriting();
cache.put(deltaMapKey, copy);
cacheForWriting.put(deltaMapKey, copy);
return copy;
}
}
Expand Down
Expand Up @@ -91,7 +91,7 @@ protected AtomicHashMap<K, V> getDeltaMapForWrite() {
AtomicHashMap<K, V> copy = insertNewMap ? new AtomicHashMap<K, V>(true) : map.copy();
copy.initForWriting();
if (insertNewMap) {
cache.put(deltaMapKey, copy);
cacheForWriting.put(deltaMapKey, copy);
}
return copy;
}
Expand Down
Expand Up @@ -173,15 +173,15 @@ public void commit(LocalTransaction localTransaction, boolean isOnePhase) throws
try {
invoker.invoke(ctx, command);
} catch (Throwable e) {
handleCommitFailure(e, localTransaction);
handleCommitFailure(e, localTransaction, true);
}
} else {
CommitCommand commitCommand = commandCreator.createCommitCommand(localTransaction.getGlobalTransaction());
try {
invoker.invoke(ctx, commitCommand);
txTable.removeLocalTransaction(localTransaction);
} catch (Throwable e) {
handleCommitFailure(e, localTransaction);
handleCommitFailure(e, localTransaction, false);
}
}
}
Expand All @@ -204,9 +204,13 @@ public void rollback(LocalTransaction localTransaction) throws XAException {
}
}

private void handleCommitFailure(Throwable e, LocalTransaction localTransaction) throws XAException {
log.errorProcessing1pcPrepareCommand(e);
if (trace) log.tracef("Couldn't commit 1PC transaction %s, trying to rollback.", localTransaction);
private void handleCommitFailure(Throwable e, LocalTransaction localTransaction, boolean onePhaseCommit) throws XAException {
if (trace) log.tracef("Couldn't commit transaction %s, trying to rollback.", localTransaction);
if (onePhaseCommit) {
log.errorProcessing1pcPrepareCommand(e);
} else {
log.errorProcessing2pcCommitCommand(e);
}
try {
rollbackInternal(localTransaction);
} catch (Throwable e1) {
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/org/infinispan/util/logging/Log.java
Expand Up @@ -494,7 +494,7 @@ public interface Log extends BasicLogger {
void errorRequestingOrApplyingState(@Cause Exception e);

@LogMessage(level = ERROR)
@Message(value = "Error while processing 1PC PrepareCommand", id = 97)
@Message(value = "Error while processing a prepare in a single-phase transaction", id = 97)
void errorProcessing1pcPrepareCommand(@Cause Throwable e);

@LogMessage(level = ERROR)
Expand Down Expand Up @@ -862,4 +862,7 @@ void asyncStoreShutdownTimeoutTooHigh(long configuredAsyncStopTimeout,
@Message(value = "hash's 'rehashWait' attribute has been deprecated. Please use stateTransfer.timeout instead", id = 187)
void hashRehashWaitDeprecated();

@LogMessage(level = ERROR)
@Message(value = "Error while processing a commit in a two-phase transaction", id = 188)
void errorProcessing2pcCommitCommand(@Cause Throwable e);
}