Skip to content

Commit b58d313

Browse files
committed
Fix rapid cache cleanup logic bugs
- Fix Redis error skipping bucket cleanup: Fall back to GCS timestamp when Redis LastAccess fails - Fix index deletes skipping access recheck: Recheck LastAccess before deletion to prevent removing recently touched objects - Fix index cleanup error blocking bucket scan: Log error and continue to cleanFromBucket even if cleanFromIndex fails
1 parent 1043f73 commit b58d313

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • packages/orchestrator/cmd/clean-rapid-cache

packages/orchestrator/cmd/clean-rapid-cache/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func clean(ctx context.Context, bucket string, prefix string, cutoff time.Time,
7373

7474
deleted, err := cleanFromIndex(ctx, client, bucket, cutoff, maxDeletions, dryRun, index)
7575
if err != nil {
76-
return err
76+
log.Printf("cleanFromIndex failed (continuing with bucket scan): %v", err)
7777
}
7878

7979
return cleanFromBucket(ctx, client, bucket, prefix, cutoff, maxDeletions-deleted, dryRun, index)
@@ -99,6 +99,10 @@ func cleanFromIndex(ctx context.Context, client *gcs.Client, bucket string, cuto
9999
if err != nil {
100100
return deleted, fmt.Errorf("read cache object metadata: %w", err)
101101
}
102+
lastAccess, ok, err := index.LastAccess(ctx, path)
103+
if err == nil && ok && lastAccess >= cutoff.Unix() {
104+
continue
105+
}
102106
if dryRun {
103107
deleted++
104108

@@ -135,10 +139,7 @@ func cleanFromBucket(ctx context.Context, client *gcs.Client, bucket string, pre
135139
continue
136140
}
137141
lastAccess, ok, err := index.LastAccess(ctx, attrs.Name)
138-
if err != nil {
139-
continue
140-
}
141-
if ok && lastAccess >= cutoff.Unix() {
142+
if err == nil && ok && lastAccess >= cutoff.Unix() {
142143
continue
143144
}
144145
matched++

0 commit comments

Comments
 (0)