yuxiqian commented on code in PR #3432:
URL: https://github.com/apache/flink-cdc/pull/3432#discussion_r1654662884


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtils.java:
##########


Review Comment:
   Is it possible to create a mocked `BinlogClient` that ~~fails to 
`connect()`~~ fails to `registerEventListener()` for the first time and 
succeeds after retrying?



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtils.java:
##########
@@ -324,11 +324,22 @@ private static long getBinlogTimestamp(BinaryLogClient 
client, String binlogFile
             client.setBinlogFilename(binlogFile);
             client.setBinlogPosition(0);
 
-            LOG.info("begin parse binlog: {}", binlogFile);
+            LOG.info("Begin parse binlog: {}", binlogFile);
             client.connect();
         } finally {
             client.unregisterEventListener(eventListener);
         }
+        if (binlogTimestamps.isEmpty()) {
+            try {
+                if (client.isConnected()) {
+                    client.disconnect();
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            LOG.warn("Failed to register eventListener and try to register it 
again");
+            return getBinlogTimestamp(client, binlogFile);

Review Comment:
   Just worrying about overflow of calling stack. But since connection failure 
not very likely to happen, I'll not insist about this.



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtils.java:
##########
@@ -324,11 +324,22 @@ private static long getBinlogTimestamp(BinaryLogClient 
client, String binlogFile
             client.setBinlogFilename(binlogFile);
             client.setBinlogPosition(0);
 
-            LOG.info("begin parse binlog: {}", binlogFile);
+            LOG.info("Begin parse binlog: {}", binlogFile);
             client.connect();
         } finally {
             client.unregisterEventListener(eventListener);
         }
+        if (binlogTimestamps.isEmpty()) {
+            try {
+                if (client.isConnected()) {
+                    client.disconnect();
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            LOG.warn("Failed to register eventListener and try to register it 
again");
+            return getBinlogTimestamp(client, binlogFile);

Review Comment:
   Just worrying about overflow of calling stack. But since connection failure 
very unlikely to happen, I'll not insist about this.



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtils.java:
##########
@@ -324,11 +324,22 @@ private static long getBinlogTimestamp(BinaryLogClient 
client, String binlogFile
             client.setBinlogFilename(binlogFile);
             client.setBinlogPosition(0);
 
-            LOG.info("begin parse binlog: {}", binlogFile);
+            LOG.info("Begin parse binlog: {}", binlogFile);
             client.connect();
         } finally {
             client.unregisterEventListener(eventListener);
         }
+        if (binlogTimestamps.isEmpty()) {
+            try {
+                if (client.isConnected()) {
+                    client.disconnect();
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            LOG.warn("Failed to register eventListener and try to register it 
again");
+            return getBinlogTimestamp(client, binlogFile);

Review Comment:
   Just worrying about overflow of calling stack. But since connection failure 
very unlikely to happen, I'll not insist on this.



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