ServiceNotAvailableException even after successful waitUntilReady()

I’ve just run into a strange error trying to run tests immediately after spinning up a Couchbase Server container. This is how I initialize it:

podman run -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11210:11210 -p 11280:11280 --name couchbase couchbase:7.2.3

if ! podman exec couchbase curl http://127.0.0.1:8091/pools -s --retry 15 --retry-all-errors > /dev/null; then
   podman container rm -f couchbase
   exit 1
fi

podman exec couchbase \
   couchbase-cli cluster-init -c 127.0.0.1 \
      --cluster-username Administrator \
      --cluster-password password \
      --cluster-ramsize 2048 \
      --services data,index,query,backup

podman exec couchbase \
   couchbase-cli bucket-create -c 127.0.0.1 -u Administrator -p password \
      --bucket default \
      --bucket-type couchbase \
      --bucket-replica 0 \
      --bucket-ramsize 2048 \
      --compression-mode active

I then call waitUntilReady() like so (pretty sure the defaultBucket one is redundant):

private Cluster cluster;
private Bucket defaultBucket;

public Couchbase(String connectionString, String username, String password) {
    var timeout = Duration.ofSeconds(10);
    var options = ClusterOptions.clusterOptions(username, password)
        .environment(environment -> environment.compressionConfig(config -> config.enable(true))
            .loggerConfig(config -> config.enableDiagnosticContext(false))
            .loggingMeterConfig(config -> config.enabled(false)));
    cluster = Cluster.connect(connectionString, options);
    cluster.waitUntilReady(timeout);
    defaultBucket = cluster.bucket("default");
    defaultBucket.waitUntilReady(timeout);
}

…and get this at the first cluster.query():

com.couchbase.client.core.error.ServiceNotAvailableException: The query service is not available in the cluster. {“completed”:true,“coreId”:“0xa951e6df00000001”,“idempotent”:false,“requestId”:13,“requestType”:“QueryRequest”,“retried”:0,“service”:{“operationId”:“null”,“statement”:“CREATE SCOPE default.videoland\n”,“type”:“query”},“timeoutMs”:75000,“timings”:{“totalMicros”:7183}}

Same thing happens when I set the second parameter so as to exclude the services I don’t use:

var waitOptions = WaitUntilReadyOptions.waitUntilReadyOptions()
    .serviceTypes(ServiceType.KV, ServiceType.QUERY)
    .desiredState(ClusterState.ONLINE);

Is there another curl --retry that I could add to my init script to actually wait for the services to be ready?

That looks like it should work. What version of the SDK do you have? waitUntilReady() is pretty reliable, but it did have some issues that were fixed. What is connectionString? What does SDK Doctor report about the cluster? If you loop on the cluster.query() operation, does it eventually succeed?

What version of the SDK do you have?

Pretty sure it was com.couchbase.client:java-client:3.5.0.

What is connectionString?

couchbase://127.0.0.1

What does SDK Doctor report about the cluster? If you loop on the cluster.query() operation, does it eventually succeed?

I can’t check it right now but I had to start my application REALLY fast in order for this error to manifest, right after setting up the container.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.