Jiabao-Sun commented on code in PR #3940:
URL: https://github.com/apache/flink-cdc/pull/3940#discussion_r1984369768


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/polardbx/PolardbxSourceTestBase.java:
##########
@@ -113,14 +115,34 @@ protected static Connection getJdbcConnection() throws 
SQLException {
     }
 
     protected static Boolean checkConnection() {
-        LOG.info("check polardbx connection validation...");
-        try {
-            Connection connection = getJdbcConnection();
-            return connection.isValid(3);
+        LOG.info("check PolarDBx CDC node status...");
+        boolean cdcReady = false;
+        try (Connection connection = getJdbcConnection();
+                Statement statement = connection.createStatement()) {
+            ResultSet rs = statement.executeQuery("SHOW MASTER STATUS");
+            if (rs.next()) {
+                String binlogFilename = rs.getString(1);
+                long binlogPosition = rs.getLong(2);
+                // the initial binlog position is 4
+                cdcReady = StringUtils.isNotEmpty(binlogFilename) && 
binlogPosition > 4L;
+                if (cdcReady) {
+                    LOG.info(
+                            "PolarDBx CDC node is ready at offset {}:{}",
+                            binlogFilename,
+                            binlogPosition);
+                } else {
+                    LOG.warn(
+                            "PolarDBx CDC node is not ready at offset {}:{},  
waiting...",
+                            binlogFilename,
+                            binlogPosition);
+                }
+            } else {
+                LOG.warn("PolarDBx CDC node is not ready, waiting...");
+            }
         } catch (SQLException e) {
-            LOG.warn("polardbx connection is not valid... caused by:" + 
e.getMessage());
-            return false;
+            LOG.warn("PolarDBx CDC node is not ready... caused by:{}", 
e.getMessage());

Review Comment:
   It is recommended to set cdcReady to false in the catch block to prevent it 
from being overlooked after adding new logic.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to