weaviate/weaviate · error
unsupported strategy in segment: %w
Error message
unsupported strategy in segment: %w
What it means
Thrown in newSegment (segment.go:320) when segmentindex.CheckExpectedStrategy rejects header.Strategy. The header parsed fine, but the segment's strategy identifier isn't one the bucket expects (replace/set/map/inverted), indicating the file is either corrupt or belongs to a bucket of a different strategy configuration.
Source
Thrown at adapters/repos/db/lsmkv/segment.go:320
unMapContents = true
} else { // read the file into memory if it's small enough and we have enough memory
meteredF := diskio.NewMeteredReader(file, diskio.MeteredReaderCallback(metrics.ReadObserver("readSegmentFile")))
bufio.NewReader(meteredF)
contents, err = io.ReadAll(meteredF)
if err != nil {
return nil, fmt.Errorf("read file: %w", err)
}
unMapContents = false
readFromMemory = true
useBloomFilter = false
}
header, err := segmentindex.ParseHeader(contents[:segmentindex.HeaderSize])
if err != nil {
return nil, fmt.Errorf("parse header: %w", err)
}
if err := segmentindex.CheckExpectedStrategy(header.Strategy); err != nil {
return nil, fmt.Errorf("unsupported strategy in segment: %w", err)
}
if header.Version >= segmentindex.SegmentV1 && cfg.enableChecksumValidation {
file.Seek(0, io.SeekStart)
headerSize := int64(segmentindex.HeaderSize)
if header.Strategy == segmentindex.StrategyInverted {
headerSize += int64(segmentindex.HeaderInvertedSize)
}
segmentFile := segmentindex.NewSegmentFile(segmentindex.WithReader(file))
if err := segmentFile.ValidateChecksum(size, headerSize); err != nil {
return nil, fmt.Errorf("validate segment %q: %w", path, err)
}
}
primaryIndex, err := header.PrimaryIndex(contents)
if err != nil {
return nil, fmt.Errorf("extract primary index position: %w", err)
}View on GitHub (pinned to 75aa4b6d11)
Solutions
- Identify the segment's actual strategy (decode the header) and move it back to the bucket directory of the matching strategy/object store.
- If the strategy byte is corrupted (bitrot), treat the segment as corrupt: drop the shard and restore from backup or rebuild from replicas.
- Never manually relocate segment files between bucket directories; use Weaviate's backup/restore tooling.
- Upgrade-in-place scenarios: confirm both source and target Weaviate versions use the same strategy identifiers.
- Re-ingest the affected collection if no backup exists.
Example fix
// before: inverted-index segment accidentally placed in the object bucket dir mv segment-3 /var/lib/weaviate/.../shard/lsm/objects/ // after: keep each strategy's segments in their own bucket directories mv segment-3 /var/lib/weaviate/.../shard/lsm/inverted/
Defensive patterns
Strategy: type-guard
Validate before calling
func segmentMatchesBucket(path string, expected segmentindex.Strategy) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
buf := make([]byte, segmentindex.HeaderSize)
if _, err := io.ReadFull(f, buf); err != nil {
return err
}
h, err := segmentindex.ParseHeader(buf)
if err != nil {
return err
}
return segmentindex.CheckExpectedStrategy(h.Strategy)
} Type guard
func strategyIsKnown(s segmentindex.Strategy) bool {
switch s {
case segmentindex.StrategyReplace,
segmentindex.StrategySet,
segmentindex.StrategyMap,
segmentindex.StrategyInverted:
return true
default:
return false
}
} Try / catch
if err := segmentindex.CheckExpectedStrategy(header.Strategy); err != nil {
return nil, fmt.Errorf("segment %q strategy %v misplaced or corrupt: %w", path, header.Strategy, err)
} Prevention
- Never move segment files between bucket directories (objects vs inverted index); each bucket dir belongs to one strategy.
- Restore shards only through Weaviate's backup module, not manual file copying.
- Validate the whole shard directory (header check per segment) after any manual recovery operation.
- Keep all cluster nodes on the same Weaviate version so strategy identifiers match.
When it happens
Trigger: Loading a segment into a bucket whose expected strategy (from segmentConfig) doesn't match the strategy stamped in the segment header — e.g. a segment written as 'map' (BM25) opened where 'replace' is expected, a strategy byte corrupted after write, or a foreign/garbage file renamed to look like a segment.
Common situations: Pointing a bucket at a directory mixing segments from different bucket types (manual file moves between object and inverted-index buckets); storage corruption flipping the strategy field; restoring partial backups that mix segment files; hand-crafted test data with invalid strategy constants.
Related errors
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/faab5920df21e2e6.
Report an issue: GitHub.