Files
seaweedfs/weed/storage
Chris LuandClaude Opus 5.5 b0d12a71af volume: keep the heartbeat moving while a compaction commit holds a volume (#13365)
* volume: report the commit-start status while a compaction commit holds the volume

CommitCompact holds dataFileAccessLock across makeupDiff and the reload,
which on a large volume takes longer than the master's heartbeat
timeout. The heartbeat reads every volume of the server through
collectStatus, so it waited out the commit and the master unregistered
the whole server.

The commit now pins the status it starts from, and status reads answer
with it until the commit is done, instead of queueing behind its
exclusive lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): report the commit-start status while a compaction commit holds the volume

The Rust commit closes the needle map and .dat and reloads the compacted
files under the io write lock. The heartbeat read each volume's counts
through that lock, so it waited out the reload, and between the close and
the reload it reported the volume as empty.

Mirror the Go change: the commit pins the status it starts from, and
collect_status answers with it until the commit is done. The heartbeat
reads all of a volume's counts through one collect_status call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: report the compaction revision with the commit-start status

The commit reloads the superblock before it lets status reads see the
live volume again, so a heartbeat in between paired the new compaction
revision with the pinned counts, and the changed hash sent that mixed
report. The revision is now part of the status the commit pins, in Go
and in Rust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: size auto-sized disks from the commit-start footprint

MaybeAdjustVolumeMax runs just before every heartbeat and, for a disk
without a fixed -max, reads each writable volume's .dat and .idx sizes
through the data lock, so it still waited out a compaction commit.
UnUsedSpace now reads the footprint the commit pinned while one holds
the volume, in Go and in Rust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): recheck expiry from the commit-start status

The heartbeat's expiry recheck runs under the store write lock and read
the .dat size through the io lock, so a TTL volume that came due while a
compaction commit reloaded it held the heartbeat until the reload ended.
It now reads the size from collect_status, and delete_volume keeps
refusing the committing volume until a later pulse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: refuse to delete a committing volume without waiting for it

Destroy takes the data locks a compaction commit holds across its
reload, and the heartbeat deletes expired TTL volumes under the
location's volumes lock, so a volume that came due mid-commit stalled
the heartbeat. deleteVolumeById now refuses a compacting volume up
front, as the Rust volume server's delete_volume does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: claim the volume before Destroy takes its data locks

deleteVolumeById checked the compaction flag and only then let Destroy
take the data locks, so a commit that claimed the volume in between
still made the delete wait out its reload under the volumes lock.
CommitCompact claims before it locks, so Destroy now does the same and
refuses a claimed volume without waiting; the separate check in
deleteVolumeById is no longer needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): refuse to destroy a volume whose sync lock is held

Every destroy runs under the store write guard, and the vacuum-commit
RPC takes the sync lock and waits out leased readers before it marks
the volume compacting, so an expiry deletion in that window passed the
compacting check and then stalled the heartbeat behind the commit.
destroy now try-locks the sync lock, as commit_compact does, and a
refused deletion keeps the volume mounted for a later pulse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): keep the CompactionClaim doc on CompactionClaim

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): report a volume a collection delete could not destroy

The collection delete logged a refused destroy, kept the volume mounted
and still answered success, so the caller never retried. Return the first
error after the loop, as the Go store does, while the other volumes of the
collection are still deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): claim a volume before the commit and destroy take its locks

destroy try-locked the sync lock so a delete under the store write guard
would not wait out a commit's reader drain, but every write holds that
lock across its fsync, so a volume or collection delete racing an upload
was refused. Claim the volume first, as Go's CommitCompact and Destroy
do: the commit RPC claims before it takes the sync lock and waits for
readers, and destroy claims, waits for the locks only behind writes, and
refuses a claimed volume without waiting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: skip the missing-.dat check while a volume is compacting

A status read no longer waits out a commit, and on Windows the commit
removes the .dat before it renames the compacted one in, so a heartbeat
in that gap took the volume for one whose .dat was unlinked and left it
out of the report. The commit-start status already stands in for the
volume until the commit ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): skip the missing-.dat check while a volume is compacting

Mirrors the Go change: the heartbeat reads the commit-start status
without waiting for the commit, and a Windows commit removes the .dat
before it renames the compacted one in, so the check dropped the volume
from a heartbeat taken in that gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): keep the new delete and heartbeat tests beside related ones

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: report a compacting volume a collection delete left mounted

Destroy refuses a volume a commit has claimed, so the collection delete
no longer filters compacting volumes out silently; the refusal is
returned and the master keeps the collection to retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): report a compacting volume a collection delete left mounted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: confirm a missing .dat under the compaction claim

The compaction flag was read before the stat, so a commit starting in
between could have its Windows swap taken for a phantom. Stat first and
recheck a missing .dat while holding the claim; a held claim defers the
verdict to a later heartbeat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): confirm a missing .dat under the compaction claim

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): expect a collection delete to refuse an in-flight compaction

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:31:58 -08:00
..