Skip to content

Release - #221

Merged
ovaistariq merged 5 commits into
releasefrom
main
Aug 18, 2026
Merged

ovaistariq merged 5 commits into
releasefrom
main

Conversation

@ovaistariq

@ovaistariq ovaistariq commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Note

Cursor Bugbot is generating a summary for commit 587d865. Configure here.

perfloop Bot and others added 3 commits August 17, 2026 15:28
* perf: write peer get chunks directly

Signed-off-by: Perfloop Agent <[email protected]>

* build: align bench-integration with sibling test targets

Add the proto prerequisite (matching test-integration / test-storage) so the
benchmark binary is never compiled against stale generated code, and document
that -timeout cannot be baked into a compiled test binary — the runner must
pass -test.timeout or a hung benchmark blocks forever.

Signed-off-by: Ovais Tariq <[email protected]>
RocksDB's TTL compaction filter drops every key not rewritten within the
window — including per-segment delete-index records, the FIFO eviction
index, and bucketed access keys. With the DB TTL set to the cache entry
TTL (24h in prod), a segment's delete-index record is silently erased
~24h after its last merge, so the recompactor loses its only
fragmentation signal and dead segment bytes become permanently
unreclaimable. Observed on ORD: 68% of 814 GiB of segments dead with
zero recompactions over 30h; PVCs hit 82%.

Entry expiry is owned by the application cleaner (which scans metadata
and stages reclamation); the engine TTL was redundant for that. Opening
with OpenDbWithTTL(..., 0) disables the filter while preserving the
on-disk value format, so existing DBs stay readable.

Signed-off-by: Ovais Tariq <[email protected]>
* perf: rate limit compaction payload reads

Share one bounded payload-read budget across file compaction and recompaction. Keep source files until synchronized segment metadata is published.

* test: add compaction serving benchmark

Exercise default file compaction against a shared benchmark payload-read lane and bound its backlog drain.

* fix: apply the compaction I/O budget default at the server flag, not the storage layer

The storage-layer clamp (<= 0 -> 16 MiB/s) had three consequences:

- No way to disable throttling: -compaction-bytes-per-second 0 silently became
  the default, unlike -max-disk-usage where 0 means unlimited.
- Embedded/library users were silently throttled: embedded.Config does not set
  the field, so every embedded deployment would inherit a 16 MiB/s compaction
  cap from a library upgrade with no knob to change it.
- Test_CompactionLoop_Performance failed deterministically: the integration
  config leaves the field unset, the clamp applied 16 MiB/s, and the test's
  53.7 MB backlog needs ~3.4s to copy — longer than its 3s wait — so the
  single end-of-pass metadata commit had not happened when it asserted that
  the raw-file count dropped.

Move the default to where the policy belongs: the server flag keeps its
16 MiB/s default (server deployments are throttled by default, as intended),
while the storage layer treats a non-positive value as unthrottled, matching
the 0-disables convention. -compaction-bytes-per-second 0 now genuinely
disables the budget, embedded storage keeps its historical behavior unless a
budget is set via Storage.CompactionBytesPerSecond, and the integration suite
runs unthrottled as its timings assume.

make test-storage, make test-integration-compaction, and make lint pass.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Signed-off-by: Ovais Tariq <[email protected]>

* fix: never block on a busy segment lock while holding the manager lock

With the compaction I/O budget, Segment.WriteEntry holds seg.mu exclusively
for the whole rate-limited payload copy — seconds per entry at the 16 MiB/s
default, vs tens of milliseconds before. AcquireOpenSegmentWithReservation
held the manager-wide sm.mu writer lock while taking seg.mu.RLock() on every
open segment, so probing a mid-copy segment blocked for the entire copy while
holding sm.mu — and every Manager.ReadEntry (the foreground GET path for all
segment-resident objects) queued behind it. Net effect: multi-second serving
stalls on every throttled entry, recreating via lock convoy the exact symptom
the I/O budget exists to prevent. Both compaction workers and the recompactor
re-acquire on ~100ms loops, so the convoy re-formed continuously for a whole
backlog pass.

Fix: probe open segments with seg.mu.TryRLock() and skip on failure. An
exclusively-locked segment is necessarily mid-copy by its reserving owner, so
it could not have been handed to this caller anyway — skipping is semantically
identical to the reservedBy check that would have rejected it, without the
blocking. Acquire was the only sm.mu holder that nested seg.mu
(RefreshMetrics already snapshots specifically to avoid this), and
Segment.Reserve cannot block on a mid-copy segment (a copy requires a
reservation, and a competing reservation cannot be taken while this caller
holds sm.mu), so this single change breaks the convoy chain.

Regression test: TestAcquireSkipsBusySegmentWithoutBlocking holds a segment's
lock (as a rate-limited copy does) and asserts a second caller's Acquire and
the Manager.ReadEntry path complete promptly. Verified to fail with the
pre-fix code (Acquire blocks until timeout) and pass with the fix.

Also from review: RateLimitBytesPerSecond() on the Compactor so the storage
config test can assert the configured budget actually reaches the compactor's
limiter (not just that the input config is preserved), and a help entry for
build-bench-compaction-serving-reads.

make test-storage and make lint pass.

* fix: snapshot open segments before releasing them so ReleaseAllSegments cannot convoy the manager lock

ReleaseAllSegments held sm.mu.RLock while calling seg.Release (which takes
seg.mu.Lock) on every open segment — the same held-manager-lock-blocks-on-
busy-segment coupling fixed in AcquireOpenSegmentWithReservation. It has no
non-test callers today, but a future caller would silently resurrect the
serving-read convoy under the compaction I/O budget. Snapshot the open set
under sm.mu and release outside it (the RefreshMetrics pattern).

* fix: keep the old segment on an incomplete recompaction pass, and make WriteEntry's failure paths actually fail

Two coupled fixes surfaced by the Greptile P1 on this PR ("cancellation drops
live entries" — whose stated scenario is refuted, but whose neighborhood hid
real bugs):

1. Incomplete-pass guard (recompactor). A live entry whose copy fails (or a
   segment read error that hides everything beyond it) previously did not stop
   the post-loop removal: the old segment was unconditionally removed and
   queued for deletion while the failed entry's metadata still pointed into
   it — permanently unreadable data. Pre-existing on main; #219's rate-limited
   copies widen the exposure window. Now any failed entry keeps the old
   segment tracked (delete index preserved) for a later pass; already-copied
   entries are committed and skipped as moved on the retry. The
   all-entries-dead case still removes the segment.

2. WriteEntry's failure paths silently succeeded (pre-existing on main).
   utils.WrapError(msg, path, nil) returns nil, so three failure branches —
   invalid value type, closed segment file, and the copied-bytes/ValueLength
   mismatch — returned (0, nil): success at offset 0. A short source read
   (e.g. a truncated segment) therefore "succeeded", the caller published
   metadata at offset 0 of the new segment, and reads decoded another entry's
   bytes — silent data corruption, reproduced deterministically by the new
   regression test before this fix. On main the same hole is worse: with no
   rollback, s.size is not advanced over the partial bytes, skewing every
   subsequent entry offset in the segment. All three branches now return real
   errors (the mismatch wraps io.ErrUnexpectedEOF).

Regression test TestSegmentRecompaction_IncompletePassKeepsOldSegment builds a
segment, truncates the last entry's payload mid-way, runs a recompaction pass,
and asserts: no error surfaced, the old segment file and manager tracking
survive, intact entries remain readable, and nothing was queued for deletion.
Before these fixes it demonstrated the full corruption chain (victim entry
committed pointing at another entry's bytes).

make test-storage and make lint pass.

Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Ovais Tariq <[email protected]>
@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown

Greptile Summary

This release improves compaction safety and serving-read performance by adding a shared compaction I/O budget, safer segment-write rollback and lifecycle ordering, and remote-stream copy optimizations.

  • Adds server configuration and documentation for a shared compaction/recompaction byte-rate limit.
  • Defers source-file deletion until metadata commits and preserves old segments after incomplete recompaction.
  • Prevents segment-manager lock convoys during rate-limited writes.
  • Disables engine-level metadata TTL in favor of entry cleanup and adds regression coverage.
  • Adds integration and serving-under-compaction benchmarks.

Confidence Score: 5/5

The PR appears safe to merge; no concrete changed-code defect remains after reviewing the compaction, segment lifecycle, configuration, streaming, and benchmark changes.

The new rate-limited copy paths preserve sync-before-metadata ordering, roll back interrupted writes, retain source segments after incomplete migration, and avoid blocking foreground segment reads behind long background writes.

Important Files Changed

Filename Overview
storage/compaction/compactor.go Adds shared rate limiting to raw-file compaction and moves source deletion enqueueing after the metadata commit.
storage/compaction/recompactor.go Shares the compaction limiter, rate-limits segment copies, and retains old segments when a pass cannot migrate every live entry.
storage/compaction/ratelimiter.go Implements cancellable, bounded source-read admission using a shared token-bucket limiter.
storage/segment/manager.go Avoids manager-wide lock convoys by skipping busy segments and releasing reservations from a snapshot.
storage/segment/segment.go Rolls back headers and partial payloads when a segment entry write fails.
storage/storage.go Threads the compaction budget into the compactor and disables RocksDB engine TTL so internal lifecycle indexes do not expire.
server/operations/get.go Adds a zero-relay-copy WriterTo path for remote gRPC streams while preserving prior write chunk sizing and error accounting.
server/main.go Adds and wires the server-level compaction throughput flag.
storage/benchio/read_gate_benchmark.go Adds benchmark-only shared read admission for foreground and background payload traffic.
server/compaction_serving_bench_test.go Adds a benchmark validating serving latency and backlog drainage during compaction.

Reviews (1): Last reviewed commit: "perf: rate limit compaction payload read..." | Re-trigger Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 587d865. Configure here.

Comment thread storage/storage.go Resolved
)

Squash-merging a bot-opened PR creates a commit authored by the bot,
which can never carry a matching Signed-off-by. Require only that some
sign-off trailer is present on bot commits (the reviewing human's merge
is the attestation); human-authored commits still need an exact match.
Unblocks release PRs containing perfloop squash merges.

Signed-off-by: Ovais Tariq <[email protected]>
…#223)

Removing the metadata DB's engine-level TTL (#218) left
StorageConfig.TTL with no consumer: a Put with no key-level TTL never
received an expiry, so configured default expiry silently stopped
working (flagged by Cursor Bugbot on the release PR). Apply the default
app-side in Put, where expiry is enforced by the cleaner — which stages
file and segment reclamation — instead of the engine filter that
dropped bookkeeping keys and orphaned backing bytes.

Signed-off-by: Ovais Tariq <[email protected]>
@ovaistariq
ovaistariq merged commit 17912f7 into release Aug 18, 2026
10 checks passed
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.10.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants