OAK-12365: Delete stale index document when a node's last aggregated property is removed - #3086
Open
bhabegger wants to merge 1 commit into
Open
OAK-12365: Delete stale index document when a node's last aggregated property is removed#3086bhabegger wants to merge 1 commit into
bhabegger wants to merge 1 commit into
Conversation
Contributor
Author
|
[AI] Addressed feedback from an internal automated review:
Full |
fabriziofortino
approved these changes
Aug 19, 2026
…property is removed FulltextIndexEditor.addOrUpdate() calls makeDocument() on every commit touching a node. When the node's indexing rule still matches but its last indexable content came from a relative/aggregated property that just got removed, makeDocument() returns null (nothing to index) and addOrUpdate() previously did nothing further, leaving the old document in the index forever. A direct (non-relative) property removal on the same node was already handled correctly: FulltextDocumentMaker.removeProperties() forces dirty=true in that case, so a rebuilt document is written instead of null. The gap is specifically the aggregated-content case, where the root's own propertiesModified list stays empty. Fix: in addOrUpdate(), when makeDocument() returns null on an update to a previously-existing node, delete the stale document. Guarded by feature toggle FT_OAK-12365 (enabled by default), following this codebase's convention for bug-fix toggles. Covers both the OAK-12244 type-tracking-enabled path and the legacy (toggle-disabled) path, since both funnel through addOrUpdate().
bhabegger
force-pushed
the
issue/OAK-12365
branch
from
August 25, 2026 08:21
a7f2951 to
3d171a1
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
FulltextIndexEditor.addOrUpdate()callsmakeDocument()on every commit touching a node. When the node's indexing rule still matches but its last indexable content came from a relative/aggregated property that was just removed,makeDocument()returnsnull(nothing to index) andaddOrUpdate()previously did nothing further — leaving the stale document in the index indefinitely.A direct (non-relative) property removal on the same node was already handled correctly:
FulltextDocumentMaker.removeProperties()forcesdirty=truein that case, so a rebuilt document is written instead ofnull. The gap is specifically the aggregated-content case, where the root node's ownpropertiesModifiedlist stays empty.Fix: in
addOrUpdate(), whenmakeDocument()returnsnullon an update to a previously-existing node, delete the stale document. Guarded by feature toggleFT_OAK-12365(enabled by default), following this codebase's convention for bug-fix toggles.Covers both the OAK-12244 type-tracking-enabled path and the legacy (toggle-disabled) path, since both funnel through
addOrUpdate().Related but distinct from OAK-12244 (mixin add/remove rule transitions): this is a content transition — the rule still matches throughout, but the document's content disappeared.
Test plan
LuceneIndexEditor2Test#nodeLosesLastAggregatedPropertyTriggersDocumentDeletion— unit test verifyingdeleteDocument()is called (new, RED→GREEN)LuceneIndexEditor2Test#nodeLosesLastAggregatedPropertyTriggersDocumentDeletionWhenMixinToggleDisabled— same, withFT_OAK_12244disabled to confirm the legacy path is also coveredPropertyIndexCommonTest#nodeLosesLastAggregatedPropertyDisappearsFromFulltextIndex— integration test using a fulltextCONTAINS()query (a plain equality query can't observe this bug, since Oak's query engine revalidates simpleWHEREconditions against the live tree)oak-search+oak-lucenesuites: 1250 tests, 0 failures, 0 errors