Stop cache eviction in progress at shutdown (closes #102) #173
@@ -1077,6 +1077,30 @@ func TestReconciliationWalksStopOnceCancelled(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestReconciliationPassLogsNoWarningOnceCancelled checks that a
|
||||||
|
// reconciliation pass run with an already cancelled context logs no
|
||||||
|
// warning, so a periodic tick the loop takes after a stop adds no
|
||||||
|
// warning to the one from the pass the stop interrupted.
|
||||||
|
func TestReconciliationPassLogsNoWarningOnceCancelled(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
cache, _ := newEvictionTestCache(t, 1<<30)
|
||||||
|
|
||||||
|
var logBuf bytes.Buffer
|
||||||
|
|
||||||
|
cache.log = slog.New(slog.NewJSONHandler(&logBuf, nil))
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(t.Context())
|
||||||
|
cancel()
|
||||||
|
|
||||||
|
cache.runReconciliationPass(ctx)
|
||||||
|
t.Logf("log output: %s", logBuf.String())
|
||||||
|
|
||||||
|
if strings.Contains(logBuf.String(), `"level":"WARN"`) {
|
||||||
|
t.Errorf("runReconciliationPass logged a warning with a cancelled context")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestEvictSourceBlobExcludesConcurrentStoreOfIdenticalContent exercises
|
// TestEvictSourceBlobExcludesConcurrentStoreOfIdenticalContent exercises
|
||||||
// the exact TOCTOU window between evictSourceBlob's row-deletion
|
// the exact TOCTOU window between evictSourceBlob's row-deletion
|
||||||
// transaction commit and its content file unlink: a concurrent
|
// transaction commit and its content file unlink: a concurrent
|
||||||
|
|||||||
Reference in New Issue
Block a user