Skip to content

Commit

Permalink
Do NOT check SQL states when catching DataAccessException in `Quali…
Browse files Browse the repository at this point in the history
…tyAnalyzerPlugin`
  • Loading branch information
mir-am committed Jun 8, 2022
1 parent 49c4229 commit 29d20b9
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,20 @@ public void consume(String kafkaMessage) {
do {
logger.info("Beginning of the transaction sequence");
setPluginError(null);
transactionRestartCount++;

try {
recordId = utils.processJsonRecord(jsonRecord);
if(recordId == null) {
if (recordId == null) {
throw new IllegalStateException("No callables matched");
}
}
catch(DataAccessException e) {
// Database-related errors
catch (DataAccessException e) {
logger.info("Data access exception");
// Database connection error
// 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.",

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());
}

Expand All @@ -123,6 +124,7 @@ public void consume(String kafkaMessage) {
setPluginError(exception);
}

setPluginError(e);
logger.info("Restarting transaction for '" + recordId + "'");
// It could be a deadlock, so restart transaction
restartTransaction = true;
Expand All @@ -148,8 +150,6 @@ public void consume(String kafkaMessage) {
+ "with callable id = " + recordId);
}

transactionRestartCount++;

} while( restartTransaction && !processedRecord && transactionRestartCount < Constants.transactionRestartLimit );
}

Expand Down

0 comments on commit 29d20b9

Please sign in to comment.