From 1aa9d0040cf1a4ca2e4b790331d49972b2b40a76 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Mon, 12 Feb 2024 15:57:38 -0500 Subject: [PATCH] [ci] Make ASN0510E retriable When attempting to start ASNCAP, the command can be ignored by Db2 and when this happens an ASN0510E status will be returned. In this case, the command should be re-executed. --- .../io/debezium/connector/db2/util/TestHelper.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/io/debezium/connector/db2/util/TestHelper.java b/src/test/java/io/debezium/connector/db2/util/TestHelper.java index 2fffc19..077c359 100644 --- a/src/test/java/io/debezium/connector/db2/util/TestHelper.java +++ b/src/test/java/io/debezium/connector/db2/util/TestHelper.java @@ -125,6 +125,7 @@ public static void enableDbCdc(Db2Connection connection) throws SQLException { Statement stmt = connection.connection().createStatement(); boolean isNotrunning = true; int count = 0; + int retries = 0; while (isNotrunning) { ResultSet rs = stmt.executeQuery(STATUS_DB_CDC); while (rs.next()) { @@ -134,6 +135,14 @@ public static void enableDbCdc(Db2Connection connection) throws SQLException { if (test.contains("is doing work")) { isNotrunning = false; } + else if (test.contains("ASN0510E")) { + // Per https://www.ibm.com/docs/en/db2/11.5?topic=messages-asn0000-asn0999#asn0510e + // The command was not executed and should be retried in this use case. + LOGGER.debug("ASN0510E detected, command was not processed and requires retry."); + connection.execute(ENABLE_DB_CDC); + retries++; + count = 0; + } else { try { Thread.sleep(1000); @@ -141,7 +150,10 @@ public static void enableDbCdc(Db2Connection connection) throws SQLException { catch (InterruptedException e) { } } - if (count++ > 60) { + if (retries > 5) { + throw new SQLException("Maximum ASNCAP server start requests exceeded"); + } + else if (count++ > 60) { throw new SQLException("ASNCAP server did not start."); } }