From 741c00ff8057bb372b76e976149438f8c2f04d24 Mon Sep 17 00:00:00 2001 From: weicheng Date: Mon, 22 Apr 2024 19:46:13 +0800 Subject: [PATCH] Fix close canal client panic if use Execute after mysql host down --- 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)