Tartarus0zm commented on a change in pull request #11530:
URL: https://github.com/apache/flink/pull/11530#discussion_r436784867



##########
File path: 
flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCUpsertOutputFormat.java
##########
@@ -166,6 +166,22 @@ public synchronized void flush() throws Exception {
                                if (i >= maxRetryTimes) {
                                        throw e;
                                }
+                               boolean isValid = false;
+                               try {
+                                       isValid = connection.isValid(1);
+                               } catch (SQLException ex) {
+                                       LOG.warn("Check connection valid 
failed.", ex);
+                               }
+
+                               try {
+                                       if (!isValid) {
+                                               LOG.warn("This connection is 
not valid, trying to reconnect.");
+                                               establishConnection();

Review comment:
       Is it possible to put the reconnect operation in the exception handling 
of isValid?
   if reconnect failed,then throw exception and retrying may be meaningless?

##########
File path: 
flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCUpsertOutputFormat.java
##########
@@ -199,7 +215,9 @@ public synchronized void close() throws IOException {
                }
 
                try {
-                       jdbcWriter.close();
+                       if (jdbcWriter != null) {

Review comment:
       In theory, jdbcWriter should not be null,




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to