Open jeffswenson opened 2 years ago
When we clean this up, we should also remove all instances of stopper.WithCancelOnQuiesce(ctx) that do not defer the cancel function. Callers that do not call the cancel function are at a high risk for leaking the context. See https://github.com/cockroachdb/cockroach/pull/101787 for details.
The SQL proxy uses stoper.RunAsyncTask to create a goroutine for each connection. The context created for the async task is passed to child go routines that are spawned using the
go
command. Stopper attaches a span to the context and the span is returned to a pool when the task returns. During the connection tear down process, child workers may use the task's context. This is inappropriate as it leads to a use after free bug.Per https://github.com/cockroachdb/cockroach/issues/58164 the sqlproxy should avoid raw use of the
go
keyword and should use the stopper to spawn goroutines.Jira issue: CRDB-13713