Error while creating an index

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.

Anyone? Any idea?
Also tried with SDK 3.1.6 but same problem.
Seems to work on Windows 10

Hi @alon.schachter,

I don’t have an answer, but here are some suggestions:

  1. Collect logs and post them here, especially anything that looks suspicious or related to the exception you’re seeing: Collecting Information and Logging in the .NET SDK with Couchbase Server | Couchbase Docs

  2. 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

  3. There is a 3.1.7 release of the .NET SDK. Might be worth a shot to see if there was an issue that was fixed. NuGet Gallery | CouchbaseNetClient 3.1.7

Uploading: logs.zip…
Hi @matthew.groves

The issue reproduces on Win server 2019.
The GetAwaiter().GetResult() has no effect on the issue.
Haven’t seen anything in 3.1.7 that might fix this.

Attaching logs (FYI, we are changing the projector 9999 port to 1701 after installation)

Logs1.zip (1.8 MB)

Hi @matthew.groves

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

@alon.schachter

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: https://issues.couchbase.com/browse/MB-11484

In the meantime, you can look at the work I’ve done on “couchbasefakeit” to help address the problem. You could either use it directly, or pull out the pieces you need. GitHub - brantburnett/couchbasefakeit: Docker scripts for a base Couchbase Server image for testing/development, with support for fakeit for data generation

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.

Brant

Hi @btburnett3

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:

And after you refresh the page, the sdk will be able to create an index.

So the question is, which dummy request can I send via the SDK to mimic whatever refreshing the Query tab does?

@alon.schachter

That’s a new one on me, I’m afraid, and outside my ability to help. Have you tried 6.6.2 Enterprise to see if it’s a bug that’s been fixed?

Brant

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));

Jeff

I’m on community I’m afraid.

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