Skip to content

feat: Implement write-only index state that is not considered for read queries#4894

Draft
porunov wants to merge 1 commit into
JanusGraph:masterfrom
porunov:feature/write-only-index
Draft

feat: Implement write-only index state that is not considered for read queries#4894
porunov wants to merge 1 commit into
JanusGraph:masterfrom
porunov:feature/write-only-index

Conversation

@porunov

@porunov porunov commented Apr 19, 2026

Copy link
Copy Markdown
Member

Write-only index is the ENABLED index for write operations, but ignored for read operations. This way, users can disable indexes without forcing them to re-index it when enabling them back.


Thank you for contributing to JanusGraph!

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there an issue associated with this PR? Is it referenced in the commit message?
  • Does your PR body contain #xyz where xyz is the issue number you are trying to resolve?
  • Has your PR been rebased against the latest commit within the target branch (typically master)?
  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you written and/or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE.txt file, including the main LICENSE.txt file in the root of this repository?
  • If applicable, have you updated the NOTICE.txt file, including the main NOTICE.txt file found in the root of this repository?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

…d queries

Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
porunov added a commit to porunov/janusgraph that referenced this pull request Jul 14, 2026
…d queries

Add SchemaStatus.WRITE_ONLY_ENABLED and SchemaAction.ENABLE_WRITE_ONLY.
An index in this state receives updates for all graph mutations but is not
used to answer queries, and SchemaAction.REINDEX preserves this state
instead of automatically enabling the index. This enables the workflow
"create index -> reindex it without enabling -> enable it later when
necessary", as well as demoting an ENABLED index to write-only and
re-enabling it later without a reindex. WRITE_ONLY_ENABLED is appended at
the end of SchemaStatus because the status is persisted by its ordinal.

Additional lifecycle extensions (no changes to existing workflows):
- DISABLE_INDEX can be applied to an INSTALLED index, allowing an index to
  be created and disabled in the same management transaction so that it
  never receives writes until explicitly activated.
- REGISTER_INDEX can be applied to a DISABLED index to re-activate it for
  writes with the registration barrier required for a lossless reindex.
- ENABLE_INDEX, DISCARD_INDEX and MARK_DISCARDED accept WRITE_ONLY_ENABLED.
- A pending index registration no longer overwrites a status change that
  superseded it (e.g. disabling an index while its registration
  acknowledgement is still pending).

Add SchemaAction.REMOVE_STALE_ENTRIES which removes index entries that
reference graph elements that no longer exist, for example because the
element was deleted while an index status change was still propagating
through the cluster or while the index was disabled. The action complements
REINDEX: a reindex restores missing entries for existing elements but never
removes entries, while REMOVE_STALE_ENTRIES removes entries of deleted
elements but never adds entries. Composite graph indexes are cleaned by the
new StaleIndexEntryRemoveJob which scans the internal index store; mixed
graph indexes are cleaned by the new MixedIndexStaleEntryRemover which
enumerates the documents through exists-queries against the index backend
and deletes stale documents in batches, running on a background thread
behind the new (cancellable) CompletableScanJobFuture. Removed and examined
entries are reported through the ScanMetrics custom metrics
"stale-entries-removed" and "scanned-entries". Vertex-centric indexes are
not supported by this action.

The index lifecycle documentation is rewritten to reflect the actual write
behavior of the existing states (INSTALLED and REGISTERED indexes have
always received graph updates; queries only ever use ENABLED indexes), now
includes the write-only workflows, an updated state transition diagram and
a new section about consistency during status transitions, and the
IndexRemoveJob validation error message reports the accepted statuses
derived from SchemaAction.DISCARD_INDEX instead of a stale hardcoded text.

Fixes JanusGraph#4894 follow-up; supersedes the docs-only draft of that PR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q6JuYe7uEs3dbr7MSPUtr2
Signed-off-by: Oleksandr Porunov <alexandr.porunov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant