reclaim runs fn for entries whose deadline has passed. Entries are dropped after attempt — a stuck deletion is not retried.
()
| 52 | // reclaim runs fn for entries whose deadline has passed. Entries are dropped |
| 53 | // after attempt — a stuck deletion is not retried. |
| 54 | func (q *quarantine) reclaim() []ReclaimResult { |
| 55 | q.mtx.Lock() |
| 56 | now := time.Now() |
| 57 | // Allocate a fresh keep slice (rather than reslicing q.entries[:0]) so |
| 58 | // dropped entries don't sit in the backing array's hidden capacity and |
| 59 | // keep their captured WAL/complete-block objects from GC. |
| 60 | var keep []quarantineEntry |
| 61 | var due []quarantineEntry |
| 62 | for _, e := range q.entries { |
| 63 | if !now.Before(e.deadline) { |
| 64 | due = append(due, e) |
| 65 | } else { |
| 66 | keep = append(keep, e) |
| 67 | } |
| 68 | } |
| 69 | q.entries = keep |
| 70 | q.mtx.Unlock() |
| 71 | |
| 72 | if len(due) == 0 { |
| 73 | return nil |
| 74 | } |
| 75 | results := make([]ReclaimResult, 0, len(due)) |
| 76 | for _, e := range due { |
| 77 | results = append(results, ReclaimResult{ |
| 78 | BlockID: e.blockID, |
| 79 | Tenant: e.tenant, |
| 80 | BlockType: e.blockType, |
| 81 | Err: e.reclaim(), |
| 82 | }) |
| 83 | } |
| 84 | return results |
| 85 | } |