From 4fdae71a9d139a55d84e902958235272f777dab9 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 22 Jul 2024 13:41:58 +0200 Subject: [PATCH 1/2] Fallback to trying old layout --- das/local_file_storage_service.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 621cf3efdb..cad323b165 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -110,17 +110,21 @@ func (s *LocalFileStorageService) Close(ctx context.Context) error { func (s *LocalFileStorageService) GetByHash(ctx context.Context, key common.Hash) ([]byte, error) { log.Trace("das.LocalFileStorageService.GetByHash", "key", pretty.PrettyHash(key), "this", s) - var batchPath string - if s.enableLegacyLayout { - batchPath = s.legacyLayout.batchPath(key) - } else { - batchPath = s.layout.batchPath(key) - } + + legacyBatchPath := s.legacyLayout.batchPath(key) + batchPath := s.layout.batchPath(key) data, err := os.ReadFile(batchPath) if err != nil { if errors.Is(err, os.ErrNotExist) { - return nil, ErrNotFound + data, err = os.ReadFile(legacyBatchPath) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return nil, ErrNotFound + } + return nil, err + } + return data, nil } return nil, err } From 903c937d9eb62c7009f74555f89c999469405285 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 22 Jul 2024 14:23:20 +0200 Subject: [PATCH 2/2] 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 }