Skip to content

Gate preprocess() on needPreprocess() in cold-download and consuming segment callers - #19394

Merged
Jackie-Jiang merged 9 commits into
apache:masterfrom
deepthi912:honor-skip-preprocess-in-load
Sep 3, 2026
Merged

Gate preprocess() on needPreprocess() in cold-download and consuming segment callers#19394
Jackie-Jiang merged 9 commits into
apache:masterfrom
deepthi912:honor-skip-preprocess-in-load

Conversation

@deepthi912

@deepthi912 deepthi912 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

ImmutableSegmentLoader#needPreprocess short-circuits when skipSegmentPreprocess is set, and after #19391 also honors tier-scoped overrides. Callers on the warm-load and reload paths route through it and observe the flag correctly.

But the cold-download path — BaseTableDataManager#downloadAndLoadSegment and #replaceSegmentIfCrcMismatch — invokes the 4-arg ImmutableSegmentLoader#load overload that hard-codes needPreprocess=true and calls preprocess directly. Preprocess itself never consulted the flag, so every handler ran on cold load.

This PR moves the flag check into preprocess itself, so every caller behaves consistently.

Why this matters

Fast ingest. When a freshly built segment first lands on a server, tryLoadExistingSegment has no local copy to reuse, so downloadAndLoadSegment runs — and preprocess with it. For skipSegmentPreprocess=true tables that trade initial index coverage for fast ingest, this defeats the flag on the exact path that matters. Really helps for OFFLINE tables who don't need to think of query performance immediately

With this fix, fresh segments come ONLINE immediately after the tar downloads. Handler work can then be deferred to reload / tier migration / manual triggers instead of blocking ingest.

@deepthi912
deepthi912 marked this pull request as draft August 29, 2026 01:07
@deepthi912 deepthi912 added the index Related to indexing (general) label Aug 29, 2026
@codecov-commenter

codecov-commenter commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.62%. Comparing base (46a07c7) to head (5e6ae35).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19394      +/-   ##
============================================
- Coverage     67.63%   67.62%   -0.02%     
  Complexity     1430     1430              
============================================
  Files          3487     3488       +1     
  Lines        224326   224392      +66     
  Branches      35408    35424      +16     
============================================
+ Hits         151725   151745      +20     
- Misses        60573    60609      +36     
- Partials      12028    12038      +10     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-25 67.62% <100.00%> (-0.02%) ⬇️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 67.62% <100.00%> (-0.02%) ⬇️
unittests 67.62% <100.00%> (-0.02%) ⬇️
unittests1 57.77% <100.00%> (+0.01%) ⬆️
unittests2 39.34% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@deepthi912
deepthi912 marked this pull request as ready for review August 31, 2026 06:27
@deepthi912
deepthi912 force-pushed the honor-skip-preprocess-in-load branch 5 times, most recently from 576a4e7 to 1249e39 Compare August 31, 2026 23:44
@deepthi912 deepthi912 added the bug Something is not working as expected label Sep 1, 2026
@deepthi912 deepthi912 changed the title Honor skipSegmentPreprocess in ImmutableSegmentLoader#preprocess Gate preprocess() on needPreprocess() in cold-download callers Sep 2, 2026
@deepthi912 deepthi912 changed the title Gate preprocess() on needPreprocess() in cold-download callers Gate preprocess() on needPreprocess() in cold-download and consuming segment callers Sep 2, 2026
…overload

The 4-arg load(File, IndexLoadingConfig, throttler, SegmentZKMetadata) overload
hard-coded needPreprocess=true, so every caller of it defeated the
skipSegmentPreprocess flag. That covered four production call sites:

  - BaseTableDataManager#downloadAndLoadSegment (also reached by
    #replaceSegmentIfCrcMismatch)
  - BaseTableDataManager reload tail (line 1204)
  - RealtimeTableDataManager#downloadAndReplaceConsumingSegment
  - RealtimeTableDataManager#replaceConsumingSegment

Fix the overload itself instead of each call site: replace the hard-coded
true with !indexLoadingConfig.isSkipSegmentPreprocess(). All four callers
now inherit the correct behaviour, and no future caller of this overload
can silently reintroduce the bug.

preprocess()'s contract is untouched; needPreprocess() remains the gate,
but the overload — which is itself a caller of preprocess() — now
consults the flag before delegating.
Route the four production cold-download callsites (downloadAndLoadSegment,
the reload-after-CRC-mismatch branch, downloadAndReplaceConsumingSegment,
replaceConsumingSegment) through ImmutableSegmentLoader#needPreprocess
before invoking load(...). Mirrors the warm-load pattern already used in
BaseTableDataManager, so preprocess() is skipped when the segment is
already consistent (pauseless-realtime replica downloading a tar the
committer preprocessed) or when skipSegmentPreprocess is set.

Revert the 4-arg load(File, ILC, throttler, zkMetadata) overload to its
original delegation now that callers gate the check themselves. Add an
initSegmentDirectory(File, ...) overload for callers that hold the
index directory directly, and a computeNeedPreprocess helper that opens
the SegmentDirectory, invokes needPreprocess(), and closes.
TierBasedSegmentDirectoryLoader.load() physically moves srcDir to a
tier-specific destDir when the target tier differs from the source. The
check was invoking it through initSegmentDirectory, so the segment was
moved away before the subsequent ImmutableSegmentLoader.load ran on the
original indexDir. Switch to DefaultSegmentDirectoryLoader for the
check-only path — it opens a plain SegmentLocalFSDirectory and never
moves.
@deepthi912
deepthi912 force-pushed the honor-skip-preprocess-in-load branch from 34dc6fc to 55867dd Compare September 2, 2026 17:36

@Jackie-Jiang Jackie-Jiang 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.

I think we should simply integrate need pre-process check into ImmutableSegmentLoader.load() after checking the needPreprocess flag. The flag means whether the caller asks the loader to perform preprocess; the loader decides whethner preprocess is needed

Per Jackie's review: the boolean parameter to load(File, ILC, boolean,
...) is now the caller's opt-in signal ("please consider preprocess"),
and the loader decides whether preprocess is actually needed via
needPreprocess(SegmentDirectory, ILC). Preprocess runs only when the
caller opts in and the loader agrees work is pending.

The check uses the default (non-tier-aware) SegmentDirectoryLoader so it
never physically moves the segment across tiers; the configured loader
is still used for the final open.

Reverts the caller-side computeNeedPreprocess helper and the
initSegmentDirectory(File, ...) overload — callers pass true directly.
Restore ImmutableSegmentLoader.load(File, ILC, throttler, zkMetadata) so
production callers in BaseTableDataManager and RealtimeTableDataManager
don't need to change. Since the smart check lives inside the 5-arg
load(...) that this overload delegates to, existing callers get the new
behavior for free. Minimal-touch diff per Jackie's review.
@deepthi912

Copy link
Copy Markdown
Collaborator Author

Done

@Jackie-Jiang
Jackie-Jiang merged commit 2c31341 into apache:master Sep 3, 2026
12 checks passed
xiangfu0 added a commit to pinot-contrib/pinot-docs that referenced this pull request Sep 3, 2026
Documents the corrected skipSegmentPreprocess behavior from
apache/pinot#19394.

- covers cold downloads and replacement paths
- explains needPreprocess gating and faster availability
- preserves tier-override guidance and cautions

Validation: `scripts/validate-docs.py --changed-only=... --strict`; `git
diff --check`

Co-authored-by: Xiang Fu <xiangfu@Xiang-mac-mtv-2.local>
@xiangfu0

xiangfu0 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Documentation follow-up: pinot-contrib/pinot-docs#1029 (merged).

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

Labels

bug Something is not working as expected index Related to indexing (general)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants