Do NOT check SQL states when catching `DataAccessException` in `MetadataDBExtension`
@@ -174,16 +174,15 @@ public abstract class MetadataDBExtension implements KafkaPlugin, DBConnector {
}
});
} catch (DataAccessException e) {
- // The error codes starting with 57P0 are related to the DB connection issues.
- // See https://www.postgresql.org/docs/current/errcodes-appendix.html
- if (e.sqlState().contains("57P0")) {
- throw new UnrecoverableError("Could not connect to the Postgres DB and the plug-in should be stopped and restarted.",
+ transactionRestartCount++;
+ if (transactionRestartCount >= Constants.transactionRestartLimit) {
+ throw new UnrecoverableError("Could not connect to or query the Postgres DB and the plug-in should be stopped and restarted.",
e.getCause());
}
} catch (Exception expected) {
-
- }
transactionRestartCount++;
+ }
+
} while (restartTransaction && !processedRecord
&& transactionRestartCount < Constants.transactionRestartLimit);
}
