mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
* volume.check.disk: resurrect needles a vacuumed replica provably never had -resurrectMissingNeedles copies a needle that is live on one replica and absent on the other only into a replica that was never vacuumed: a vacuum erases deleted needles together with their delete markers, so on a vacuumed replica an absent needle may be a delete. Once every replica has been vacuumed, a replica that lost writes, the tail of its volume after a crash for one, has no repair but copying the whole volume. A vacuum erases only among the needles the index holds when it commits. The volume now records the largest needle id it held then, deleted ones included, in its .vif (VolumeInfo.vacuumed_max_file_key), before the vacuumed files replace the old ones. A needle with a larger id that the replica has no index entry for was never deleted there, since no vacuum has touched its marker: it was never written there. volume.check.disk -resurrectMissingNeedles reads the record with the compaction revision and copies such needles back; absent needles up to the recorded id are left alone as before. The record is only good if no vacuum went unrecorded, so it starts at a volume's first vacuum and is kept through each one after it. A volume vacuumed before it had a record never gets one and keeps the present rule. A copy of a volume takes the record along in the .vif. * volume.check.disk: look at vacuumed replicas whose live counts match, and judge only what stays unrepaired Two replicas at different compaction revisions with equal live counts were skipped under -resurrectMissingNeedles when both had been vacuumed, since neither could take a needle back. One that recorded its vacuums can, and a missed write plus a missed delete leave the live counts equal. Under the flag such a pair is now compared. A run without -apply ends with a verdict on the needles one replica has and the other lacks. It counted the ones the run would have resurrected with -apply, so two replicas each missing needles above the other's recorded id were called a split brain not to be repaired. Needles above the recorded id of the replica lacking them are left out of the verdict. * volume: trust the vacuum record only at the revision it was written for A vacuum by a volume server that does not keep vacuumed_max_file_key (an older Go one, or the Rust one) erases delete markers above the record but leaves the .vif as it was. Once a server that reads the record serves the volume again, volume.check.disk -resurrectMissingNeedles takes those ids for missing writes and raises deleted needles. The record now names the compaction revision its vacuum produced. It is saved after the swap, so a vacuum that fails to record it leaves a revision that no longer matches, and check.disk and later vacuums only take it up while it equals the volume's live revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: number the vacuum record fields 12 and 13 VolumeInfo 10 and 11 already carry other bool fields in a downstream build. A volume server of that build answering ReadVolumeFileStatus would read here as vacuumed_max_file_key 1 at revision 1, a record that lets check.disk resurrect every absent needle. The .vif is keyed by name, so only the wire numbers move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): record the largest needle id a vacuum could have erased Mirror the Go volume server: VolumeInfo carries vacuumed_max_file_key and the compaction revision it was taken at (fields 12 and 13). commit_compact keeps the record through every vacuum once the volume has one, saves it after the swap, and drops it once a vacuum went unrecorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep the ids of cut tail needles in the decoded index The EC decoder dropped the .idx row of a deleted needle past the decoded .dat, so the compaction that follows recorded a vacuumed max needle id below it. volume.check.disk -resurrectMissingNeedles could then copy that deleted needle back from a stale replica. Write the row as a tombstone without the offset instead, as Go keeps every .ecx row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): count tombstone keys toward the max file key on redb loads metrics_from_idx skipped the max-key update for tombstone rows, unlike Go's needleMapMetricFromIndexFile and the in-memory replay. A deleted tail needle then left a redb volume's vacuum record below its id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>