Skip to content

index: fix repeated v2 index merge panic#101

Open
idrassi wants to merge 1 commit intogoogle:masterfrom
amcrypto-jp:issue-100-cindex-no-progress
Open

index: fix repeated v2 index merge panic#101
idrassi wants to merge 1 commit intogoogle:masterfrom
amcrypto-jp:issue-100-cindex-no-progress

Conversation

@idrassi
Copy link
Copy Markdown

@idrassi idrassi commented Apr 15, 2026

Fixes #100.

Repeated cindex runs against a v2 index could panic during merge with:

panic: no progress

The merge reader used ^uint32(0) as its internal EOF marker, while the on-disk posting-list sentinel is invalidTrigram (0x00ffffff). As a result, merge treated the serialized sentinel as a normal trigram and then emitted another sentinel at EOF. Each successful merge accumulated another serialized sentinel and a later merge could stop making progress through the duplicate sentinel entries.

This change makes merge sentinel handling use invalidTrigram consistently. It also restores lazy posting-list writes so ordinary trigrams with no surviving file IDs are omitted, while the final sentinel is still emitted.

A regression test now repeatedly merges v2 indexes and checks that the merged index remains valid and does not grow extra posting entries.

Testing:

go test ./...

I also verified the issue reproduction manually on linux/amd64 with repeated no-argument cindex runs. The patched binary completed repeated reindexes, cindex-check -list passed and the final posting index contained exactly one 0xffffff sentinel with no non-increasing trigram entries.

Repeated merges of v2 indexes could treat the on-disk posting-list sentinel, invalidTrigram (0x00ffffff), as a normal trigram because the merge reader used ^uint32(0) as its internal EOF marker. That let duplicate serialized sentinels accumulate in the posting index, and a later cindex run could panic with no progress while merging.

Use invalidTrigram consistently in postMapReader and merge sentinel handling. Restore lazy posting-list writes so ordinary trigrams with no surviving file IDs are omitted while the final sentinel is still emitted.

Add a repeated-merge regression test that checks merged v2 indexes stay valid and do not grow extra posting entries.

Fixes google#100.
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 15, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

cindex "panic: no progress" in v1.3.0-rc1

1 participant