dyp12 commented on code in PR #9628:
URL: https://github.com/apache/seatunnel/pull/9628#discussion_r2240081111


##########
seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlConnectionUtils.java:
##########
@@ -185,4 +192,87 @@ private static Map<String, String> querySystemVariables(
 
         return variables;
     }
+
+    public static BinlogOffset findBinlogOffsetBytimestamp(
+            JdbcConnection jdbc, BinaryLogClient client, long timestamp) {
+        final String showBinaryLogStmt = "SHOW BINARY LOGS";
+        List<String> binlogFiles = new ArrayList<>();
+        JdbcConnection.ResultSetConsumer rsc =
+                rs -> {
+                    while (rs.next()) {
+                        String fileName = rs.getString(1);
+                        long fileSize = rs.getLong(2);
+                        if (fileSize > 0) {
+                            binlogFiles.add(fileName);
+                        }
+                    }
+                };
+        try {
+            jdbc.query(showBinaryLogStmt, rsc);
+            if (binlogFiles.isEmpty()) {
+                return BinlogOffset.INITIAL_OFFSET;
+            }
+            String binlogName = searchBinlogName(client, timestamp, 
binlogFiles);
+            return new BinlogOffset(binlogName, 0);

Review Comment:
   > So, our logic cannot precisely specify the binlog offset, and can only 
locate the file closest to the specified timestamp? This might result in data 
before the timestamp being read, or data after the timestamp being discarded. 
Is my understanding correct?
   
   yes,in mysql , we cannot to find the specified timestamp quickly,i search 
other cdc tools, eg flink cdc , it also use binlog file begin  
   <img width="904" height="724" alt="1753799815409" 
src="https://github.com/user-attachments/assets/8c67cd4c-3abd-476e-9ea9-4826f34da66c";
 />
   
   
https://github.com/apache/flink-cdc/blob/master/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/debezium/DebeziumUtils.java#L245



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