From 50fe1df262eace318e9e809fec1528b3dd8ce6df Mon Sep 17 00:00:00 2001 From: Jose Medrano Date: Thu, 8 Feb 2024 20:29:29 +0100 Subject: [PATCH 1/2] Include statement id's for all the error messages --- .../lst_bench/client/JDBCConnection.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java b/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java index 812f5ae9..501181ad 100644 --- a/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java +++ b/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java @@ -74,7 +74,7 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client } // Log verbosely, if enabled. if (this.showWarnings && LOGGER.isWarnEnabled()) { - logWarnings(s); + logWarnings(s, false); } // Return here if successful. return queryResult; @@ -85,11 +85,14 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client + this.maxNumRetries + " retries) unsuccessful; stack trace: " + ExceptionUtils.getStackTrace(e); - if (errorCount == this.maxNumRetries) { - // Log any pending warnings associated with this statement, useful for debugging. - if (LOGGER.isWarnEnabled()) { - logWarnings(s); - } + + // Log any pending warnings associated with this statement, useful for debugging. + boolean logAsError = errorCount == this.maxNumRetries; + if (LOGGER.isWarnEnabled()) { + logWarnings(s, logAsError); + } + + if (logAsError) { // Log execution error. LOGGER.error(lastErrorMsg); throw new ClientException(lastErrorMsg); @@ -128,7 +131,7 @@ public void close() throws ClientException { } } - private void logWarnings(Statement s) throws ClientException { + private void logWarnings(Statement s, boolean logAsError) throws ClientException { List warningList = new ArrayList<>(); if (s != null) { @@ -145,7 +148,11 @@ private void logWarnings(Statement s) throws ClientException { } for (String warning : warningList) { - LOGGER.warn(warning); + if (logAsError) { + LOGGER.error(warning); + } else { + LOGGER.warn(warning); + } } } } From 156ab3fb768a54c20b5c7d1ae4e7e4c9b3ce7d31 Mon Sep 17 00:00:00 2001 From: Jose Medrano Date: Fri, 9 Feb 2024 13:51:18 +0100 Subject: [PATCH 2/2] Fix to add it as part of the lastErrorMsg Modified by: Anja --- .../lst_bench/client/JDBCConnection.java | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java b/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java index 501181ad..4c8a7a43 100644 --- a/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java +++ b/src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java @@ -74,7 +74,7 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client } // Log verbosely, if enabled. if (this.showWarnings && LOGGER.isWarnEnabled()) { - logWarnings(s, false); + LOGGER.warn(createWarningString(s)); } // Return here if successful. return queryResult; @@ -83,23 +83,22 @@ private QueryResult execute(String sqlText, boolean ignoreResults) throws Client String lastErrorMsg = "Query execution (" + this.maxNumRetries - + " retries) unsuccessful; stack trace: " + + " retries) unsuccessful; " + + "Warnings: " + + createWarningString(s) + + "stack trace: " + ExceptionUtils.getStackTrace(e); - // Log any pending warnings associated with this statement, useful for debugging. - boolean logAsError = errorCount == this.maxNumRetries; - if (LOGGER.isWarnEnabled()) { - logWarnings(s, logAsError); - } - - if (logAsError) { - // Log execution error. + // Log execution error and any pending warnings associated with this statement, useful for + // debugging. + if (errorCount == this.maxNumRetries) { LOGGER.error(lastErrorMsg); throw new ClientException(lastErrorMsg); } else { LOGGER.warn(lastErrorMsg); } errorCount++; + } finally { if (s != null) { try { @@ -131,7 +130,7 @@ public void close() throws ClientException { } } - private void logWarnings(Statement s, boolean logAsError) throws ClientException { + private String createWarningString(Statement s) throws ClientException { List warningList = new ArrayList<>(); if (s != null) { @@ -147,12 +146,6 @@ private void logWarnings(Statement s, boolean logAsError) throws ClientException } } - for (String warning : warningList) { - if (logAsError) { - LOGGER.error(warning); - } else { - LOGGER.warn(warning); - } - } + return String.join("; ", warningList); } }