Skip to content

fix(umbp): an in-place SSD read counts as an access - #793

Merged
TianDi101 merged 7 commits into
mainfrom
fix/umbp-ssd-inplace-read-touch
Oct 16, 2026
Merged

TianDi101 merged 7 commits into
mainfrom
fix/umbp-ssd-inplace-read-touch

Conversation

@TianDi101

Copy link
Copy Markdown
Collaborator

Re-land of #784. #784 merged into its base branch fix/umbp-ssd-segment-reclaim after #775 had already been squash-merged to main, so its change never reached main.

Change

SSDTier::LocateRecord hands a reader the record's fd and offset (GDS reads, in-place migrations) without touching the segment index, so the SSD's segment eviction ranking (#775) never saw those reads. Under promote_mode=move, a page's segment looked cold and mostly empty and was evicted while the same load was still reading its other objects (e2e v10d: a layer-wise get returned 3 of 1,796 keys).

LocateRecord now touches the key and its segment like any other read. Test: SegmentReclaimTest.InPlaceReadCountsAsAnAccess.

Verification

🤖 Generated with Claude Code

TianDi101 and others added 7 commits October 15, 2026 07:23
The file SSD tier is an append-only segment log, and nothing ever deleted
a segment: evicting a key only dropped it from the index, admission
counted live bytes only, so disk use, segment files and open fds grew
with every byte written (#755).  A 200 GB pure-SSD e2e arm filled its
/data drive to 0 bytes free this way and then failed every SSD write.

Space now comes back whole segment files at a time:

- Admission and Capacity() count bytes on disk (every segment's append
  extent, dead records included), so the eviction watermarks and the
  master see what the drive actually holds.
- A segment file is deleted (unlinked, then closed off the tier lock)
  once it is sealed, no key maps into it, and no read or write holds its
  fd.  Reads and writes pin the segment for the I/O they do outside the
  lock; an overwrite also pins the segment of the record it replaces,
  which a failed write restores.  An emptied active segment is rolled
  past so it can go too, and a restart deletes segments it finds nothing
  live in.
- Eviction ranks segments, not keys: the tier offers whole segments'
  keys, a sealed segment scoring (age + 1) / live_fraction so cold and
  mostly-dead segments go first, the active segment last, and each key
  credited with its share of the file.  ShardedSsdTier offers the
  fullest drive first.  PeerPool no longer substitutes the master's
  per-key ranking for a medium that owns its order, since that could
  leave every segment partly live and free nothing.
- GDS file refs carry an fd with no lease, so with UMBP_ENABLE_GDS a
  deleted segment's fd stays open for the SSD read-lease TTL, and the
  cached GDS handle is dropped before the fd number can be reused.
- A new segment is opened only while the filesystem has a segment's
  worth of free space, so a drive filled by something else fails writes
  cleanly instead of with ENOSPC mid-record.
- Segment size: UMBP_SSD_SEGMENT_SIZE env var, and a tier smaller than
  8 segments uses capacity / 8 so eviction always has sealed segments.

Also fixed on the way, since on-disk admission makes them reachable:
- SSDTier::BatchWrite reports each key; a key refused for space used to
  come back true (and an all-refused batch as success), leaving
  PeerSsdManager owning keys the tier never stored.
- RollbackWrite rewinds the append cursor only when its record is still
  the segment's tail, and no longer restores a previous record over a
  newer write of the same key.

Tests: new umbp_ssd_segment_reclaim (#755's churn repro stays bounded,
on-disk admission, eviction order and credits, per-key batch results,
overwrite and startup reclaim, the GDS grace, segment-size cap, sharded
order, and a read/evict/write race that would expose a reused fd).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TierBackend::SpaceStats() reports live bytes, segment files on disk,
files deleted and the bytes they held, and new segments refused because
the filesystem was full.  SsdBackend publishes them as
medium_events_total{event="segment_deleted"|"segment_no_room"},
medium_bytes_total{event="segment_deleted"} and
medium_state{state="live_bytes"|"segment_files"}, so a run shows disk
coming back, and how much of "used" is dead records.  It replaces the
three SSDTier accessors only the tests read, and the refusal count is
now per tier instead of process-wide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The segment-file tier ranks eviction by its own index, whose recency only
reads through the tier refreshed. LocateRecord, the path GDS reads and
in-place promotions take, did not touch it, so under on_read the SSD
evicted in write order whatever was read. With promote_mode move a load
that promoted a page's c4 objects left their segment mostly dead and still
"cold", so it went next, taking the same pages' indexer objects before the
load read them (an e2e run lost 1,793 of 1,796 keys in one get and sglang
died).

LocateRecord now touches the key like any read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-read-touch

# Conflicts:
#	src/umbp/include/umbp/local/tiers/sharded_ssd_tier.h
#	src/umbp/include/umbp/local/tiers/ssd_tier.h
#	src/umbp/local/tiers/sharded_ssd_tier.cpp
…ce-read-touch

# Conflicts:
#	src/umbp/include/umbp/local/tiers/sharded_ssd_tier.h
#	src/umbp/include/umbp/local/tiers/ssd_tier.h
#	src/umbp/local/tiers/sharded_ssd_tier.cpp
#	src/umbp/local/tiers/ssd_tier.cpp
#	tests/cpp/umbp/local/test_ssd_segment_reclaim.cpp
@TianDi101
TianDi101 merged commit 7261cb0 into main Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant