From 7c31dc4e4e5bac6f8f9a73c04efad3e0af69e606 Mon Sep 17 00:00:00 2001 From: tomwei7 Date: Mon, 22 Apr 2024 22:21:08 +0800 Subject: [PATCH] Fix close canal client panic if use Execute after mysql host down (#858) Co-authored-by: weicheng --- canal/canal.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/canal/canal.go b/canal/canal.go index f6cbfe099..23fd3de67 100644 --- a/canal/canal.go +++ b/canal/canal.go @@ -254,8 +254,10 @@ func (c *Canal) Close() { c.cancel() c.syncer.Close() c.connLock.Lock() - c.conn.Close() - c.conn = nil + if c.conn != nil { + c.conn.Close() + c.conn = nil + } c.connLock.Unlock() _ = c.eventHandler.OnPosSynced(nil, c.master.Position(), c.master.GTIDSet(), true)