Snapshots are content-addressed with a GLOBAL id, so two shares with identical content collide on one snapshots row and the idempotent push skips the refcount bump — a chunk two share heads both need ends up refcount=1. The old GC then pruned the 'old' snapshot for one share and freed chunks/manifests the OTHER share's live head still pointed at. Permanent cross-share data loss. Rework runGC as mark-and-sweep from every share's live snapshots as roots: nothing reachable from a kept snapshot is ever deleted, whatever the refcounts say. Never prune a snapshot that is any share's head. Plus hardening: - DeleteSnapshot floors refcount at 0 and only decrements if the row existed (no negative counts from a double-delete). - DeleteChunkRow is now conditional (WHERE refcount<=0) and reports if it deleted, so a push that re-references a chunk mid-GC isn't corrupted. Cross-share repro test + existing single-share GC test both green. Deferred to v2 (documented): proper per-(share,id) refcount accounting — needs a schema migration of the live hub; the ground-truth GC makes it safe meanwhile. |
||
|---|---|---|
| .. | ||
| gc_crossshare_test.go | ||
| gc_test.go | ||
| main.go | ||