Skip to content

Port trivial production fixes from Lucene 4.8.1, #1381 Batch 1#1413

Open
paulirwin wants to merge 8 commits into
apache:masterfrom
paulirwin:issue/1381-batch-1
Open

Port trivial production fixes from Lucene 4.8.1, #1381 Batch 1#1413
paulirwin wants to merge 8 commits into
apache:masterfrom
paulirwin:issue/1381-batch-1

Conversation

@paulirwin

@paulirwin paulirwin commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Backport trivial production fixes from Lucene 4.8.1

Partial #1381 (Batch 1)

Description

  • LUCENE-5635 (partial): move stream.Reset() into the try block
  • LUCENE-5668: fix off-by-one error in TieredMergePolicy + test
  • LUCENE-5656 (partial): don't leak dv producers if one of them throws exception
  • LUCENE-5644 (partial): add PulseAll call to DeactivateUnreleasedStates

Note that the partial items will be fully completed in Batch 5.

@paulirwin
paulirwin requested review from NightOwl888 and Copilot July 8, 2026 20:16
@paulirwin paulirwin added the notes:bug-fix Contains a fix for a bug label Jul 8, 2026

Copilot AI 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.

Pull request overview

Backports a first batch of small but production-relevant Lucene 4.8.1 fixes into Lucene.Net, focusing on correctness around merging, docvalues resource handling, token stream lifecycle, and thread coordination, plus adding a regression test for the TieredMergePolicy change.

Changes:

  • Hardened and corrected several production code paths (token stream reset handling, docvalues producer ref-count/leak behavior, merge “over budget” selection, and thread wakeups).
  • Added an argument-range guard to OfflineSorter.ByteSequencesWriter.Write() to prevent invalid short length truncation.
  • Added a new TieredMergePolicy regression test for LUCENE-5668.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Lucene.Net/Util/OfflineSorter.cs Adds len > short.MaxValue guard before writing length as short.
src/Lucene.Net/Index/TieredMergePolicy.cs Fixes LUCENE-5668 by adjusting the “over budget” eligibility threshold.
src/Lucene.Net/Index/SegmentReader.cs Prevents docvalues producer reference leaks by tracking gens only after successful producer creation.
src/Lucene.Net/Index/DocumentsWriterPerThreadPool.cs Ensures waiting threads are woken after deactivating unreleased thread states.
src/Lucene.Net/Index/DocInverterPerField.cs Moves TokenStream.Reset() into the try so failures are handled and the stream is properly closed.
src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs Adds TestUnbalancedMergeSelection() for LUCENE-5668.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Lucene.Net/Util/OfflineSorter.cs Outdated
Comment thread src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs Outdated
Comment thread src/Lucene.Net/Util/OfflineSorter.cs Outdated
@paulirwin

Copy link
Copy Markdown
Contributor Author

The OfflineSorter changes were reverted and moved to #1422.

@paulirwin
paulirwin force-pushed the issue/1381-batch-1 branch from dd44294 to aa17acb Compare July 15, 2026 17:29
@paulirwin paulirwin changed the title Backport trivial production fixes from Lucene 4.8.1, #1381 Batch 1 Port trivial production fixes from Lucene 4.8.1, #1381 Batch 1 Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:bug-fix Contains a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants