Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
When starting the CouchbaseContainer sometimes this error occurs:
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:563)
at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:354)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
... 8 more
Caused by: java.lang.IllegalStateException: Could not create primary index for bucket default-bucket: Response{protocol=http/1.1, code=500, message=Internal Server Error, url=http://localhost:33753/query/service}, body={
"requestID": "efb1e253-78dc-477e-841f-d74e1ad4a6d2",
"signature": null,
"results": [
],
"errors": [{"code":5000,"msg":"GSI CreatePrimaryIndex() - cause: Index creation for index #primary, bucket default-bucket, scope _default, collection _default cannot start. Reason: Create index or Alter replica cannot proceed due to rebalance in progress..","reason":{"_level":"exception","caller":"secondary_index:413","cause":{"error":"Index creation for index #primary, bucket default-bucket, scope _default, collection _default cannot start.","reason":"Create index or Alter replica cannot proceed due to rebalance in progress..","source":"CreatePrimaryIndex()"},"code":4350,"icause":"Index creation for index #primary, bucket default-bucket, scope _default, collection _default cannot start. Reason: Create index or Alter replica cannot proceed due to rebalance in progress..","key":"indexing.error","message":"GSI CreatePrimaryIndex()"}}],
"status": "fatal",
"metrics": {"elapsedTime": "45.456464ms","executionTime": "45.368677ms","resultCount": 0,"resultSize": 0,"serviceLoad": 1,"errorCount": 1}
}
Apparently the database is rebalancing, preventing the creation of the primary index.
We propose to make the creation of the primary index retryable, as many other operations occuring during the set-up of the container.
When starting the
CouchbaseContainer
sometimes this error occurs:Apparently the database is rebalancing, preventing the creation of the primary index.
We propose to make the creation of the primary index retryable, as many other operations occuring during the set-up of the container.