OAK-12249: lazy ES index provisioning — skip creation for empty reindex#2955
Draft
bhabegger wants to merge 2 commits into
Draft
OAK-12249: lazy ES index provisioning — skip creation for empty reindex#2955bhabegger wants to merge 2 commits into
bhabegger wants to merge 2 commits into
Conversation
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>
When FT_OAK-12249 and FT_OAK-12248 are both enabled, ElasticIndexWriter defers provisionIndex() from the constructor to the first updateDocument() or deleteDocuments() call. A reindex that produces zero documents never creates an Elasticsearch index or alias, eliminating the empty-index problem described in OAK-12249. Deployment order is enforced at runtime: isLazyProvisioningActive() returns true only when both toggles are on. Enabling FT_OAK-12249 alone logs a WARN and falls back to eager provisioning, preventing 404 errors on query paths that lack graceful 404 handling. ensureProvisioned() handles the incremental-write-after-empty-reindex case: if an alias does not exist when the first document arrives, it creates a new backing index with a fresh seed and points the alias at it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d61927f to
77817e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
provisionIndex()from theElasticIndexWriterconstructor to the firstupdateDocument()ordeleteDocuments()call when bothFT_OAK-12249andFT_OAK-12248are enabledensureProvisioned()handles the incremental-write-after-empty-reindex case: if an alias does not exist when the first document arrives, it creates a new backing index with a fresh seed and points the alias at itDependency on OAK-12248
This PR must be merged after #2950 (OAK-12248: graceful 404 handling).
This branch is currently based on
OAK-12248-graceful-404so the diff includes both changes. Once OAK-12248 merges to trunk this branch will be rebased and the diff will show only the OAK-12249 commit.Deployment order is enforced at runtime:
isLazyProvisioningActive()returnstrueonly when bothFT_OAK-12249andFT_OAK-12248are enabled. EnablingFT_OAK-12249alone falls back to eager provisioning and logs aWARN.Tests
Three new unit tests in
ElasticIndexWriterTest:lazyProvisioning_requiresGraceful404Toggle— asserts lazy provisioning is inactive when OAK-12248 toggle is offemptyReindex_doesNotCreateEsIndex— verifies no ES index is created during construction when no documents are writtennonEmptyReindex_provisionsOnFirstDocument— verifiesprovisionIndex()is called on the firstupdateDocument()and not beforeAll 11 tests in
ElasticIndexWriterTestpass.Jira
https://issues.apache.org/jira/browse/OAK-12249