Skip to content

Mark server failed after its logs have been deleted by a peer #31226

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

Merged
merged 2 commits into from
May 6, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,8 @@ private void markFailed(Throwable t, boolean report, boolean peerServerLostLogOw
boolean newFailure = false;
synchronized (this) {
if (!_failed) {
if (tc.isDebugEnabled()) Tr.debug(tc, "markFailed: RecoveryLog has been marked as failed. [" + this + "]");
if (tc.isDebugEnabled())
Tr.debug(tc, "markFailed: RecoveryLog has been marked as failed. [" + this + "]");
newFailure = true;
_failed = true;
}
Expand Down Expand Up @@ -3848,12 +3849,17 @@ public void heartBeat() throws LogClosedException {
if (tc.isDebugEnabled())
Tr.debug(tc, "The underlying table may have been deleted");
if (isTableDeleted(sqlex)) {
// The underlying table has been deleted
Tr.audit(tc, "WTRN0107W: " +
"Underlying SQL tables missing when heartbeating SQL RecoveryLog " + _logName + " for server " + _serverName);
// Set exception variables to NOT retry
// Set exception variables to NOT retry. Regular heartbeat will keep going
currentSqlEx = null;
nonTransientException = sqlex;
if (conn != null) {
// At this point we know we can contact the database and we know our log table has disappeared. A peer server must have recovered our logs.
// We'll mark the log failed so the server will go down unless configured not to.
markFailed(sqlex, true, false);
} else {
Tr.audit(tc, "WTRN0107W: " +
"Underlying SQL tables missing when heartbeating SQL RecoveryLog " + _logName + " for server " + _serverName);
}
} else
Tr.audit(tc, "WTRN0107W: " +
"Peer locking heartbeat failed with SQL exception: " + sqlex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,29 +471,26 @@ public void testLeaseIndexBackwardCompatibility() throws Exception {
}

@Test
@AllowedFFDC(value = { "javax.transaction.xa.XAException", "com.ibm.ws.recoverylog.spi.RecoveryFailedException",
"javax.transaction.SystemException", "com.ibm.ws.recoverylog.spi.InternalLogException",
"com.ibm.ws.recoverylog.spi.LogsUnderlyingTablesMissingException", "java.lang.Exception" })
// Annoying that all these have to be allowed rather that some being expected. Thanks Derby.
@AllowedFFDC(value = { "com.ibm.ws.recoverylog.spi.LogsUnderlyingTablesMissingException", "javax.transaction.SystemException", "java.lang.Exception",
"com.ibm.ws.recoverylog.spi.InternalLogException" })
public void testReactionToDeletedTables() throws Exception {
final String method = "testReactionToDeletedTables";
StringBuilder sb = null;
if (!TxTestContainerSuite.isDerby()) { // Embedded Derby cannot support tests with concurrent server startup

if (!TxTestContainerSuite.isDerby()) { // Can't get a connection to drop tables on embedded Derby
serversToCleanup = new LibertyServer[] { server2, noRecoveryGroupServer1 };
// server2.setHttpDefaultPort(cloud2ServerPort);
server2.useSecondaryHTTPPort();
FATUtils.startServers(_runner, server2);
assertNotNull("Home server recovery failed", server2.waitForStringInTrace("Transaction recovery processing for this server is complete", FATUtils.LOG_SEARCH_TIMEOUT));
FATUtils.startServers(_runner, noRecoveryGroupServer1);

sb = runTestWithResponse(noRecoveryGroupServer1, SERVLET_NAME, "dropServer2Tables");
Log.info(c, method, "testReactionToDeletedTables dropServer2Tables returned: " + sb);
FATUtils.startServers(_runner, server2, noRecoveryGroupServer1);
assertNotNull("Home server recovery should have completed",
server2.waitForStringInTrace("WTRN0133I: Transaction recovery processing for this server is complete", FATUtils.LOG_SEARCH_TIMEOUT));

runTestWithResponse(noRecoveryGroupServer1, SERVLET_NAME, "dropServer2Tables");

assertNotNull("Failed to drop tables", noRecoveryGroupServer1.waitForStringInTrace("<<< END: dropServer2Tables", FATUtils.LOG_SEARCH_TIMEOUT));
runTestWithResponse(server2, SERVLET_NAME, "twoTrans");
assertNotNull("Home server tables sould have been deleted", server2.waitForStringInTrace("Underlying SQL tables missing", FATUtils.LOG_SEARCH_TIMEOUT));

sb = runTestWithResponse(server2, SERVLET_NAME, "twoTrans");
Log.info(c, method, "testReactionToDeletedTables twoTrans returned: " + sb);
assertNotNull("Home server tables are still present", server2.waitForStringInTrace("Underlying SQL tables missing", FATUtils.LOG_SEARCH_TIMEOUT));
assertNotNull("Server should have stopped",
server2.waitForStringInLog("CWWKE0036I: The server com.ibm.ws.transaction_ANYDBCLOUD002 stopped", FATUtils.LOG_SEARCH_TIMEOUT));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,7 @@ public void dropServer2Tables(HttpServletRequest request,

try (Connection con = getConnection(dsTranLog)) {
con.setAutoCommit(false);
DatabaseMetaData mdata = con.getMetaData();
String dbName = mdata.getDatabaseProductName();
boolean isPostgreSQL = dbName.toLowerCase().contains("postgresql");
boolean isOracle = dbName.toLowerCase().contains("oracle");
boolean isSQLServer = dbName.toLowerCase().contains("microsoft sql");
Statement stmt = null;
// Statement used to drop table
try {
stmt = con.createStatement();
try (Statement stmt = con.createStatement()) {
String dropTableString = "DROP TABLE WAS_TRAN_LOGCLOUD0021";
System.out.println("dropServer2Tables: Drop table using: " + dropTableString);
int dropReturn = stmt.executeUpdate(dropTableString);
Expand All @@ -501,7 +493,6 @@ public void dropServer2Tables(HttpServletRequest request,
} catch (Exception ex) {
System.out.println("dropServer2Tables: caught exception in testSetup: " + ex);
}

}
}

Expand Down