Repository navigation
Description
Context
When an ObjectFS node caches data or writes to S3, other nodes in the cluster have no way to know. This leads to stale reads (a node reads from its local cache while another node has written a newer version to S3) and missed cache-warming opportunities (a node fetches from S3 when a peer already has the data cached).
What to implement
In internal/fuse/filesystem.go, after successful cache operations:
After fs.cache.Put(key, offset, data) (in the read path where data is fetched from backend and stored in cache):
if fs.coordinator != nil {
ann := types.KeyAnnouncement{
Key: key,
NodeID: localNodeID, // from cluster config
Size: int64(len(data)),
CachedAt: time.Now(),
Offset: offset,
Length: int64(len(data)),
}
_ = fs.coordinator.AnnounceKey(ctx, ann) // fire-and-forget
}After fs.backend.PutObject(ctx, key, data) (write path):
if fs.coordinator != nil {
_ = fs.coordinator.InvalidateKey(ctx, key) // broadcasts cache eviction to peers
}After fs.backend.DeleteObject(ctx, key) (delete path):
if fs.coordinator != nil {
_ = fs.coordinator.InvalidateKey(ctx, key)
}InvalidateKey in coordinatorWrapper delegates to the existing ClusterManager.InvalidateCacheKey(key) which already sends gossip broadcast — this just adds the coordinator path.
Both calls are fire-and-forget: errors are logged at DEBUG, never returned to the FUSE caller.
Acceptance criteria
- AnnounceKey is called after each cache.Put (only when coordinator non-nil)
- InvalidateKey is called after PutObject and DeleteObject (only when coordinator non-nil)
- Two-node integration test: node A writes key X, node B's cache for key X is evicted within one gossip round-trip
- Cache benchmarks in
tests/benchmarks/show no regression (coordinator is nil in benchmark setup) go test -race ./internal/fuse/... ./internal/cache/...passes
Sequencing
Depends on A2-1 (coordinator field in FileSystem) and A2-2 (AnnounceKey implemented).
Activity
refactor(cache): delete redis's pub/sub Invalidator, which deleted fr…
feat(types)!: cache coordination on DistributedCoordinator, with stub…
feat(cluster): make cluster.enabled actually start cluster coordinati…
feat(cluster): a write on one node evicts what its peers cached (#141) (