Skip to content

Fix bool index reload as immutable on appendable segments - #8785

Merged
agourlay merged 1 commit into
devfrom
fix-bool-index-reload
Apr 24, 2026
Merged

agourlay merged 1 commit into
devfrom
fix-bool-index-reload

Conversation

@agourlay

@agourlay agourlay commented Apr 24, 2026 •

Copy link
Copy Markdown
Member

Fixes a regression introduced by #8625 that prevents Qdrant from starting when a collection has a bool payload index.

Symptom

ERROR collection::collection_manager::collection_updater: Update operation failed: Service internal error: Can't add values to immutable bool index

Triggered on WAL replay during startup, on any appendable segment with a bool payload index; regardless of whether the index was created before or after #8625.

Root cause

BoolIndex::get_storage_type() returns StorageType::Mmap for both MutableBoolIndex and ImmutableBoolIndex (they share the same on-disk format).

The persisted index type for a bool index on an appendable segment is therefore { mutability: Mutable, storage_type: Mmap }.

On reload, StructPayloadIndex::selector_with_type dispatches purely on storage_type.

After #8625, IndexSelector::Mmap + bool_new unconditionally opens an ImmutableBoolIndex — ignoring the stored mutability.

Any subsequent add_many call (e.g. WAL replay) hits the "Can't add values to immutable bool index" error arm.

Fix

bool_new now takes an IndexMutability parameter and branches on it in the Mmap arm:

  • Mutable → MutableBoolIndex::open → BoolIndex::Mmap
  • Immutable → ImmutableBoolIndex::open → BoolIndex::Immutable

Callers pass:

  • new_index_with_type (reload): index_type.mutability from config
  • new_index (fresh migration): derived from selector — Mmap → Immutable,
    Gridstore → Mutable

Since the on-disk format is shared, existing segments load unchanged; only the in-memory wrapper differs.

Test

Added test_bool_index_appendable_reopen_accepts_updates in lib/segment/tests/integration/payload_index_test.rs.

It builds an appendable StructPayloadIndex with a bool-indexed field, drops it, reopens it, and performs an update. Fails against pre-fix code with the exact error from the report; passes with the fix.

@agourlay
agourlay marked this pull request as ready for review April 24, 2026 10:15
@agourlay
agourlay requested a review from timvisee April 24, 2026 10:22
@qdrant qdrant deleted a comment from coderabbitai Bot Apr 24, 2026
Comment on lines +475 to +485
// `MutableBoolIndex` and `ImmutableBoolIndex` share the same on-disk
// format; stored mutability picks which in-memory wrapper to build.
match mutability {
IndexMutability::Immutable => {
ImmutableBoolIndex::open(&dir, id_tracker.deleted_point_bitslice())?
.map(BoolIndex::Immutable)
}
IndexMutability::Mutable => {
MutableBoolIndex::open(&dir, create_if_missing)?.map(BoolIndex::Mmap)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Key change is here.

The null index PR definitely needs the same treatment.

I'm not so sure about the numeric index PR, because it handles immutable state differently:

if effective_is_on_disk {
// Use on mmap directly
Ok(Some(NumericIndexInner::Mmap(mmap_index)))
} else {
// Load into RAM, use mmap as backing storage
Ok(Some(NumericIndexInner::Immutable(
ImmutableNumericIndex::open_mmap(mmap_index),
)))
}

@timvisee timvisee mentioned this pull request Apr 24, 2026
12 tasks done
@agourlay
agourlay merged commit d436351 into dev Apr 24, 2026
15 checks passed
@agourlay
agourlay deleted the fix-bool-index-reload branch April 24, 2026 10:52
@generall generall added this to the Live-reload milestone May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants