Hi.
I’m trying to run this command on .NET5 + SDK 3.1.4 + Couchbase 6.6.0 Community
var result = CouchbaseConnection.QueryAsync(“CREATE INDEX idx_id ON users_Couchbase (META().id)”).GetAwaiter().GetResult();
users_Couchbase is a Couchbase type bucket.
I’m getting the following error:
Exception of type ‘Couchbase.Core.Exceptions.IndexNotFoundException’ was thrown
If I run the CREATE INDEX command manually from the Couchbase Console UI it works.
I don’t have an answer, but here are some suggestions:
Collect logs and post them here, especially anything that looks suspicious or related to the exception you’re seeing: Logging | Couchbase Docs
I see you’re using .GetAwaiter().GetResult() instead of await. I have no idea if that’s related to the exception, but I’d generally recommend using await instead - Don't Block on Async Code
I have some more info about the bug.
It happens if you try to create the index immediately after installing Couchbase for the first time.
For example, after I install and configure it, if I go to the Query window in the Couchbase console I see a “404 while contacting query server…” message.
If I refresh the page, then the query window appears as it should, and from that point on I am able to create the index also via my script.
This has been reproduced on several Win 2019 servers
It’s a known detail that Couchbase takes some time to startup, and trying to connect to a cluster before it’s fully initialized can leave the SDK in an odd state. It’s a problem I’ve encountered a lot for local machine development, where we script up Couchbase in Docker.
There is an open issue on the Server to make this more monitorable: Loading...
It fully initializes the cluster with indexes, fake data, and more. Once complete, it writes out a “/notestatus/initialized” file to disk. I share that file with my application via a Docker volume mount, and set my application to watch for this file (local dev only) before app startup. It’s not elegant, but it works.
It’s not that it takes some time to startup.
You can install it, configure it, go on a vacation for a week, come back, go to the query tab and get this error:
Although I have seen that error message in the console, its only after creating a cluster and immediately trying to query the service, but its not yet warmed up.
Your best bet is probably using Ping:
var result = await cluster.PingAsync(new PingOptions().ServiceTypes(ServiceType.Query));
I’ll try that thanks.
But this should be really easy to reproduce for you.
It’s like you need to make some initial request for some Couchbase services to start warming up