Skip to content

Commit

Permalink
Tolerate SocketException
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhawkes committed Sep 19, 2023
1 parent ed8f338 commit 5523644
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ibm.tx.jta.impl;

/*******************************************************************************
* Copyright (c) 1997, 2021 IBM Corporation and others.
* Copyright (c) 1997, 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,6 +10,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.tx.jta.impl;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -654,7 +653,7 @@ protected HashMap<XAResource, JTAXAResource> getResourceTable() {
* debug trace is enabled.
*/
protected void checkLPSEnablement() {
if (tc.isEntryEnabled())
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "checkLPSEnablement");

// If this is in a tran enabled for LPS via beginLPSEnabledTx return without
Expand All @@ -665,7 +664,7 @@ protected void checkLPSEnablement() {
return;
}

final boolean debug = tc.isDebugEnabled();
final boolean debug = TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled();

// If we are not debugging and LPS is disabled, return immediately.
if (!debug) {
Expand All @@ -679,7 +678,7 @@ protected void checkLPSEnablement() {
final boolean isLPSEnabled = _transaction._configProvider.getRuntimeMetaDataProvider().isHeuristicHazardAccepted();

if (debug)
Tr.debug(tc, "LPSEnabled", isLPSEnabled);
Tr.debug(tc, "LPSEnabled {0}", isLPSEnabled);

// If this application does not allow the LPS function then ensure that we record
// this fact. This flag will remain false until the first application that does
Expand All @@ -689,7 +688,7 @@ protected void checkLPSEnablement() {
_LPSProhibited = true;
}

if (tc.isEntryEnabled())
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "checkLPSEnablement : LPSEnabled=" + isLPSEnabled + " LPSProhibited=" + _LPSProhibited);
}

Expand Down Expand Up @@ -1170,15 +1169,6 @@ public int distributePrepare(boolean subordinate,
throw new RollbackException();
}

final long startTime = System.currentTimeMillis();

// Prepare the async resources if needed
// Two calls are needed before and after preparing resources to enable ordering if required
if (gotAsyncResources()) {
prePreparePrepareAsyncResources();
prePrepareGetAsyncPrepareResults(startTime);
}

// If we have priority defined resources, sort the list prior to prepare
if (_gotPriorityResourcesEnlisted) {
// Take the one phase resource out of the list while we sort
Expand All @@ -1200,7 +1190,6 @@ public int distributePrepare(boolean subordinate,
if ((i == 0)
&& (_okVoteCount == 0)
&& (optimise) // (!subordinate)
&& !gotAsyncResources()
&& (currResource instanceof ResourceSupportsOnePhaseCommit)
&& (_onePhaseResourceEnlisted == null)) {
// This is the last resource to be processed (i==0), no other resources have voted to commit
Expand Down Expand Up @@ -1266,12 +1255,6 @@ public int distributePrepare(boolean subordinate,
}
} // end for..

// Get the asynchronous results
if (gotAsyncResources()) {
postPreparePrepareAsyncResources();
postPrepareGetAsyncPrepareResults(startTime);
}

// Have we only had one XA_OK vote? If so we can commit the single resource without
// writing any prepare information to the recovery log.

Expand Down Expand Up @@ -1306,26 +1289,6 @@ public int distributePrepare(boolean subordinate,
return _prepareResult;
}

protected boolean gotAsyncResources() {
return false;
}

protected void prePrepareGetAsyncPrepareResults(long startTime) throws HeuristicHazardException, RollbackException, SystemException, HeuristicMixedException {
// Not used in JTM
}

protected void postPrepareGetAsyncPrepareResults(long startTime) throws HeuristicHazardException, RollbackException, SystemException, HeuristicMixedException {
// Not used in JTM
}

protected void prePreparePrepareAsyncResources() throws SystemException, RollbackException {
// Not used in JTM
}

protected void postPreparePrepareAsyncResources() throws SystemException, RollbackException {
// Not used in JTM
}

/**
* Log any prepared resources
*/
Expand Down Expand Up @@ -1667,12 +1630,6 @@ protected boolean distributeOutcome() {
_diagnosticsRequired = false;

try {
final long startTime = System.currentTimeMillis();

if (gotAsyncResources()) {
retryRequired = completeAsyncResources();
}

boolean priorityResourceHasFailed = false;
int failedPriority = 0;
final int resourceCount = _resourceObjects.size();
Expand All @@ -1699,19 +1656,14 @@ protected boolean distributeOutcome() {
if (i < (resourceCount - 1)) {
final JTAResource nextResource = _resourceObjects.get(i + 1);
if (nextResource.getPriority() != failedPriority && (nextResource instanceof JTAXAResource)) {
for (int j = i + 1; j < resourceCount; j++) // Need to retry all other resources on z/os
{
for (int j = i + 1; j < resourceCount; j++) { // Need to retry all other resources on z/os
addToFailedResources(_resourceObjects.get(j));
}
break;
}
}
}
}

if (gotAsyncResources()) {
retryRequired = getAsyncCompletionResults(startTime, retryRequired);
}
} finally {
updateHeuristicOutcome(calculateHeuristicOutcome());

Expand All @@ -1729,17 +1681,6 @@ protected boolean distributeOutcome() {
return retryRequired;
}

@SuppressWarnings("unused")
protected boolean getAsyncCompletionResults(long startTime, boolean retryRequired) {
// TODO Auto-generated method stub
return retryRequired;
}

protected boolean completeAsyncResources() {
// Not used in JTM
return false;
}

/**
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.ibm.tx.jta.XAResourceNotAvailableException;
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;
import com.ibm.websphere.ras.annotation.Trivial;
import com.ibm.ws.Transaction.JTA.JTAResource;
import com.ibm.ws.Transaction.JTA.Util;
import com.ibm.ws.Transaction.JTA.XAReturnCodeHelper;
Expand Down Expand Up @@ -798,6 +799,7 @@ public ClassLoader getRecoveryClassLoader() /* @369064.2A */
return _recoveryClassLoader;
}

@Trivial
public boolean supportsIsSameRM() {
if (tc.isDebugEnabled())
Tr.debug(tc, "supportsIsSameRM: {0}", _supportsIsSameRM);
Expand Down
13 changes: 4 additions & 9 deletions dev/com.ibm.tx.jta/src/com/ibm/tx/jta/impl/XidImpl.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.ibm.tx.jta.impl;

/*******************************************************************************
* Copyright (c) 2002, 2021 IBM Corporation and others.
* Copyright (c) 2002, 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.tx.jta.impl;

import java.io.Serializable;
import java.security.PrivilegedAction;
Expand Down Expand Up @@ -200,11 +199,7 @@ public XidImpl(Xid xid) {
*/
public XidImpl(Xid oldXid, int sequenceNumber) {
if (tc.isEntryEnabled())
Tr.entry(tc, "XidImpl", new Object[] {
oldXid,
sequenceNumber });
if (tc.isDebugEnabled())
Tr.debug(tc, "Creating XID for a resource branch");
Tr.entry(tc, "XidImpl", oldXid, sequenceNumber);

this._formatId = oldXid.getFormatId();
this._gtrid = Util.duplicateByteArray(oldXid.getGlobalTransactionId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,16 @@ public boolean isLoggingForHeuristicReportingEnabled() {
@Override
@Trivial
public boolean isAcceptHeuristicHazard() {
return (Boolean) _props.get("acceptHeuristicHazard");
final Boolean ahh = (Boolean) _props.get("acceptHeuristicHazard");
if (tc.isDebugEnabled())
Tr.debug(tc, "isAcceptHeuristicHazard {0}", ahh);
return ahh;
}

@Override
@Trivial
public boolean isRecoverOnStartup() {
Boolean isRoS = (Boolean) _props.get("recoverOnStartup");
final Boolean isRoS = (Boolean) _props.get("recoverOnStartup");
if (tc.isDebugEnabled())
Tr.debug(tc, "isRecoverOnStartup {0}", isRoS);
if (isRoS && checkpointWaitForConfig()) {
Expand All @@ -459,7 +462,7 @@ public boolean isRecoverOnStartup() {

@Override
public boolean isShutdownOnLogFailure() {
Boolean isSoLF = (Boolean) _props.get("shutdownOnLogFailure");
final Boolean isSoLF = (Boolean) _props.get("shutdownOnLogFailure");
if (tc.isDebugEnabled())
Tr.debug(tc, "isShutdownOnLogFailure set to " + isSoLF);
return isSoLF;
Expand All @@ -468,7 +471,7 @@ public boolean isShutdownOnLogFailure() {
@Override
@Trivial
public boolean isOnePCOptimization() {
Boolean is1PC = (Boolean) _props.get("OnePCOptimization");
final Boolean is1PC = (Boolean) _props.get("OnePCOptimization");
if (tc.isDebugEnabled())
Tr.debug(tc, "OnePCOptimization set to {0}", is1PC);
return is1PC;
Expand All @@ -477,7 +480,7 @@ public boolean isOnePCOptimization() {
@Override
@Trivial
public boolean isForcePrepare() {
Boolean forcePrepare = (Boolean) _props.get("forcePrepare");
final Boolean forcePrepare = (Boolean) _props.get("forcePrepare");
if (tc.isDebugEnabled())
Tr.debug(tc, "forcePrepare set to {0}", forcePrepare);
return forcePrepare;
Expand All @@ -486,7 +489,7 @@ public boolean isForcePrepare() {
@Override
@Trivial
public boolean isWaitForRecovery() {
Boolean isWfR = (Boolean) _props.get("waitForRecovery");
final Boolean isWfR = (Boolean) _props.get("waitForRecovery");
if (tc.isDebugEnabled())
Tr.debug(tc, "isWaitForRecovery {0}", isWfR);
if (!isWfR && checkpointWaitForConfig()) {
Expand Down Expand Up @@ -515,6 +518,7 @@ public ResourceFactory getResourceFactory() {
}

@Override
@Trivial
public RuntimeMetaDataProvider getRuntimeMetaDataProvider() {
return _runtimeMetaDataProvider;
}
Expand Down Expand Up @@ -889,8 +893,12 @@ public int getLogRetryLimit() {
* @see com.ibm.tx.config.ConfigurationProvider#enableLogRetries()
*/
@Override
@Trivial
public boolean enableLogRetries() {
return (Boolean) _props.get("enableLogRetries");
final Boolean elr = (Boolean) _props.get("enableLogRetries");
if (tc.isDebugEnabled())
Tr.debug(tc, "enableLogRetries {0}", elr);
return elr;
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.ibm.tx.jta.embeddable.TransactionSettingsProvider;
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;
import com.ibm.websphere.ras.annotation.Trivial;

/**
*
Expand Down Expand Up @@ -78,6 +79,7 @@ public boolean isClientSideJTADemarcationAllowed() {
* @see com.ibm.tx.config.RuntimeMetaDataProvider#isHeuristicHazardAccepted()
*/
@Override
@Trivial
public boolean isHeuristicHazardAccepted() {
return _serverWideConfigProvider.isAcceptHeuristicHazard();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.ibm.tx.util.TMService;
import com.ibm.websphere.ras.Tr;
import com.ibm.websphere.ras.TraceComponent;
import com.ibm.websphere.ras.annotation.Trivial;
import com.ibm.ws.Transaction.UOWCallback;
import com.ibm.ws.Transaction.UOWCoordinator;
import com.ibm.ws.Transaction.UOWCurrent;
Expand All @@ -75,6 +76,7 @@ public class TransactionManagerService implements ExtendedTransactionManager, Tr
private final AtomicBoolean isStarted = new AtomicBoolean();
boolean xaFlowCallbacksInitialised;

@Trivial
private EmbeddableWebSphereTransactionManager etm() {
return EmbeddableTransactionManagerFactory.getTransactionManager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import componenttest.annotation.ExpectedFFDC;
import componenttest.custom.junit.runner.FATRunner;

@AllowedFFDC(value = { "com.ibm.tx.jta.ut.util.AlreadyDumpedException", "javax.transaction.SystemException", "javax.transaction.xa.XAException", "java.io.IOException", "java.io.EOFException", "org.apache.cxf.binding.soap.SoapFault", "javax.xml.stream.XMLStreamException" })
@AllowedFFDC(value = { "com.ibm.tx.jta.ut.util.AlreadyDumpedException", "javax.transaction.SystemException", "javax.transaction.xa.XAException", "java.io.IOException", "java.io.EOFException", "org.apache.cxf.binding.soap.SoapFault", "javax.xml.stream.XMLStreamException", "java.net.SocketException" })
@RunWith(FATRunner.class)
public class MultiRecoveryTest3 extends MultiRecoveryTest {

Expand Down

0 comments on commit 5523644

Please sign in to comment.