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

fix ut panic #20412

Merged
merged 11 commits into from
Nov 28, 2024
16 changes: 12 additions & 4 deletions pkg/frontend/routine_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,12 @@ func (rm *RoutineManager) cleanKillQueue() {
ar := rm.accountRoutine
ar.killQueueMu.Lock()
defer ar.killQueueMu.Unlock()
for toKillAccount, killRecord := range ar.killIdQueue {
if time.Since(killRecord.killTime) > time.Duration(getPu(rm.service).SV.CleanKillQueueInterval)*time.Minute {
delete(ar.killIdQueue, toKillAccount)
pu := getPu(rm.service)
if pu != nil {
for toKillAccount, killRecord := range ar.killIdQueue {
if time.Since(killRecord.killTime) > time.Duration(pu.SV.CleanKillQueueInterval)*time.Minute {
delete(ar.killIdQueue, toKillAccount)
}
}
}
}
Expand Down Expand Up @@ -520,7 +523,12 @@ func NewRoutineManager(ctx context.Context, service string) (*RoutineManager, er
default:
}
rm.KillRoutineConnections()
time.Sleep(time.Duration(time.Duration(getPu(rm.service).SV.KillRountinesInterval) * time.Second))
pu := getPu(rm.service)
if pu != nil {
time.Sleep(time.Duration(pu.SV.KillRountinesInterval) * time.Second)
} else {
break
}
}
}()

Expand Down
18 changes: 18 additions & 0 deletions pkg/frontend/routine_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/matrixorigin/matrixone/pkg/common/moerr"
Expand Down Expand Up @@ -219,3 +220,20 @@ func TestRoutineManager_killClients(t *testing.T) {
})
}
}

func Test_rm(t *testing.T) {
sv, err := getSystemVariables("test/system_vars_config.toml")
if err != nil {
t.Error(err)
}
pu := config.NewParameterUnit(sv, nil, nil, nil)
pu.SV.SkipCheckUser = true
pu.SV.KillRountinesInterval = 1
setPu("", pu)
rm, err := NewRoutineManager(context.Background(), "")
assert.NoError(t, err)
rm.cleanKillQueue()
setPu("", nil)
time.Sleep(2 * time.Second)
rm.cancelCtx()
}
Loading