* fix: add -verifyCrc to leave needles with damaged data out of the index
weed fix reads only record headers, so a needle whose data was damaged is
indexed and fails on every read. With -verifyCrc it reads each body and
checks it; a needle that fails is not indexed, an older copy of its key is
not brought back, and fix exits non-zero.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: read each record to verify it, so a read error fails instead of dropping it
The scan passes a body buffer even when reading it failed, so -verifyCrc
took bytes it never read for damage. Read the record through a handle of
its own, drop it only when its bytes are corrupt, and fail the scan on any
other read error. -verifyCrc needs the local .dat.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: -verifyCrc rejects a record with a size but no data
A needle with no data is written with size 0, and the CRC covers only the
data, so a record whose data size was zeroed parsed cleanly and skipped
the CRC check. Treat it as corrupt, as the tail repair does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: index a needle that fails -verifyCrc as deleted
Leaving it out of the index let loading the volume read the bytes past
the last indexed needle as an interrupted append: the older copy of the
key came back and the damaged record was cut. Handle it like a delete
marker, so with -includeDeleted its tombstone keeps the key deleted and
the loader leaves the .dat alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix: do not index a record that runs past the end of the .dat
A truncated .dat, or a header whose size points past the file end, left
weed fix indexing a needle the volume cannot serve. Stop the scan at such a
record instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: exit non-zero under -ignoreError when a volume fails
-ignoreError kept going but always exited 0, so an empty or partial index
looked like success. Record the failure in the exit status, and keep the
existing .idx when the super block could not be read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* compact: remove the partial .cpd/.cpx when compaction fails
A failed weed compact exited through glog.Fatalf and left a partial .cpd
next to the volume. Remove both outputs and report the failure in the
exit status instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: skip the end-of-file check for a volume on a remote tier
The scan reads the remote object when the .vif lists one, so a retained
local .dat is the wrong length to check records against.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: keep a key deleted when its last record is truncated
Stopping before a truncated delete record left the key's earlier live
record in the index, so a deleted file came back. Drop the key instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: return the .idx open error from SaveToIdx
The bare return gave back the nil named result, so a failure to open the
index looked like a successful save.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: exit non-zero when a record is cut off by the end of the .dat
A record past EOF ends the scan like a bad header does, so report it the
same way while keeping the index of the records before it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* compact: close the volume before removing a failed compaction's output
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: remove a failed .idx only after SaveToIdx opened it
An open failure no longer reaches the caller's cleanup, so an existing
.idx that could not be opened is left in place.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(s3vectors): drop the worker and CLI flags #12906 removed (#12911)
* test(s3vectors): start weed-worker with only --admin
weed-worker no longer accepts --namespace, --masters or --filer-group; it
takes the Lance Namespace and the filers from admin. The worker jobs passed
all three, so the worker exited on its arguments before registering.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(s3vectors): let weed-vector-cli find the namespace through the masters
weed-vector-cli dropped --namespace and looks the Lance Namespace up among
the gateways the masters list, so the index job test failed on its
arguments once the worker could register.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(volume): verify the .dat-tail needle in the integrity check
CheckVolumeDataIntegrity checked the last entry by file position in the .idx
and, for a live needle, flipped the volume read-only when fileSize > fileTailOffset.
That entry is the .dat tail only when the .idx is in append order; a key-sorted
.idx (weed fix and other rebuilds listed entries by key) puts the highest-key
needle last, whose tail sits mid-file, so healthy volumes went read-only on every
load and re-running weed fix only reproduced the sorted index.
Locate the needle at the maximum offset — the one physically last in the .dat —
and verify the .dat ends exactly at it, regardless of .idx ordering. The
append-ordered common case stays O(1) (the last entry's on-disk end matches the
.dat size); only a key-sorted index pays a single linear scan. Deletion
tombstones at the tail are now verified too, instead of skipping the file-size
check.
* fix(command): weed fix rebuilds the .idx in .dat offset order
SaveToIdx wrote entries via AscendingVisit — sorted by key, the .sdx/.ecx shape
— so the rebuilt .idx put the highest-key needle last instead of the .dat-tail
needle, and dropped tombstones whose live needle was gone. Collect the live and
deleted entries, sort by .dat offset, and write them in append order so the .idx
stays a faithful log whose last entry is the real .dat tail.