apache / apache/lucene

Lucene41PostingsReader.advance() doc scanning is buggy [LUCENE-6014]

Open
#7,076 3 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Major type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

The "code duplication" here to optimize scanning to target after "possible skipping" looks really buggy.

For example, it never checks to refill buffer in the loop if it gets exhausted. But the code gives no indication about why its safe for it to make this assumption.

If nobody understands why this optimization is allowed to make such a shortcut, then please add a comment indicating why, with asserts tied to exact specific constants in skipwriter (if applicable), otherwise i will remove the optimization completely in 72 hours.

---
Migrated from [LUCENE-6014](https://issues.apache.org/jira/browse/LUCENE-6014) by Robert Muir (@rmuir)

Contributor guide

Open the contributing guide

Research direction

Start with Lucene41PostingsReader.advance() and inspect the duplicated scanning loop, especially its buffer-refill behavior. Compare the shortcut with the skip writer's constants and determine whether it is safe; done means documenting that guarantee with targeted assertions or removing the optimization if it cannot be justified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.