Restore live index settings on per-entity distributed-promote path

DefaultRecreateHandler exposes two finalization paths:

  - finalizeReindex(...)        — centralized end-of-job promotion. Calls
                                  applyLiveServingSettings + maybeForceMerge
                                  before the alias swap, reverting the bulk
                                  overrides (refresh_interval=-1, replicas=0,
                                  async translog) back to live values
                                  (refresh=1s, replicas=1, durable translog).

  - promoteEntityIndex(ctx, ok) — per-entity promotion. Used by the distributed
                                  search-indexer's "promote as soon as all
                                  partitions for an entity complete" callback
                                  (DistributedSearchIndexExecutor.promoteEntityIndex).
                                  Swaps the alias and cleans up old indices —
                                  but never restored live settings.

When an entity finishes its partitions before the final reconciliation
(typically the smallest entities — e.g. knowledge `page` with ~11 rows),
its index is promoted via the per-entity path, the alias swap succeeds,
and the bulk-build overrides become the new live settings. refresh_interval
stays at -1 in production, so live writes after the reindex are buffered in
the translog and never reach searchable segments until a manual _refresh.
Externally this surfaces as "create an article, hierarchy is empty until I
re-trigger reindex" — exactly the user-reported bug.

Mirror the finalizeReindex sequence by calling applyLiveServingSettings
(and maybeForceMerge for parity) at the top of the promote block in
promoteEntityIndex, before the alias swap.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Sriharsha Chintalapani 2026-05-04 10:07:56 -07:00
parent f0e9bc28ae
commit b272de85f9

View file

@ -321,6 +321,15 @@ public class DefaultRecreateHandler implements RecreateIndexHandler {
return;
}
// Restore live serving settings on the staged index before alias swap. The bulk-build
// overrides (refresh=-1, replicas=0, async translog) must NOT survive into live serving
// otherwise live writes after promotion are buffered indefinitely and only become
// searchable on a manual _refresh, which surfaces as the "create-then-search returns
// nothing until reindex" symptom on knowledge pages. This mirrors the call in
// finalizeReindex; the per-entity distributed promotion path was missing it.
applyLiveServingSettings(searchClient, stagedIndex, entityType);
maybeForceMerge(searchClient, stagedIndex, entityType);
// Always clear staged-index routing on the way out see the rationale in finalizeReindex.
try {
Set<String> aliasesToAttach =