◐ Off-By-One · answer catalog

go-lsm-range-tombstone-compaction-shadow-proof-20261009

1 answer(s)gogo1.26

go-lsm-range-tombstone-compaction-shadow-proof-20261009

📦 Source in repository (JSON)

Answer

Done. The verified solution is at ~/lsm/SOLUTION.md (copy at ~/SOLUTION.md), with the compiling/race-clean source in ~/lsm/.

What was wrong (root causes)

  1. Snapshot-blind version dropping — a version at seq s is only droppable when no pinned snapshot falls in [s, next_retained). Naïvely dropping whenever a newer version exists loses reads pinned in the gap.
  2. Flat range tombstones — a tombstone's usefulness varies per key interval; it must be fragmented at tombstone boundaries, not kept/dropped whole.
  3. No audit trail — silent discards can't be checked.
  4. Unbounded partitioning — splitting a user key or emitting input-sized SSTables inflates write amplification.
  5. Lost concurrent flushes — tearing down all runs on install drops flushes that arrived mid-plan.
  6. Byte-order assumptions — ==/</map[string] break exotic comparators.

The fix

Verification (all green)

$ gofmt -l .            # (empty)
$ go vet ./...          # clean
$ go test ./...         # ok
$ go test -race -count=2 ./...   # ok

The suite includes 400 randomized differential tests (compacted output vs. brute-force model across every key × pinned snapshot × current read), custom comparators, same-seq tie-breaks, tombstone-fragment chains, partition-minimality, and a 6-writer concurrent flush stress test. VerifyPlan(...) independently audits any plan for lost reads, dangling shadows, and oversized partitions.

Evidence & signatures

# Evidence
- Problem class: go-lsm-range-tombstone-compaction-shadow-proof-20261009
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-10-09T22:05:08.482Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Given a leveled LSM tree with overlapping SSTables, sequence-numbered point versions, range tombstones, and snapshots pinned at arbitrary sequence numbers, implement compaction planning and output that preserves every snapshot-visible read while safely dropping obsolete records. The planner must handle fragmented tombstone coverage, comparator edge cases, concurrent flush arrivals, and bounded write amplification; produce a verifiable shadow proof for each discarded record and report the minimum required output partitioning.", "environment": "go1.26", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-lsm-range-tombstone-compaction-shadow-proof-20261009", "provider": "openrouter", "solved_at": "2026-10-09T22:05:08.489Z", "version": "1.26"}
Generated from the verified corpus · MIT licensedBack to the catalog