diff --git a/stores/metadata.go b/stores/metadata.go index 744261150..4d8b6e097 100644 --- a/stores/metadata.go +++ b/stores/metadata.go @@ -2748,12 +2748,12 @@ func (s *SQLStore) pruneSlabsLoop() { }) } else { s.alerts.DismissAlerts(s.shutdownCtx, pruneSlabsAlertID) + + s.mu.Lock() + s.lastPrunedAt = time.Now() + s.mu.Unlock() } cancel() - - s.mu.Lock() - s.lastPrunedAt = time.Now() - s.mu.Unlock() } } diff --git a/stores/metadata_test.go b/stores/metadata_test.go index 9ecd56422..aa12e3fb8 100644 --- a/stores/metadata_test.go +++ b/stores/metadata_test.go @@ -1219,13 +1219,10 @@ func TestSQLMetadataStore(t *testing.T) { } // Remove the first slab of the object. - ts := time.Now() obj1.Slabs = obj1.Slabs[1:] fullObj, err = ss.addTestObject(objID, obj1) if err != nil { t.Fatal(err) - } else if err := ss.waitForPruneLoop(ts); err != nil { - t.Fatal(err) } else if !reflect.DeepEqual(*fullObj.Object, obj1) { t.Fatal("object mismatch") }