sandynz commented on code in PR #25932:
URL: https://github.com/apache/shardingsphere/pull/25932#discussion_r1209161343


##########
kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java:
##########
@@ -80,15 +85,30 @@ public OpenGaussWALDumper(final DumperConfiguration 
dumperConfig, final IngestPo
         this.decodeWithTX = dumperConfig.isDecodeWithTX();
     }
     
-    @SneakyThrows(InterruptedException.class)
     @Override
     protected void runBlocking() {
+        while (isRunning()) {
+            try {
+                connect();

Review Comment:
   It's better to add `break;` after `connect();`



##########
kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java:
##########
@@ -80,15 +85,30 @@ public OpenGaussWALDumper(final DumperConfiguration 
dumperConfig, final IngestPo
         this.decodeWithTX = dumperConfig.isDecodeWithTX();
     }
     
-    @SneakyThrows(InterruptedException.class)
     @Override
     protected void runBlocking() {
+        while (isRunning()) {
+            try {
+                connect();
+            } catch (final SQLException ex) {
+                int reconnectTimes = this.reconnectTimes.incrementAndGet();
+                log.error("Connect failed, reconnect times={}", 
reconnectTimes, ex);
+                if (reconnectTimes > 3) {
+                    throw new IngestException(ex);
+                }
+            }
+        }
+    }
+    
+    @SneakyThrows(InterruptedException.class)
+    private void connect() throws SQLException {

Review Comment:
   `connect()` name could be `dump()`?



##########
kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java:
##########
@@ -68,6 +71,8 @@ public final class OpenGaussWALDumper extends 
AbstractLifecycleExecutor implemen
     
     private List<AbstractRowEvent> rowEvents = new LinkedList<>();
     
+    private final AtomicInteger reconnectTimes = new AtomicInteger();

Review Comment:
   `reconnectTimes` could be put in `runBlocking` as local variable



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to