Skip to content

Commit

Permalink
Reintroduce instant-on for entity manager for Jakarta data
Browse files Browse the repository at this point in the history
Do not pool connections before checkpoint restore
  • Loading branch information
KyleAure committed Jul 16, 2024
1 parent 5e96e93 commit 4163dfb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dev/com.ibm.ws.jca.cm/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#*******************************************************************************
# Copyright (c) 2017,2022 IBM Corporation and others.
# Copyright (c) 2017, 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
Expand Down Expand Up @@ -78,6 +78,7 @@ instrument.disabled: true
com.ibm.websphere.javaee.connector.1.6;version=latest,\
com.ibm.websphere.security;version=latest,\
com.ibm.ws.javaee.dd.common;version=latest,\
com.ibm.ws.kernel.boot.common;version=latest,\
com.ibm.ws.kernel.service,\
com.ibm.ws.classloading;version=latest,\
com.ibm.ws.container.service;version=latest,\
Expand Down
12 changes: 11 additions & 1 deletion dev/com.ibm.ws.jca.cm/src/com/ibm/ejs/j2c/ConnectionManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1997, 2021 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
Expand Down Expand Up @@ -66,6 +66,8 @@
import com.ibm.wsspi.kernel.service.utils.FilterUtils;
import com.ibm.wsspi.resource.ResourceFactory;

import io.openliberty.checkpoint.spi.CheckpointPhase;

/**
* An instance of the ConnectionManager class is created by the
* ConnectionFactoryBuilder for a deployed resource adapter when the first
Expand Down Expand Up @@ -330,6 +332,14 @@ public Object allocateConnection(ManagedConnectionFactory factory, ConnectionReq
"logging.");
throw e;
}

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");
}
}
} catch (ResourceException e) {
mcWrapper.setPoolState(poolState);
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ejs.j2c.ConnectionManager.allocateConnection", "344", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,21 @@ public void applicationStarting(ApplicationInfo appInfo) throws StateChangeExcep
public void applicationStarted(ApplicationInfo appInfo) throws StateChangeException {
Collection<FutureEMBuilder> futures = futureEMBuilders.remove(appInfo.getName());
if (futures != null) {
boolean beforeCheckpoint = !CheckpointPhase.getPhase().restored();
for (FutureEMBuilder futureEMBuilder : futures) {
// This delays createEMBuilder until restore.
// While this works by avoiding all connections to the data source, it does make restore much slower.
// TODO figure out how to do more work on restore without having to make a connection to the data source
CheckpointPhase.onRestore(() -> futureEMBuilder.completeAsync(futureEMBuilder::createEMBuilder, executor));
if (beforeCheckpoint)
try {
// Run the task in the foreground if before a checkpoint.
// This is necessary to ensure this task completes before the checkpoint.
// Application startup performance is not as important before checkpoint
// and this ensures we don't do this work on restore side which will make
// restore faster.
futureEMBuilder.complete(futureEMBuilder.createEMBuilder());
} catch (Throwable x) {
futureEMBuilder.completeExceptionally(x);
}
else
futureEMBuilder.completeAsync(futureEMBuilder::createEMBuilder, executor);
}
}
}
Expand Down

0 comments on commit 4163dfb

Please sign in to comment.