Skip to content

Read legacy text index directory without probing consolidated entry when it exists#18919

Open
xiangfu0 wants to merge 1 commit into
apache:masterfrom
xiangfu0:fix-text-index-legacy-directory-probe
Open

Read legacy text index directory without probing consolidated entry when it exists#18919
xiangfu0 wants to merge 1 commit into
apache:masterfrom
xiangfu0:fix-text-index-legacy-directory-probe

Conversation

@xiangfu0

@xiangfu0 xiangfu0 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Problem

With storeInSegmentFile=true, TextIndexType.ReaderFactory probed the consolidated segment-file entry (segmentReader.getIndexFor(column, StandardIndexes.text())) unconditionally.

On a V1/V2 segment backed by FilePerIndexDirectory whose column still has the legacy Lucene text-index directory on disk, getFileFor resolves that directory (File.exists() is true for directories) and mapForReads rejects it with IllegalArgumentException: File: ... must be a regular file — killing the whole segment load before any fallback can run. This makes flipping storeInSegmentFile=true non-rolling-upgrade-safe for existing V1/V2 text segments.

TextIndexHandler cannot rescue these segments either: its combined-format conversion is v3-gated, so the reader factory must handle them.

This is the text-index twin of the vector index bug fixed in #18852.

Fix

Legacy-directory-first gate, same pattern as #18852: if SegmentDirectoryPaths.findTextIndexIndexFile finds a Lucene directory on disk (an unmigrated V3 segment, or any V1/V2 segment), construct the directory-based LuceneTextIndexReader directly and skip the consolidated probe entirely. The probe only runs when no legacy directory exists.

Tests

New TextIndexTypeTest mirrors the vector regression tests:

  • testReaderFactoryUsesLegacyTextDirectoryWithoutProbingConsolidatedEntry — builds a real legacy Lucene text index in the V1 root layout, stubs getIndexFor to throw IllegalArgumentException("... must be a regular file"), asserts the reader is constructed, serves queries, and the probe never runs.
  • testReaderFactoryUsesLegacyTextDirectoryInV3LayoutWithoutProbing — same for the v3/ subdirectory layout.

Both tests fail without the fix (verified by stashing the main change) and pass with it.

…hen it exists

With storeInSegmentFile=true, the text index reader factory probed the
consolidated segment-file entry (getIndexFor) unconditionally. On a V1/V2
segment backed by FilePerIndexDirectory, getIndexFor resolves the
still-present legacy Lucene text-index DIRECTORY and mapForReads rejects it
(IllegalArgumentException: must be a regular file), killing the segment load
before the legacy fallback could run — making the flag
non-rolling-upgrade-safe for existing text segments. TextIndexHandler cannot
rescue these segments because its combined-format conversion is v3-gated.

The factory now checks the on-disk artifact first: if it is a Lucene
directory (an unmigrated V3 segment, or any V1/V2 segment), read it directly
and skip the probe entirely. Same pattern as the vector index fix in apache#18852.

Tests cover both the V1 root layout and the v3/ subdirectory layout,
asserting the probe never runs while the legacy directory exists.
@xiangfu0 xiangfu0 force-pushed the fix-text-index-legacy-directory-probe branch from cb8749f to 12939e2 Compare July 5, 2026 19:25
@codecov-commenter

codecov-commenter commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.81%. Comparing base (19897c5) to head (12939e2).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...egment/local/segment/index/text/TextIndexType.java 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18919      +/-   ##
============================================
+ Coverage     64.80%   64.81%   +0.01%     
  Complexity     1347     1347              
============================================
  Files          3392     3396       +4     
  Lines        211769   212504     +735     
  Branches      33345    33485     +140     
============================================
+ Hits         137232   137745     +513     
- Misses        63451    63598     +147     
- Partials      11086    11161      +75     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-21 64.81% <57.14%> (+0.01%) ⬆️
temurin 64.81% <57.14%> (+0.01%) ⬆️
unittests 64.81% <57.14%> (+0.01%) ⬆️
unittests1 56.78% <57.14%> (-0.17%) ⬇️
unittests2 37.23% <57.14%> (+0.05%) ⬆️

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.

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.

2 participants