Skip to content

Include cache size in manifest segment size#87

Merged
imp merged 7 commits into
mainfrom
fmurphy/segment-size-includes-cache
Jun 30, 2026
Merged

Include cache size in manifest segment size#87
imp merged 7 commits into
mainfrom
fmurphy/segment-size-includes-cache

Conversation

@AnIrishDuck

Copy link
Copy Markdown
Collaborator

The cache is "ephemeral" yes, but there are situations where it actually survives and is e.g. used in the recovery process. It should not be ignored; until it is physically removed from disk, it must be included in the size of its associated segment.

claude added 2 commits June 26, 2026 14:15
The active-chunk cache (.arrows) can persist across a crash — it holds
rows not yet flushed to the main segment file and is read back by
Segment::iter() on the next open. It is only safe to remove after
Writer::end() flushes its contents into the main file.

Previously size_estimate() excluded the cache, so any segment that
survived a crash with a live .arrows file was under-counted in the
manifest (and therefore in retention's accounting). On a busy cluster
these orphaned cache files accumulated to several GiB of invisible
disk usage.

Fix: include cache_path() in Segment::size_estimate(). Remove the now-
redundant cache.size() addition in Writer::size_estimate() (cache.size()
also reads the same .arrows file via fs::metadata, so it would have
double-counted). Segment::destroy() already removes cache_path(), so
retention cleans it up automatically.

Co-Authored-By: Claude <noreply@anthropic.com>
segment_disk_size() added cache_path() to tracked_files (so orphan
detection didn't flag it) but excluded it from the size total via an
explicit guard. This meant UpdateManifestSizes never updated manifest
entries to reflect the cache bytes, leaving existing rows under-counted
even after the size_estimate() fix.

Remove the guard so the cache file is counted the same as other parts.
For sealed segments this corrects the manifest size; for active segments
it gives a more accurate informational delta (process_active_segment
never mutates the manifest anyway).

Co-Authored-By: Claude <noreply@anthropic.com>
@AnIrishDuck AnIrishDuck requested review from JONBRWN and imp June 26, 2026 18:15

@imp imp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've pushed some cleanup commits on top of this branch to make clippy happy. If it passes I am going to merge it.

@imp imp merged commit 7ad8d8c into main Jun 30, 2026
4 checks passed
@imp imp deleted the fmurphy/segment-size-includes-cache branch June 30, 2026 15:47
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.

3 participants