Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terminating state #67

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go/vt/vtgate/plugin_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ func startSpan(ctx context.Context, query, label string) (trace.Span, context.Co

func (vh *vtgateHandler) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes.Result) error) error {
ctx := context.Background()

if terminating {
return vterrors.New(vtrpcpb.Code_ABORTED, "Terminating vtgate")
}

var cancel context.CancelFunc
if *mysqlQueryTimeout != 0 {
ctx, cancel = context.WithTimeout(ctx, *mysqlQueryTimeout)
Expand Down
8 changes: 8 additions & 0 deletions go/vt/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -328,6 +330,8 @@ func Init(
}
})
servenv.OnTerm(func() {
terminating = true

if st != nil && enableSchemaChangeSignal {
st.Stop()
}
Expand Down Expand Up @@ -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
}

Expand Down
Loading