mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: gc only do once (#32722)
issue: #29655 produced by pr: #31740 Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
parent
b6c06ff2c3
commit
77f4f0c5a8
@ -174,7 +174,7 @@ func (gc *garbageCollector) work(ctx context.Context) {
|
||||
}
|
||||
|
||||
// startControlLoop start a control loop for garbageCollector.
|
||||
func (gc *garbageCollector) startControlLoop(ctx context.Context) {
|
||||
func (gc *garbageCollector) startControlLoop(_ context.Context) {
|
||||
for {
|
||||
select {
|
||||
case cmd := <-gc.cmdCh:
|
||||
@ -203,7 +203,7 @@ func (gc *garbageCollector) startControlLoop(ctx context.Context) {
|
||||
// runRecycleTaskWithPauser is a helper function to create a task with pauser
|
||||
func (gc *garbageCollector) runRecycleTaskWithPauser(ctx context.Context, name string, interval time.Duration, task func(ctx context.Context)) {
|
||||
logger := log.With(zap.String("gcType", name)).With(zap.Duration("interval", interval))
|
||||
timer := time.NewTimer(interval)
|
||||
timer := time.NewTicker(interval)
|
||||
defer timer.Stop()
|
||||
|
||||
for {
|
||||
|
||||
@ -1614,6 +1614,26 @@ func (s *GarbageCollectorSuite) TestPauseResume() {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *GarbageCollectorSuite) TestRunRecycleTaskWithPauser() {
|
||||
gc := newGarbageCollector(s.meta, newMockHandler(), GcOption{
|
||||
cli: s.cli,
|
||||
enabled: true,
|
||||
checkInterval: time.Millisecond * 10,
|
||||
scanInterval: time.Hour * 7 * 24,
|
||||
missingTolerance: time.Hour * 24,
|
||||
dropTolerance: time.Hour * 24,
|
||||
})
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*2500)
|
||||
defer cancel()
|
||||
|
||||
cnt := 0
|
||||
gc.runRecycleTaskWithPauser(ctx, "test", time.Second, func(ctx context.Context) {
|
||||
cnt++
|
||||
})
|
||||
s.Equal(cnt, 2)
|
||||
}
|
||||
|
||||
func TestGarbageCollector(t *testing.T) {
|
||||
suite.Run(t, new(GarbageCollectorSuite))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user