You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
golang runtime and libraries have adopted the style that context.Context is the first parameters in function arguments. We don't need to proactively check the query is killed/canceled frequently. In many functions from official SDK or 3-rd party libraries, invalid context will cause the function return error and break the workflow. In fact, we often forget to proactively check the killed/canceled flag and have caused many problems like can't kill query for CHECK_CONSTRAINTS #58080non-dist-task fast-reorg ADD INDEX can't be canceled timely #56017
the builtin style of CancelCauseFunc requires to use https://pkg.go.dev/context#Cause to find the error, but we are more familiar with ctx.Err(). There should be some work to rewrite the usage of ctx.Err()
the builtin https://pkg.go.dev/context#WithCancelCause uses a lock to guard the cancel cause. So if multiple goroutines access it, it's slower than the killed/canceled flag which is an atomic variable. Given these 2 drawbacks, we may want to implement our own WithCancelCauseFast function
The text was updated successfully, but these errors were encountered:
Enhancement
as title.
pros:
context.Context
is the first parameters in function arguments. We don't need to proactively check the query is killed/canceled frequently. In many functions from official SDK or 3-rd party libraries, invalid context will cause the function return error and break the workflow. In fact, we often forget to proactively check the killed/canceled flag and have caused many problems like can't kill query for CHECK_CONSTRAINTS #58080 non-dist-task fast-reorg ADD INDEX can't be canceled timely #56017tidb/pkg/util/sqlkiller/sqlkiller.go
Lines 71 to 85 in 0ffac36
cons:
CancelCauseFunc
requires to use https://pkg.go.dev/context#Cause to find the error, but we are more familiar withctx.Err()
. There should be some work to rewrite the usage ofctx.Err()
WithCancelCauseFast
functionThe text was updated successfully, but these errors were encountered: