Skip to content

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

Merged
nit0906 merged 1 commit into
apache:trunkfrom
bhabegger:OAK-12248-graceful-404
Jun 24, 2026
Merged

OAK-12248: graceful 404 when ES alias is not yet provisioned#2950
nit0906 merged 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 3 times, most recently 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.

@bhabegger

Copy link
Copy Markdown
Contributor Author

@bhabegger - do we need a toggle for this ?

The change seems very limited.

Yes, that's why it is on by default. This is just a precaution because it does change the behavior (maybe in some situations we would want an error if the index doesn't exist ?).

@bhabegger bhabegger force-pushed the OAK-12248-graceful-404 branch from 12ea30f to 9d69a61 Compare June 23, 2026 15:28
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 9d69a61 to ccf0da3 Compare June 23, 2026 15:32
@nit0906 nit0906 merged commit 72a21df into apache:trunk Jun 24, 2026
2 of 3 checks passed
@bhabegger bhabegger deleted the OAK-12248-graceful-404 branch June 24, 2026 06:18
reschke pushed a commit that referenced this pull request Jun 25, 2026
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>
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.

3 participants