Skip to content

fix: reset stale location counts in merge mode - #1

Merged
ajroetker merged 2 commits into
antflydb:antflydb-mainfrom
ajroetker:fix/mergemode-stale-loc-counts
Jul 24, 2026
Merged

fix: reset stale location counts in merge mode#1
ajroetker merged 2 commits into
antflydb:antflydb-mainfrom
ajroetker:fix/mergemode-stale-loc-counts

Conversation

@ajroetker

Copy link
Copy Markdown

Summary

  • reset numLocValues and numFieldIDs when a posting has no locations in merge mode
  • add a regression that merges interleaved postings with and without term vectors

Root cause

nextAtOrAfter only assigned the location counters for postings that had locations. A location-less posting therefore inherited the previous posting counters. mergeTermFreqNormLocs infers location presence from those counters and consumed values belonging to later postings until the chunk failed with read location values: EOF.

The failure is deterministic when the same term appears in both a term-vectored field and a plain field. Segment bytes are valid; this is a merge-reader state leak.

Validation

Related incident: antflydb/antfly#381

excenter added 2 commits July 24, 2026 12:38
…rge mode

A hasLocs=false posting left numLocValues/numFieldIDs holding the previous
posting's counts. mergeTermFreqNormLocs infers hasLocs from
NumLocationValues()>0, so the merge reader consumed location values that
belonged to later postings until the chunk underflowed with
'read location values: EOF'. Any postings list where a term appears both
in a term-vectored field and a plain field (numeric tokens, ids) hits
this; the resulting merge failure is deterministic and retries forever.

Query path is unaffected (it gates on hasLocs directly). Verified against
four production segments from three environments: all fail merge before
this change, all merge cleanly after; zapx test suite green (the three
pre-existing arm64/NEON StreamVByte failures are unrelated and tracked
separately).
Builds a segment where one term produces a postings list interleaving
hasLocs=true and hasLocs=false postings, with another hasLocs=true
posting after a false one, then merges it. Before the stale count reset
this failed deterministically with 'read location values: EOF'; also
verifies per-posting freq and location counts in the merged output.
@ajroetker
ajroetker merged commit bdf8ce7 into antflydb:antflydb-main Jul 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants