From 12e75b1f3c730a86b7a8f95b7f90ee0fba617bf1 Mon Sep 17 00:00:00 2001 From: Manan Gupta <35839558+GuptaManan100@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:55:04 +0530 Subject: [PATCH] Add nil check to prevent panics (#14902) Signed-off-by: Manan Gupta --- go/vt/vtgate/vtgate.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index 4716cdcf794..f3be94599e4 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -364,8 +364,10 @@ func Init( st.Start() } srv := initMySQLProtocol(vtgateInst) - servenv.OnTermSync(srv.shutdownMysqlProtocolAndDrain) - servenv.OnClose(srv.rollbackAtShutdown) + if srv != nil { + servenv.OnTermSync(srv.shutdownMysqlProtocolAndDrain) + servenv.OnClose(srv.rollbackAtShutdown) + } }) servenv.OnTerm(func() { if st != nil && enableSchemaChangeSignal {