Skip to content

Fix lost hits and scores in single-segment global ordinal joins with concurrent slices - #17028

Open
uchiha-asha wants to merge 7 commits into
apache:mainfrom
uchiha-asha:lucene-single-segment-ordinal-join-race
Open

uchiha-asha wants to merge 7 commits into
apache:mainfrom
uchiha-asha:lucene-single-segment-ordinal-join-race

Conversation

@uchiha-asha

Copy link
Copy Markdown
Contributor

TestJoinUtil.testRandomOrdinalsJoin failed on the Windows JDK 25 job of #16864 (seed D47984DB114B1684) with a hit scored Infinity instead of 5.8557844.
#16805 used SegmentOrdinalCollector for a single segment, which updated the hits and scores without a lock. However, IndexSearcher can partition a segment into multiple slices which can lead to race conditions.
This change uses the locked collector for both cases, with LongValues.IDENTITY as the ordinal mapping when there is a single segment.

@uchiha-asha

Copy link
Copy Markdown
Contributor Author

Hi @msokolov, could you please take a look when available. Thanks!

@kkewwei kkewwei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

private void collectOrd(int globalOrd) throws IOException {
collectedOrds.set(globalOrd);
double existingScore = scores.getScore(globalOrd);
double newScore = scorer.score();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure it's worth movingscorer.score() outside the lock.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @kkewwei for the review. Moved scorer.score() outside the lock. Looks safe.

scoreMode,
min,
max,
// IndexSearcher creates one collector per slice and collects each slice on its own

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we need to bother about this single slice case. Can we make this change purely about fixing the bug, and then separately optimize the single slice case? I think we might want to specialize the collector for that case, but this change is already a lot to review, so i'd like to simplify it into the smallest change possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @msokolov. I have removed the single slice case.

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