-
Notifications
You must be signed in to change notification settings - Fork 380
Description
Summary
Pinned chunks are not protected from eviction processes, causing permanent data loss when batches expire or storage pressure triggers evictions. This violates the fundamental guarantee that pinned data should persist until explicitly unpinned.
Expected Behavior
Pinned chunks should be excluded from all eviction processes:
- Batch expiry evictions
- Storage pressure evictions
- Manual batch evictions via
EvictBatch()API
Current Behavior
Pinned chunks are evicted along with other chunks when:
- Their postage batch expires
- Storage capacity triggers reserve evictions
- Manual batch eviction is called
After eviction, pin collections reference non-existent chunks, causing download failures with storage.ErrNotFound.
Root Cause
The eviction logic in pkg/storer/internal/reserve/reserve.go:330 (EvictBatchBin) never checks pin status before removing chunks:
func (r *Reserve) EvictBatchBin(ctx context.Context, batchID []byte, count int, bin uint8) (int, error) {
// Iterates through chunks and removes them without pin protection
err := RemoveChunkWithItem(ctx, s, item) // No HasPin() check
}
Steps to Reproduce
- Upload and pin content to a bee node
- Wait for the postage batch to expire, OR trigger storage pressure
- Attempt to download the pinned content
- Observe
storage.ErrNotFound errorsdespite pin status showing as active
Proposed Solution
Add pin protection checks to eviction paths:
- In
EvictBatchBin(): Before adding chunks toevicteditems, check if chunk address exists in any pin collection - In
RemoveChunkWithItem(): Add safety check usingHasPin()before deletion - Performance optimization: Consider caching pin status or maintaining a pin-protected chunk index
Required Changes
- Modify
pkg/storer/internal/reserve/reserve.goeviction logic - Add pin status checks in
pkg/storer/internal/pinning/pinning.go - Update eviction metrics to track pin-protected chunks
- Add integration tests covering pin-eviction scenarios
Impact
- High: Data loss for pinned content
- Affects: All nodes using pinning functionality
- Regression risk: Low (adding protection, not removing functionality)
Additional Context
This issue may be exacerbated during node upgrades when migration processes trigger eviction cleanup, explaining reports of pinned data loss after version upgrades.