Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix ttl objects

chrislua265a0792228
diff --git a/weed/filer/tikv/tikv_store.go b/weed/filer/tikv/tikv_store.go
index c02f2c22ee..3708ddec57 100644
--- a/weed/filer/tikv/tikv_store.go
+++ b/weed/filer/tikv/tikv_store.go
@@ -10,6 +10,7 @@ import (
"fmt"
"io"
"strings"
+ "time"
"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/glog"
@@ -265,7 +266,21 @@ func (store *TikvStore) ListDirectoryPrefixedEntries(ctx context.Context, dirPat
break
}
- // Only increment counter after successful processing
+ // Check TTL expiration before calling eachEntryFunc (similar to Redis stores)
+ if entry.TtlSec > 0 {
+ if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
+ // Entry is expired, delete it and continue without counting toward limit
+ if deleteErr := store.DeleteEntry(ctx, entry.FullPath); deleteErr != nil {
+ glog.V(0).InfofCtx(ctx, "failed to delete expired entry %s: %v", entry.FullPath, deleteErr)
+ }
+ if err := iter.Next(); err != nil {
+ break
+ }
+ continue
+ }
+ }
+
+ // Only increment counter for non-expired entries
i++
if err := iter.Next(); !eachEntryFunc(entry) || err != nil {