Skip to content

feat: wire up partial load rules to segment cache#19657

Open
clintropolis wants to merge 4 commits into
apache:masterfrom
clintropolis:wire-up-partial-load-rules
Open

feat: wire up partial load rules to segment cache#19657
clintropolis wants to merge 4 commits into
apache:masterfrom
clintropolis:wire-up-partial-load-rules

Conversation

@clintropolis

Copy link
Copy Markdown
Member

Description

This PR finishes the partial load rules by wiring the partial load specs up to the segment cache, allowing historicals in virtual storage mode to eagerly load and pin parts of segments to the cache, while allowing the rest of the segment to still be loaded on demand (and evicted).

@capistrant capistrant 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.

nothing I see as outright blocking. left a few comments and nits.

Comment on lines +979 to +980
"Backend for segment[%s] does not support range reads; partial-load rule[fingerprint=%s] cannot be honored, "
+ "falling back to weak full-load at query time",

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 agree with the decision to fallback here, but how will we help an operator get out of this state? do you think that will come in via documentation of the feature, guiding an operator on how to configure and common pitfalls (like zipped segments resulting in logs like these, and what to change to fix)?

continue;
}
try {
FileUtils.mkdirp(partialDir);

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.

not seeing this cleaned up in the event of failure and rollback. does that need to cleaned up outside of the callable if it fails and rolls back?

@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 0
P2 2
P3 0
Total 2

This is an automated review by Codex GPT-5.5

"Dropping stale static partial entry for segment[%s]: current rule cannot be applied without range reads",
dataSegment.getId()
);
drop(dataSegment);

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] Preserve stale static partials while refs are active

The range-reader-null fallback drops a stale static partial entry and immediately deletes stale segment directories without the outstanding-reference precheck used by the normal reconciliation path. If a query still holds a metadata or bundle reference, drop only removes the entry from the static map while actual cleanup is deferred; deleting/reusing the directory before those refs close can break in-flight reads or let deferred cleanup delete files for the next entry. This path should fail/retry when the old partial would defer cleanup.

// bundles installed by {@link #loadPartial}, this is the only path that removes them from the static map.
if (entry instanceof PartialSegmentMetadataCacheEntry partial) {
for (PartialSegmentBundleCacheEntry bundle : partial.snapshotLinkedBundles()) {
location.release(bundle);

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] Evict weak linked bundles during partial drops

The new drop cascade calls location.release for each linked bundle, but release is a no-op for weak/on-demand bundles. A rule-loaded partial segment can still have non-selected bundles mounted through the weak path; those bundles hold metadata references for their lifetime, so dropping/reconciling the static metadata can proceed, delete/recreate the same segment directory, and leave old weak bundle entries to later evict containers through the old mapper. Drop/reconcile needs to remove unheld weak linked bundles too, or refuse to proceed while any linked weak bundle remains active.

@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 0
P2 2
P3 0
Total 2
Severity Findings
P0 0
P1 0
P2 2
P3 0
Total 2

Reviewed 16 of 16 changed files.

Found 2 lifecycle issues in the partial-load-rule reconciliation/drop paths.


This is an automated review by Codex GPT-5.5

"Dropping stale static partial entry for segment[%s]: current rule cannot be applied without range reads",
dataSegment.getId()
);
drop(dataSegment);

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] Range-reader fallback drops live partial entries

This unsupported-range-reader fallback calls drop() and then removes every stale per-segment directory without the cascadeReleaseWouldDeferCleanup() guard used by the main reconciliation path. If a query is still holding the old static partial metadata or bundle when a changed rule falls back because the delegate has no range reader, drop() can defer old cleanup while removeStaleSegmentDirsOnAllLocations() deletes or reuses the same cache directory underneath that query. Please apply the same outstanding-reference precheck here and retry later instead of dropping when cleanup would defer.

// bundles installed by {@link #loadPartial}, this is the only path that removes them from the static map.
if (entry instanceof PartialSegmentMetadataCacheEntry partial) {
for (PartialSegmentBundleCacheEntry bundle : partial.snapshotLinkedBundles()) {
location.release(bundle);

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] Weak linked bundles survive partial drop

location.release(bundle) only removes entries from staticCacheEntries, so it is a no-op for weak/on-demand bundles linked to a static partial metadata entry. Those weak bundles still hold metadata references, but the reconciliation precheck subtracts all linked bundles as if drop will release them, after which the new code can nuke or reuse the segment directory while the weak bundles remain mounted. Drop/reconcile should either remove unheld weak linked bundles or treat their presence as a deferred-cleanup blocker.

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