From d18bde71c69aef11ad9da6845702f34d89132752 Mon Sep 17 00:00:00 2001 From: "jianghang.loujh" Date: Thu, 25 Dec 2025 11:47:36 +0800 Subject: [PATCH] merge and support polardb-x recycle_bin binlog format --- .../prometheus/PrometheusService.java | 10 +- .../dbsync/binlog/event/QueryLogEvent.java | 238 ++++++++---------- 2 files changed, 108 insertions(+), 140 deletions(-) diff --git a/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/prometheus/PrometheusService.java b/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/prometheus/PrometheusService.java index 76fcf8c8..0dba1147 100644 --- a/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/prometheus/PrometheusService.java +++ b/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/prometheus/PrometheusService.java @@ -1,14 +1,15 @@ package com.alibaba.otter.canal.adapter.launcher.prometheus; -import io.prometheus.client.exporter.HTTPServer; -import io.prometheus.client.hotspot.DefaultExports; +import java.io.IOException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component; -import java.io.IOException; +import io.prometheus.client.exporter.HTTPServer; +import io.prometheus.client.hotspot.DefaultExports; /** * @author sunxien @@ -25,8 +26,9 @@ public class PrometheusService implements InitializingBean, DisposableBean { /** *
-     * Canal Server admin port: 11112
+     * Canal Server admin port: 11110
      * Canal Server tcp port: 11111
+     * Canal Server metric port: 11112
      * Canal Adapter metric port: 11113
      * 
*/ diff --git a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/QueryLogEvent.java b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/QueryLogEvent.java index 7941ce76..75912d71 100644 --- a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/QueryLogEvent.java +++ b/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/QueryLogEvent.java @@ -3,6 +3,7 @@ package com.taobao.tddl.dbsync.binlog.event; import java.io.IOException; import java.math.BigInteger; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import com.taobao.tddl.dbsync.binlog.CharsetConversion; import com.taobao.tddl.dbsync.binlog.LogBuffer; @@ -281,82 +282,28 @@ public class QueryLogEvent extends LogEvent { * packet (i.e. a query) sent from client to master; First, an auxiliary * log_event status vars estimation: */ - public static final int MAX_SIZE_LOG_EVENT_STATUS = (1 + 4 /* type, flags2 */ - + 1 + 8 /* - * type, - * sql_mode - */ - + 1 + 1 + 255/* - * type, - * length - * , - * catalog - */ - + 1 + 4 /* - * type, - * auto_increment - */ - + 1 + 6 /* - * type, - * charset - */ - + 1 + 1 + 255 /* - * type, - * length - * , - * time_zone - */ - + 1 + 2 /* - * type, - * lc_time_names_number - */ - + 1 + 2 /* - * type, - * charset_database_number - */ - + 1 + 8 /* - * type, - * table_map_for_update - */ - + 1 + 4 /* - * type, - * master_data_written - */ - /* - * type, db_1, db_2, - * ... - */ - /* type, microseconds */ - /* - * MariaDb type, - * sec_part of NOW() - */ - + 1 + (MAX_DBS_IN_EVENT_MTS * (1 + NAME_LEN)) + 3 /* - * type - * , - * microseconds - */+ 1 + 32 - * 3 + 1 + 60/* - * type , - * user_len - * , user , - * host_len - * , host - */) - + 1 + 1 /* - * type, - * explicit_def - * ..ts - */+ 1 + 8 /* - * type, - * xid - * of - * DDL - */+ 1 + 2 /* - * type - * , - * default_collation_for_utf8mb4_number - */+ 1 /* sql_require_primary_key */; + public static final int MAX_SIZE_LOG_EVENT_STATUS = (1 + 4 /* type, flags2 */ + 1 + 8 /* type,sql_mode */ + 1 + 1 + 255 /* type,length, catalog */ + + 1 + 4 /* type,auto_increment */ + + 1 + 6 /* type, charset */ + + 1 + 1 + 255 /* type, length, time_zone */ + + 1 + 2 /* type, lc_time_names_number */ + + 1 + 2 /* type, charset_database_number */ + + 1 + 8 /* type, table_map_for_update */ + + 1 + 4 /* type,master_data_written */ + + 1 + 1 + 32 * 3 /* type, user_len, user */ + + 1 + 255 /* host_len, host */ + + 1 + 1 + (MAX_DBS_IN_EVENT_MTS * (1 + NAME_LEN)) /* type, db_1, db_2, ... */ + + 1 + 3 /* type, microseconds */ + + 1 + 1 /* type, explicit_def..ts*/ + + 1 + 8 /* type, xid of DDL */ + + 1 + 2 /* type, default_collation_for_utf8mb4_number */ + + 1 + 1 /* sql_require_primary_key */ + + 1 + 1 /* type, default_table_encryption */ + + 1 + 1 /* opt_flashback_area */ + + 1 + 1 /* type, opt_index_format_gpp_enabled */ + + 1 + 1 /* type, opt_index_format_panda_enabled */ + + 1 + 1 + NAME_LEN /* type, length, recycle_bin_table_name */); + /** * Fixed data part: *