Benjamin Habegger created OAK-12371:
---------------------------------------
Summary: REINDEX_COMPLETION_TIMESTAMP not written when a reindex
writes zero documents
Key: OAK-12371
URL: https://issues.apache.org/jira/browse/OAK-12371
Project: Jackrabbit Oak
Issue Type: Bug
Reporter: Benjamin Habegger
h3. Summary
When a reindex writes zero documents (the index rule matches nothing), the
index's
{{REINDEX_COMPLETION_TIMESTAMP}} status property is never written -- even
though the reindex
genuinely completed successfully. This is not specific to any one index
implementation: it lives
in the shared {{FulltextIndexEditorContext.closeWriter()}}, used by every
{{FulltextIndexWriter}}.
h3. Details
{{closeWriter()}} only writes {{STATUS_LAST_UPDATED}} and
{{REINDEX_COMPLETION_TIMESTAMP}} when the
writer's {{close()}} call returns {{true}} ({{indexUpdated}}). For Elastic,
that return value comes
from {{ElasticBulkProcessorHandler.flushIndex()}}, which returns
{{indexInfo.indexModified}} -- only
set {{true}} by an actual successful bulk write. A reindex that matches zero
documents never issues
a bulk write, so {{indexModified}} stays {{false}} and the timestamp is
skipped, regardless of
whether provisioning is eager or lazy.
{{REINDEX_COMPLETION_TIMESTAMP}} is consumed by:
* {{IndexVersionOperation.isActiveIndexOldEnough()}} (oak-run-commons) -- gates
oak-run's
{{purge-old-index-versions}} command. Missing timestamp -> WARN + refuses to
purge.
* {{ElasticIndexInfoProvider}} / {{LuceneIndexInfoProvider}} -- report
reindex-completion status in
monitoring/info APIs.
* {{ReindexOperations}} -- checks reindex completion state.
Found while reviewing OAK-12249 (lazy ES index provisioning) -- confirmed via
{{git diff}} that OAK-12249 does not touch {{closeWriter()}} at all, so this is
a pre-existing gap,
not something that PR introduces. It affects every {{FulltextIndexWriter}}
implementation (Lucene
included), at whatever rate a reindex already produces zero documents --
unrelated to lazy vs eager
provisioning.
h3. Acceptance Criteria
# {{REINDEX_COMPLETION_TIMESTAMP}} is written whenever a reindex genuinely
completes, even if it
wrote zero documents -- OR the property's absence is handled gracefully by
all three consumers
above (no WARN-and-refuse behavior for a legitimately-empty, completed
reindex).
# oak-run's {{purge-old-index-versions}} correctly purges old versions of an
index whose active
version's most recent reindex produced zero documents.
# Behavior is consistent across Lucene and Elastic index implementations.
h3. Related
Found during review of
[OAK-12249|https://issues.apache.org/jira/browse/OAK-12249] / PR
[apache/jackrabbit-oak#3085|https://github.com/apache/jackrabbit-oak/pull/3085].
Not blocking that
PR -- tracked separately since the gap is cross-cutting and pre-existing.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)