Skip to content

Commit

Permalink
Test alternative approach
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Jul 17, 2024
1 parent c09c874 commit 2761d96
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ public Object allocateConnection(ManagedConnectionFactory factory, ConnectionReq

boolean beforeCheckpoint = !CheckpointPhase.getPhase().restored();
if (beforeCheckpoint) {
mcWrapper.markStale();
if (isTraceOn && tc.isDebugEnabled()) {
Tr.debug(this, tc, "Marked the mcWrapper stale " + mcWrapper + " Do not pool any connection before checkpoint restore");
Tr.debug(this, tc, "Marking the mcWrapper as not poolable before checkpoint restore " + mcWrapper);
}
mcWrapper.markNotPoolable();
}
} catch (ResourceException e) {
mcWrapper.setPoolState(poolState);
Expand Down
8 changes: 5 additions & 3 deletions dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/FreePool.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,8 @@ protected void returnToFreePool(MCWrapper mcWrapper) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(this, tc, "returnToFreePool", gConfigProps.cfName);
}
if (mcWrapper.shouldBeDestroyed() || mcWrapper.hasFatalErrorNotificationOccurred(fatalErrorNotificationTime)
|| ((pm.agedTimeout != -1)
&& (mcWrapper.hasAgedTimedOut(pm.agedTimeoutMillis)))) {
if (mcWrapper.shouldBeDestroyed() || mcWrapper.hasFatalErrorNotificationOccurred(fatalErrorNotificationTime) || !mcWrapper.isPoolable()
|| ((pm.agedTimeout != -1) && (mcWrapper.hasAgedTimedOut(pm.agedTimeoutMillis)))) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
if (mcWrapper.shouldBeDestroyed()) {
Tr.debug(this, tc, "Connection destroy flag is set, removing connection " + mcWrapper);
Expand All @@ -265,6 +264,9 @@ protected void returnToFreePool(MCWrapper mcWrapper) {
Tr.debug(this, tc, "Mbean method purgePoolContents with option immediate was used." +
" Connection cleanup and destroy is being processed.");
}
if (!mcWrapper.isPoolable()) {
Tr.debug(this, tc, "Connection was flagged as not poolable and will not be returned to the free pool.");
}
}
if (mcWrapper.isDestroyState()) {
final FreePool tempFP = this;
Expand Down
19 changes: 19 additions & 0 deletions dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/MCWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ protected void setAlreadyBeingReleased(boolean value) {
protected boolean do_not_reuse_mcw = false;
private boolean inSharedPool = false;

/**
* During specific server states (such as during instantOn checkpoint) we may not
* want to allow connections to pool and disregard user configuration.
* This is another property like stale and do_not_reuse_mcw that will prevent pooling.
* However, this property is not related to an error state and is expected to allow
* valid connections to be discarded after use.
*/
private boolean poolable = true;

/**
* There is one recoveryToken needed per ManagedConnectionFactory and thus one per PoolManager.
* The <code>PoolManager</code> will get the token from the transaction service in it's constructor
Expand Down Expand Up @@ -3192,4 +3201,14 @@ public Boolean run() throws Exception {
public int getMaximumConnectionValue() {
return this.pm.maxConnections;
}

@Override
public void markNotPoolable() {
this.poolable = false;
}

@Override
public boolean isPoolable() {
return this.poolable;
}
}
18 changes: 16 additions & 2 deletions dev/com.ibm.ws.jca.cm/src/com/ibm/ws/j2c/MCWrapper.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 1997, 2013 IBM Corporation and others.
* Copyright (c) 1997, 2024 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:
Expand Down Expand Up @@ -106,6 +106,12 @@ public interface MCWrapper {
*/
void markStale();

/**
* Marks this connection for destruction.
* Used during specific server states where valid connections should not be pooled.
*/
void markNotPoolable();

boolean hasFatalErrorNotificationOccurred(int fatalErrorNotificationTime);

boolean hasAgedTimedOut(long timeoutValue);
Expand All @@ -114,6 +120,14 @@ public interface MCWrapper {

void markInUse();

/**
* Returns true if the connection is poolable as determined by the MCWrapper property poolable.
* Does not check any other state such as agedTimeout, idleTimeout, or stale.
*
* @return
*/
boolean isPoolable();

boolean isStale();

Object getSharedPool();
Expand Down

0 comments on commit 2761d96

Please sign in to comment.