From a080a630754be9a7b7cc38028ccd700b5f46a29d Mon Sep 17 00:00:00 2001 From: David Piegza <697113+davidpiegza@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:07:05 +0000 Subject: [PATCH] Add terminating state Signed-off-by: David Piegza <697113+davidpiegza@users.noreply.github.com> --- go/vt/vtgate/vtgate.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index de3fba2fbe0..20146bea46b 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -83,6 +83,8 @@ var ( // healthCheckTimeout is the timeout on the RPC call to tablets healthCheckTimeout = time.Minute + terminating bool + // System settings related flags sysVarSetEnabled = true setVarEnabled = true @@ -328,6 +330,8 @@ func Init( } }) servenv.OnTerm(func() { + terminating = true + if st != nil && enableSchemaChangeSignal { st.Stop() } @@ -405,6 +409,10 @@ func (vtg *VTGate) registerDebugHealthHandler() { // IsHealthy returns nil if server is healthy. // Otherwise, it returns an error indicating the reason. func (vtg *VTGate) IsHealthy() error { + if terminating { + return errors.New("Terminating") + } + return nil }