Ottoman v2 ensureIndexes

From another topic, I’ve followed and added this code into my unit test and remove all indexes from couchbase server.

before(() => {
    service = new UnitTestService(options);
      .then(() => {
        console.log('All the indexes were registered');
      .catch((e) => console.log('hello: ', e));

The behavior when running my test cases output the following

(node:15224) UnhandledPromiseRejectionWarning: Error: LCB_ERR_HTTP (1053): HTTP Operation failed. Inspect status code for details
(node:15224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see (rejection id: 1)(node:15224) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I’ve notice that the #primary index is created at couchbase server. The second time i run the unit test, it output different and was caught in the before() catch exception.

hello: [Error: LCB_ERR_HTTP (1053): HTTP Operation failed. Inspect status code for details] {
code: 1053,
ctxtype: ‘query’,
first_error_code: 5000,
first_error_message: ‘GSI CreateIndex() - cause: Create index or Alter replica cannot proceed due to rebalance in progress, another concurrent create index request, network partition, node failover, indexer failure, or presence of duplicate index name.’,
statement: ‘CREATE INDEX Ottoman_scope_type ON TestBucket(_scope, _type) USING GSI WITH {“defer_build”: true}’,
client_context_id: ‘7feb395c31c281f8’,
parameters: ‘’,
http_response_code: 500,
http_response_body: ‘’

Couchbase server show another index created called Ottoman_scope_type and the status show created and stated the following:

Index definition has been saved. User Build Index to build the index. It is NOT serving scan requests yet.

Just wondering why is there a difference in output at the start of the test and what happen when ensureIndexes() is called? From a developer point of view, is there anything to do regarding this error?

1 Like

This might be an issue with the underlying SDK we are still investigating.