Skip to content

Missing global index metadata can silently prune matching rows #577

Description

@XiaoHongbo-Hope

Search before asking

  • I searched the existing issues and found nothing similar.

Please describe the bug

On the latest main commit a9a8f6b, GlobalIndexScanner converts missing or unparseable sorted global-index metadata into BTreeIndexMeta(None, None, false). BTreeIndexMeta then interprets that value as an only-null index.

For equality and range predicates, file-level pruning reports no match without opening the physical index file. The scanner returns an indexed result such as Some([]) instead of None, so rows covered by that index shard can be silently omitted in fast, full, and detail search modes.

A minimal reproduction uses two BTree shards for the same field: one with valid metadata and one with missing metadata. Querying a key present in both shards returns only the valid shard result instead of falling back to the normal table scan.

Malformed key lengths are related: BTreeIndexMeta::deserialize currently slices with unchecked lengths and can panic before the scanner can handle the parse error.

Solution

Preserve missing or unparseable metadata as unavailable and return None when evaluating that field, allowing the caller to use the normal table scan. Validate serialized key lengths before slicing so malformed metadata returns InvalidData instead of panicking.

Are you willing to submit a PR?

  • I am willing to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions