From 12affc858deec7d2132e4aea9e387a45b7d69a17 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 10 Jul 2024 13:38:06 +0200 Subject: [PATCH 1/2] Always make expiry index --- das/local_file_storage_service.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 6b0a5f0070..621cf3efdb 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -199,7 +199,7 @@ func (s *LocalFileStorageService) Put(ctx context.Context, data []byte, expiry u } } - if !s.enableLegacyLayout && s.layout.expiryEnabled { + if !s.enableLegacyLayout { if err := createHardLink(batchPath, s.layout.expiryPath(key, expiry)); err != nil { return fmt.Errorf("couldn't create by-expiry-path index entry: %w", err) } @@ -360,11 +360,9 @@ func migrate(fl *flatLayout, tl *trieLayout) error { return err } - if tl.expiryEnabled { - expiryPath := tl.expiryPath(batch.key, uint64(batch.expiry.Unix())) - if err = createHardLink(newPath, expiryPath); err != nil { - return err - } + expiryPath := tl.expiryPath(batch.key, uint64(batch.expiry.Unix())) + if err = createHardLink(newPath, expiryPath); err != nil { + return err } migrated++ } @@ -698,10 +696,8 @@ func (l *trieLayout) startMigration() error { return err } - if l.expiryEnabled { - if err := os.MkdirAll(filepath.Join(l.root, byExpiryTimestamp+migratingSuffix), 0o700); err != nil { - return err - } + if err := os.MkdirAll(filepath.Join(l.root, byExpiryTimestamp+migratingSuffix), 0o700); err != nil { + return err } return nil @@ -726,10 +722,8 @@ func (l *trieLayout) commitMigration() error { return err } - if l.expiryEnabled { - if err := removeSuffix(byExpiryTimestamp); err != nil { - return err - } + if err := removeSuffix(byExpiryTimestamp); err != nil { + return err } syscall.Sync() From 55e7d456981a65757911c6a22e22bb48198e3601 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 10 Jul 2024 17:20:44 +0200 Subject: [PATCH 2/2] Fix check for iter by expiry when expiry disabled --- das/local_file_storage_service_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/das/local_file_storage_service_test.go b/das/local_file_storage_service_test.go index 0b2ba9749d..cc27e293e3 100644 --- a/das/local_file_storage_service_test.go +++ b/das/local_file_storage_service_test.go @@ -98,10 +98,9 @@ func TestMigrationNoExpiry(t *testing.T) { countEntries(t, &s.layout, 4) getByHashAndCheck(t, s, "a", "b", "c", "d") - _, err = s.layout.iterateBatchesByTimestamp(time.Unix(int64(now+10), 0)) - if err == nil { - Fail(t, "can't iterate by timestamp when expiry is disabled") - } + // Can still iterate by timestamp even if expiry disabled + countTimestampEntries(t, &s.layout, time.Unix(int64(now+11), 0), 4) + } func TestMigrationExpiry(t *testing.T) {