Skip to content

Commit

Permalink
[ci] Make ASN0510E retriable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Naros committed Feb 12, 2024
1 parent 375286c commit caed77c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/test/java/io/debezium/connector/db2/util/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -134,14 +135,25 @@ 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);
}
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.");
}
}
Expand Down

0 comments on commit caed77c

Please sign in to comment.