Skip to content

OAK-12248: graceful 404 when ES alias is not yet provisioned#2950

Open
bhabegger wants to merge 1 commit into
apache:trunkfrom
bhabegger:OAK-12248-graceful-404
Open

OAK-12248: graceful 404 when ES alias is not yet provisioned#2950
bhabegger wants to merge 1 commit into
apache:trunkfrom
bhabegger:OAK-12248-graceful-404

Conversation

@bhabegger

Copy link
Copy Markdown
Contributor

Summary

  • Adds feature toggle FT_OAK-12248 (off by default) to ElasticIndexStatistics
  • When enabled, a 404 ElasticsearchException from an ES count request during query planning is caught in getCountOrZeroOn404(), logged at INFO, and treated as 0 estimated documents — the planner stays on the ES path instead of falling back to traversal with an ERROR log
  • ElasticResultRowAsyncIterator.onFailure() / hasNext() also check the toggle to suppress ERROR at execution time if the alias is still missing
  • Toggle registered in ElasticIndexProviderService alongside the existing FT_OAK-12206 and FT_OAK-12234 toggles

Root cause note

The 404 first surfaces during planning (not execution): ElasticIndexStatistics.getDocCountFor() fires an ES count request whose ElasticsearchException propagates uncaught to FulltextIndex.getPlans():176 and is logged as ERROR there. Oak's cache re-throws RuntimeException causes unwrapped (only checked exceptions are wrapped in CompletionException), so the catch must target ElasticsearchException directly.

Test

ElasticGraceful404QueryTest (new):

  • queryOnMissingAlias_withToggleOff_logsError — seeds data, provisions index, deletes alias, asserts ERROR log (confirms existing behaviour)
  • queryOnMissingAlias_withToggleOn_returnsEmptyWithoutError — same setup, toggle on, asserts 0 results + no ERROR + INFO "alias not found"

Relation to other tickets

Builds on OAK-12247 (track totalIndexedNodes). Prerequisite for OAK-12249 (lazy ES provisioning): without this toggle, a non-existent alias after an empty reindex would ERROR on every query.

🤖 Generated with Claude Code

@bhabegger bhabegger force-pushed the OAK-12248-graceful-404 branch 8 times, most recently from 34d67e8 to 32e7d73 Compare June 12, 2026 06:02
@bhabegger bhabegger marked this pull request as ready for review June 12, 2026 06:20
@bhabegger bhabegger force-pushed the OAK-12248-graceful-404 branch 8 times, most recently from 05248f4 to 17749e4 Compare June 12, 2026 08:31
@bhabegger bhabegger force-pushed the OAK-12248-graceful-404 branch 2 times, most recently from ddf8a34 to 46e080d Compare June 15, 2026 06:10
When an Elasticsearch alias does not exist (index_not_found_exception / 404),
the query now returns an empty cursor and logs INFO instead of propagating
an ERROR via FulltextIndex.getPlans(). The fix is behind feature toggle
FT_OAK-12248 (disabled by default) registered in ElasticIndexProviderService.

The 404 is caught in ElasticIndexStatistics.getCountOrZeroOn404() so the
planner receives 0 estimated documents and proceeds normally; ElasticResultRow-
AsyncIterator.onFailure() / hasNext() also suppress the ERROR when the toggle
is on. ElasticGraceful404QueryTest verifies both toggle-off (ERROR expected)
and toggle-on (empty result, no ERROR, INFO logged) behaviours.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bhabegger bhabegger force-pushed the OAK-12248-graceful-404 branch from 46e080d to 12ea30f Compare June 15, 2026 06:13
@nit0906

nit0906 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@bhabegger - do we need a toggle for this ?

The change seems very limited.

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