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

fix: remove EventSemaphore.clear() #29722

Closed
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/com.ibm.tx.jta/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ instrument.disabled: true
com.ibm.ws.kernel.boot.common;version=latest,\
com.ibm.ws.kernel.service;version=latest,\
com.ibm.ws.logging.core,\
com.ibm.wsspi.org.osgi.service.component.annotations;version=latest,\
com.ibm.ws.org.osgi.annotation.versioning;version=latest,\
com.ibm.ws.recoverylog;version=latest,\
com.ibm.ws.resource;version=latest
Expand Down
62 changes: 8 additions & 54 deletions dev/com.ibm.tx.jta/src/com/ibm/tx/jta/impl/EventSemaphore.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 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:
Expand All @@ -17,65 +17,19 @@
* event semaphore.
* <p>
* This is specifically to handle the situation where the event may have been
* posted before the wait method is called. This behaviour is not supported by
* posted before the wait method is called. This behaviour is not supported by
* the existing wait and notify methods.
*/
public final class EventSemaphore
{
public final class EventSemaphore {
boolean _posted;

/**
* Default Constructor
*/
public EventSemaphore() {}


/**
* Creates the event semaphore in the given posted state.
*
* @param posted Indicates whether the semaphore should be posted.
*/
EventSemaphore( boolean posted )
{
_posted = posted;
}


/**
* Waits for the event to be posted.
* <p>
* If the event has already been posted, then the operation returns immediately.
*
* @exception InterruptedException
* The wait was interrupted.
*/
synchronized public void waitEvent() throws InterruptedException
{
while ( !_posted )
{
wait();
}
public synchronized void waitEvent() throws InterruptedException {
while (!_posted)
wait();
}


/**
* Posts the event semaphore.
* <p>
* All waiters are notified.
*/
public synchronized void post()
{
if ( !_posted )
notifyAll();
public synchronized void post() {
_posted = true;
}


/**
* Clears a posted event semaphore.
*/
public synchronized void clear()
{
_posted = false;
notifyAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1429,8 +1429,6 @@ protected void recoveryFailed(Throwable t) {
if (!_recoveryCompleted) {
_recoveryCompleted = true;
_recoveryInProgress.post();

signalRecoveryComplete();
}

if (_failureScopeController.localFailureScope()) {
Expand Down Expand Up @@ -1466,10 +1464,6 @@ protected void recoveryFailed(Throwable t) {
Tr.exit(tc, "recoveryFailed");
}

protected void signalRecoveryComplete() {
// Not used in JTM
}

// Checks to see if shutdown processing has begun. If it has, this method causes signals recovery
// processing earlier than normal (ie before it would naturally have completed). Callers must
// examine the boolean return value and not proceed with recovery if its true.
Expand Down
110 changes: 31 additions & 79 deletions dev/com.ibm.tx.jta/src/com/ibm/tx/jta/util/TxTMHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

package com.ibm.tx.jta.util;

import static org.osgi.service.component.annotations.ReferenceCardinality.OPTIONAL;
import static org.osgi.service.component.annotations.ReferencePolicy.DYNAMIC;

import javax.transaction.NotSupportedException;
import javax.transaction.Status;
import javax.transaction.SystemException;
Expand All @@ -21,11 +24,13 @@

import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.annotations.Reference;

import com.ibm.tx.TranConstants;
import com.ibm.tx.config.ConfigurationProvider;
import com.ibm.tx.config.ConfigurationProviderManager;
import com.ibm.tx.jta.TransactionManagerFactory;
import com.ibm.tx.jta.XAResourceFactory;
import com.ibm.tx.jta.impl.EventSemaphore;
import com.ibm.tx.jta.impl.LocalTIDTable;
import com.ibm.tx.jta.impl.RecoveryManager;
Expand All @@ -46,7 +51,6 @@
import com.ibm.ws.recoverylog.spi.RecoveryLogFactory;
import com.ibm.ws.uow.UOWScopeCallback;
import com.ibm.ws.uow.UOWScopeCallbackAgent;
import com.ibm.wsspi.resource.ResourceFactory;
import com.ibm.wsspi.tx.UOWEventListener;

import io.openliberty.checkpoint.spi.CheckpointPhase;
Expand All @@ -71,13 +75,13 @@ public class TxTMHelper implements TMService, UOWScopeCallbackAgent {
protected String _recoveryIdentity;
protected String _recoveryGroup;

private static boolean _xaResourceFactoryReady;
private boolean _xaResourceFactoryReady;
private boolean _waitForRecovery;
private boolean _tmsReady;
private static boolean _recoveryLogFactoryReady;
private static RecoveryLogFactory _recoveryLogFactory;
private static boolean _recoveryLogServiceReady;
private static boolean _requireDataSourceActive;
private boolean _recoveryLogFactoryReady;
private RecoveryLogFactory _recoveryLogFactory;
private boolean _recoveryLogServiceReady;
private boolean _requireDataSourceActive;
private boolean _localRecoveryFailed;

protected static BundleContext _bc;
Expand All @@ -96,17 +100,14 @@ public TxTMHelper() {
TMHelper.setTMService(this);
}

protected TxTMHelper(boolean dummy) {
if (tc.isDebugEnabled())
Tr.debug(tc, "NOT Adding shutdown hook");
TMHelper.setTMService(this);
}
//recoveryLogService=com.ibm.ws.recoverylog.spi.RecLogServiceImpl; \
//recoveryLogFactory=com.ibm.ws.recoverylog.spi.RecoveryLogFactory; \
//

/**
* Called by DS to inject reference to Config Provider
*
* @param p
*/
//<reference name="recoveryLogService" cardinality="1..1" interface="com.ibm.ws.recoverylog.spi.RecLogServiceImpl" bind="setRecoveryLogService" unbind="unsetRecoveryLogService"/>
//<reference name="recoveryLogFactory" cardinality="1..1" interface="com.ibm.ws.recoverylog.spi.RecoveryLogFactory" bind="setRecoveryLogFactory" unbind="unsetRecoveryLogFactory"/>

@Reference(unbind = "shutdown")
protected void setConfigurationProvider(ConfigurationProvider p) {
if (tc.isEntryEnabled())
Tr.entry(tc, "setConfigurationProvider", p);
Expand All @@ -128,34 +129,8 @@ protected void setConfigurationProvider(ConfigurationProvider p) {
Tr.exit(tc, "setConfigurationProvider");
}

protected void unsetConfigurationProvider(ConfigurationProvider p) {
if (tc.isEntryEnabled())
Tr.entry(tc, "unsetConfigurationProvider", p);
if (p != null) {
// Used to test whether we are logging to an RDBMS
// configured
if (!p.isSQLRecoveryLog()) {
if (tc.isDebugEnabled())
Tr.debug(tc, "Logging to a filesytem, shutdown now");
// Where transactions are logged to an RDBMS, shutdown is driven at the point where
// the DataSource Service is being unset.
try {
shutdown();
} catch (Exception e) {
FFDCFilter.processException(e, "com.ibm.tx.jta.util.TxTMHelper.unsetConfigurationProvider", "138", this);
}
}
}
if (tc.isEntryEnabled())
Tr.exit(tc, "unsetConfigurationProvider");
}

/**
* Called by DS to inject reference to XaResource Factory
*
* @param ref
*/
protected void setXaResourceFactory(ServiceReference<ResourceFactory> ref) {
@Reference(cardinality = OPTIONAL, policy = DYNAMIC)
protected void setXaResourceFactory(ServiceReference<XAResourceFactory> ref) {
if (tc.isEntryEnabled())
Tr.entry(tc, "setXaResourceFactory", "ref " + ref);

Expand All @@ -174,16 +149,12 @@ protected void setXaResourceFactory(ServiceReference<ResourceFactory> ref) {
Tr.exit(tc, "setXaResourceFactory");
}

protected void unsetXaResourceFactory(ServiceReference<ResourceFactory> ref) {
protected void unsetXaResourceFactory(ServiceReference<XAResourceFactory> ref) {
if (tc.isDebugEnabled())
Tr.debug(tc, "unsetXaResourceFactory, ref " + ref);
}

/**
* Called by DS to inject reference to RecoveryLog Factory
*
* @param ref
*/
@Reference
public void setRecoveryLogFactory(RecoveryLogFactory fac) {
if (tc.isEntryEnabled())
Tr.entry(tc, "setRecoveryLogFactory, factory: " + fac, this);
Expand All @@ -202,16 +173,7 @@ public void setRecoveryLogFactory(RecoveryLogFactory fac) {
Tr.exit(tc, "setRecoveryLogFactory");
}

public void unsetRecoveryLogFactory(RecoveryLogFactory fac) {
if (tc.isDebugEnabled())
Tr.debug(tc, "unsetRecoveryLogFactory, factory: " + fac, this);
}

/**
* Called by DS to inject reference to RecoveryLog Service
*
* @param ref
*/
@Reference
public void setRecoveryLogService(ServiceReference<RecLogServiceImpl> ref) {
if (tc.isEntryEnabled())
Tr.entry(tc, "setRecoveryLogService", ref);
Expand All @@ -231,11 +193,6 @@ public void setRecoveryLogService(ServiceReference<RecLogServiceImpl> ref) {
Tr.exit(tc, "setRecoveryLogService");
}

public void unsetRecoveryLogService(ServiceReference<RecLogServiceImpl> ref) {
if (tc.isDebugEnabled())
Tr.debug(tc, "unsetRecoveryLogService", ref);
}

@Override
public boolean isProviderInstalled(String providerId) {
return true;
Expand Down Expand Up @@ -492,8 +449,7 @@ private synchronized void shutdown(boolean withCleanup, int timeout) {
Thread.sleep(1000);
if (tc.isDebugEnabled())
Tr.debug(tc, "Waited " + ++timeSlept + " seconds for transactions to finish");
} catch (InterruptedException e) {
}
} catch (InterruptedException e) {}
} else {
if (tc.isDebugEnabled())
Tr.debug(tc, "Gave up waiting for transactions to finish after " + ++timeSlept + " seconds");
Expand Down Expand Up @@ -571,10 +527,8 @@ private synchronized void shutdown(boolean withCleanup, int timeout) {
} else {
try {
_asyncRecoverySemaphore.waitEvent();
} catch (InterruptedException e) {
}
} catch (InterruptedException e) {}
setResyncException(null);
_asyncRecoverySemaphore.clear();
}

ConfigurationProviderManager.stop(true);
Expand Down Expand Up @@ -662,7 +616,7 @@ public void start() throws Exception {
Tr.exit(tc, "start");
}

public synchronized static void resyncComplete(RuntimeException r) {
public static synchronized void resyncComplete(RuntimeException r) {
if (tc.isEntryEnabled())
Tr.entry(tc, "resyncComplete", r);

Expand Down Expand Up @@ -833,16 +787,14 @@ private boolean ableToStartRecoveryNow() {
", _dataSourceFactorySet: " + isDataSourceFactorySet +
", _recoveryLogFactoryReady: " + _recoveryLogFactoryReady);

if (!_requireDataSourceActive) {
if (_waitForRecovery)
// If the waitForRecovery flag has been specified then we need the full set of services in place before we can start recovery
recoverNow = _tmsReady && _xaResourceFactoryReady && _recoveryLogServiceReady && _recoveryLogFactoryReady; // FOR NOW && _dataSourceFactoryReady;
else
recoverNow = _tmsReady && _recoveryLogServiceReady;
} else {
if (_requireDataSourceActive)
// If logging to a database then we need the full set of services in place before we can start recovery
recoverNow = _tmsReady && _xaResourceFactoryReady && _recoveryLogServiceReady && _recoveryLogFactoryReady && isDataSourceFactorySet;
}
else if (_waitForRecovery)
// If the waitForRecovery flag has been specified then we need the full set of services in place before we can start recovery
recoverNow = _tmsReady && _recoveryLogServiceReady && _xaResourceFactoryReady && _recoveryLogFactoryReady; // FOR NOW && _dataSourceFactoryReady;
else
recoverNow = _tmsReady && _recoveryLogServiceReady;
}

if (tc.isEntryEnabled())
Expand Down
Loading