From 903c937d9eb62c7009f74555f89c999469405285 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 22 Jul 2024 14:23:20 +0200 Subject: [PATCH] Fix health check spamming the expiry index --- das/local_file_storage_service.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index cad323b165..5623195657 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -229,7 +229,14 @@ func (s *LocalFileStorageService) String() string { func (s *LocalFileStorageService) HealthCheck(ctx context.Context) error { testData := []byte("Test-Data") - err := s.Put(ctx, testData, uint64(time.Now().Add(time.Minute).Unix())) + // Store some data with an expiry time at the start of the epoch. + // If expiry is disabled it will only create an index entry for the + // same timestamp each time the health check happens. + // If expiry is enabled, it will be cleaned up each time the pruning + // runs. There is a slight chance of a race between pruning and the + // Put and Get calls, but systems using the HealthCheck will just retry + // and succeed the next time. + err := s.Put(ctx, testData /* start of epoch */, 0) if err != nil { return err }