Skip to content

fix: more chill abandoned partial loads and safer deferred eviction of weak held entries - #20073

Open
clintropolis wants to merge 6 commits into
apache:masterfrom
clintropolis:fix-abandoned-partial-loads
Open

fix: more chill abandoned partial loads and safer deferred eviction of weak held entries#20073
clintropolis wants to merge 6 commits into
apache:masterfrom
clintropolis:fix-abandoned-partial-loads

Conversation

@clintropolis

Copy link
Copy Markdown
Member

Description

Relaxes cache manager partial segment loading to not throw when pinning reference holds if the caller closed the holds (and so no longer cares to finish mounting and loading the segment), and also fixes a problem where a weak held entry with deferred unmount could be incorrectly unmounted since it was looking up by id without confirming it was the same reference (and not a newly re-added entry).

@clintropolis clintropolis changed the title fix: more chill abandoned partial loads and safer eviction of held entries fix: more chill abandoned partial loads and safer deferred eviction of weak held entries Aug 19, 2026
Comment on lines +984 to +988
@SuppressWarnings("unused")
ListenableFuture<?> unused = gatedPool.getExecutorService().submit(() -> {
atGate.countDown();
return openGate.await(30, TimeUnit.SECONDS);
});

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Severity Findings
P0 0
P1 1
P2 1
P3 0
Total 2

Reviewed 4 of 4 changed files.

The review found one weak-entry identity race and one failed-partial-entry cleanup issue.


This is an automated review by Codex GPT-5.6-Luna(max)

weakCacheEntries.computeIfPresent(
weakEntry.cacheEntry.getId(),
(cacheEntryIdentifier, weakCacheEntry) -> {
if (weakCacheEntry != weakEntry || weakCacheEntry.isHeld()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P1] Replacement entry can be mistaken for the in-flight entry

If an abandoned mount entry is reclaimed and a replacement with the same ID is registered, the mount verification and reservation adjustment check only the ID. The old mount can therefore commit against the replacement's reservation and leave its mapper and files live. Verify object identity before committing or adjusting.

final boolean isMounted = weakCacheEntry.cacheEntry.isMounted();
if ((isNewEntry && !isMounted)
|| (areWeakEntriesEphemeral && !weakCacheEntry.isHeld())) {
if ((isNewEntry && !isMounted) || areWeakEntriesEphemeral) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P2] Failed partial entries can lose restart metadata

A failed mount consumes the onUnmount hook and deletes the info file. If another hold remains, this guard retains the unmounted entry; the final non-creator hold does not remove it. A later acquire reuses it without rewriting the info file or restoring the hook, so bootstrap can lose the segment after restart.

Comment on lines +1114 to +1118
@SuppressWarnings("unused")
ListenableFuture<?> unused = gatedPool.getExecutorService().submit(() -> {
atGate.countDown();
return openGate.await(30, TimeUnit.SECONDS);
});
if (!existing.metadata().isMounted()) {
// rewrite the info file if it is missing
try {
storeInfoFile(dataSegment);

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.

Two things:

  1. The code that writes info files could use a cleanup. I think it would improve things to run it all through rewriteInfoFile, i.e., make storeInfoFile call rewriteInfoFile, and also make the if (hold != null) branch in acquireSegment call rewriteInfoFile. It would be easier to track through all the places that can write an info file.

  2. Do we need to register a hook here to delete the info file on unmount?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants