From 06e7f441144247275a51561fa7eb6ab2a616405c Mon Sep 17 00:00:00 2001 From: Wu-Jianqiang <959007@163.com> Date: Mon, 26 Feb 2018 16:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AMASTER=5FHEARTBEAT?= =?UTF-8?q?=5FPERIOD=20=E7=9A=84=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=98=AF=E7=A7=92=EF=BC=88=E5=8F=AF=E4=BB=A5=E5=8C=85=E5=90=AB?= =?UTF-8?q?3=E4=BD=8D=E5=B0=8F=E6=95=B0=E8=A1=A8=E7=A4=BA=E6=AF=AB?= =?UTF-8?q?=E7=A7=92=EF=BC=89=EF=BC=8C=E4=BD=86=E4=B8=8D=E6=98=AF=E7=BA=B3?= =?UTF-8?q?=E7=A7=92=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canal/parse/inbound/mysql/MysqlConnection.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java index e665b4f564..0eeef9f514 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java @@ -297,9 +297,15 @@ private void updateSettings() throws IOException { logger.warn("update mariadb_slave_capability failed", e); } - long periodNano = TimeUnit.SECONDS.toNanos(MASTER_HEARTBEAT_PERIOD_SECONDS); + /** + * MASTER_HEARTBEAT_PERIOD sets the interval in seconds between replication heartbeats. + * Whenever the master's binary log is updated with an event, the waiting period for the next heartbeat is reset. + * interval is a decimal value having the range 0 to 4294967 seconds and a resolution in milliseconds; + * the smallest nonzero value is 0.001. Heartbeats are sent by the master only if there are no unsent events + * in the binary log file for a period longer than interval. + */ try { - update("SET @master_heartbeat_period=" + periodNano); + update("SET @master_heartbeat_period=" + MASTER_HEARTBEAT_PERIOD_SECONDS); } catch (Exception e) { logger.warn("update master_heartbeat_period failed", e); }