From 87060748ae984dae9a23fa498f6d67acd5e5440a Mon Sep 17 00:00:00 2001 From: Aaron Son Date: Tue, 14 Jan 2025 15:38:50 -0800 Subject: [PATCH] go/libraries/doltcore/sqle/dprocedures: dolt_gc.go: Retry canceling running queries when waiting for safepoint establishment. This allows `call dolt_gc()` to more quickly and realibly establish a safepoint if the call to safepointF() races with a new query beginning and being registered for the connection in the process list. --- go/libraries/doltcore/sqle/dprocedures/dolt_gc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/go/libraries/doltcore/sqle/dprocedures/dolt_gc.go b/go/libraries/doltcore/sqle/dprocedures/dolt_gc.go index 4a28a3fe00..d4308e18bf 100644 --- a/go/libraries/doltcore/sqle/dprocedures/dolt_gc.go +++ b/go/libraries/doltcore/sqle/dprocedures/dolt_gc.go @@ -157,11 +157,16 @@ func doDoltGC(ctx *sql.Context, args []string) (int, error) { params.MaxElapsedTime = 3 * time.Second err := backoff.Retry(func() error { processes := ctx.ProcessList.Processes() + allgood := true for _, p := range processes { if _, ok := killed[p.Connection]; ok { - return errors.New("unable to establish safepoint.") + allgood = false + ctx.ProcessList.Kill(p.Connection) } } + if !allgood { + return errors.New("unable to establish safepoint.") + } return nil }, params) if err != nil {