Skip to content

Conversation

@magibney
Copy link
Collaborator

@magibney magibney commented Oct 10, 2025

Note

Introduces Unloader to dynamically unload/reload codec resources (fields/docvalues/points) with directory-coordinated executors, updates codecs to use it, and adjusts tests/build to support and stress this behavior.

  • Core/Codecs:
    • Add index.Unloader with scheduling, reference tracking, and UnloadHelper/UnloadAware APIs.
    • New wrappers: UnloadingFieldsProducer, UnloadingDocValuesProducer, UnloadingPointsReader enabling on-demand reload.
    • Update PerFieldPostingsFormat and PerFieldDocValuesFormat to wrap producers via Unloader (bypass when UnloadAware#disableUnload).
    • Use Unloader for points in SegmentCoreReaders.
  • IO/Directory Coordination:
    • Introduce store.UnloaderCoordinationPoint and implement in FSDirectory and ByteBuffersDirectory (per-directory executor management, shutdown on close).
  • Build/Config:
    • Add test system properties (lucene.unload.*) with defaults in Gradle.
    • CI: tweak Gradle tasks (skip javadoc render tasks) and enable unload stress flags during tests.
  • Tests:
    • Add TestUnloader; update various tests to close resources, incRef segment files, or temporarily disable unloading where necessary.

Written by Cursor Bugbot for commit 0c25238. This will update automatically on new commits. Configure here.

there are still a few tests that fail, but they fail in known ways
hard to address, but none are alarming.
@cursor
Copy link

cursor bot commented Oct 10, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on October 18.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

otherwise dead reference analysis GC parent object may cause
decRef, making resource to eligible for unloading before we've
incRef'd for the new "child" object

Saw this issue during merge on shard split
@cursor
Copy link

cursor bot commented Oct 20, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on November 18.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

this may yet not be enough for callback-oriented methods such
as PointTree.visitDocValues(). If we continue to hit errors,
we'll simply have to inc/decRef at beginning/end of such methods.

But for now we know we have a problem in the way we're wrapping
the raw readers, since the wrapped readers are very explicitly
unaware of being wrapped, so if we track the wrapper refs, they
become GC'able well before the raw instances that do the actual
work.

In any case we'll proceed iteratively here so that we have a
better sense of where the problem is, and where it's been fixed.
This avoids the need for GC "Reference Handler" thread to do
full-on ReferenceQueue tracking, and allows us to more efficiently
handle the majority of refs, which live only very briefly.
from derivative objects, indirectly ensure reachability of the
top-level object to prevent collection while there are outstanding
derivative refs
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

u.exec.schedule(
maybeUnloadTask(u, type, u.reporter),
KEEP_ALIVE_NANOS + INITIAL_NANOS,
TimeUnit.NANOSECONDS);
Copy link

Choose a reason for hiding this comment

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

Bug: NullPointerException when executor is null

The code calls u.exec.schedule() without null-checking exec. If AbstractUnloadHelper.onCreation() returns null (when initialized with a null executor), subsequent attempts to schedule unload tasks will throw NullPointerException, which is not caught by the RejectedExecutionException handler. This occurs in the reopen lambdas for pointsReader, fieldsProducer, and docValuesProducer, causing resource loading to fail unexpectedly.

Fix in Cursor Fix in Web

} else {
dvp =
Unloader.docValuesProducer(
() -> format.fieldsProducer(srs), srs.segmentInfo.dir, srs);
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect directory access in PerFieldDocValuesFormat

The code accesses srs.segmentInfo.dir to pass a Directory to Unloader.docValuesProducer(), but SegmentInfo does not have a dir property. This should be srs.directory instead, matching the usage pattern in PerFieldPostingsFormat.java line 334. This will cause an AttributeError or similar runtime exception.

Fix in Cursor Fix in Web

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.

3 participants