Repository navigation
HCK-18349: reverse-engineer index defer_build and num_replica from the instance - #74
Merged
Merged
Conversation
system:indexes returns no WITH options, so read them from REST /indexStatus: - defer_build: true when the index state is deferred or its definition has defer_build - num_replica: from numReplica, only when greater than 0 - nodes are not reverse-engineered, since hosts are always reported Co-authored-by: Cursor <cursoragent@cursor.com>
serhii-filonenko
approved these changes
Oct 28, 2026
An index without option was reverse-engineered with withOptions.defer_build false, which broke the feature RE and apply-to-instance comparisons. A missing value already shows the checkbox unchecked. Co-authored-by: Cursor <cursoragent@cursor.com>
|
serhii-filonenko
approved these changes
Oct 29, 2026
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.



Jira: HCK-18349
Problem
When we reverse-engineer from an instance, the index WITH options are lost. An index pushed with
defer_build: truecomes back without it.The RE reads indexes from
SELECT * FROM system:indexes, and this view has no WITH options at all (checked on a real instance, onlystateis there). REST/indexStatushas them:definition(with"defer_build":true),numReplicaandhosts.Change
In
reverse_engineering/helpers/indexHelper.js, the instance RE now also calls/indexStatusand matches each index by bucket, scope, collection and name:defer_build:trueif the state isdeferredor the definition contains"defer_build":true, else not set.num_replica: fromnumReplica, only when > 0 (0 is the default).withOptionsis set only when one of these options is found, so an index without option stays as before (feature RE and apply-to-instance models unchanged).nodes: not reverse-engineered on purpose./indexStatusalways reportshosts, even when no nodes were specified, so a round-trip would add nodes to every index.If
/indexStatusfails, the error is logged and RE continues:defer_buildstill comes from the state,num_replicastays empty.Known limit
An index created deferred and then built keeps
defer_buildonly if Couchbase keeps it in the definition. Not verified (noBUILD INDEXin the test).Tests
npm test: 123 passed, 0 failed (new cases intest/reverse_engineering/indexes.test.js).oxlinton touched files: no error.Made with Cursor