N1QL select after insert delay and Identity question

I’m currently working on a MVC project using Couchbase and noticed an odd behaviour when I do an insert then redirect to the list page. The insert is successful so it continue to show a list of created items but I’m not sure if it’s running to fast that it misses the lastest entry. If I do a manual refresh after the page is loaded the new entry is populated.

I have tried the following suggestion from the team on the irc channel with no success.

Here is the insert command

string documentID = string.Format("{0}.config", Guid.NewGuid());
var document = new Document<dynamic>
	Id = documentID,
	Content = configuration

var result = bucket.Upsert(document);
if (result.Success)
	success = 0;

Here is the Select command:

string query = "SELECT meta(`default`).id as id, name, description, dateCreated FROM `default`;"
var queryRequest = new QueryRequest().Statement(query).ScanConsistency(ScanConsistency.RequestPlus);

I have also tried

var queryRequest = new QueryRequest().Statement(query).ScanWait(new TimeSpan(0,0,20));

Also I’m trying the couchlabs Identity code and when I try to use a Role when the controller is looking for that Role it forgets about couchbase and looks for an SQL connection. Is this due to the code being in labs and not ready for a production environment?

@schuranator -

Based upon the documentation for scan consistency request_plus, should give you the behavior that you are seeking. The payload sent to the server looks like this:

 { "statement":"SELECT meta(`default`).id as id, name, description, dateCreated FROM `default`;","timeout":"75000ms","scan_consistency":"request_plus","client_context_id":"5::6"}

So the proper scan consistency is being sent to the query engine. I’ll ask around internally and see if I can get an answer.

Yes, most likely this is just a bug. You can create a ticket here.


Is it possible to debug on the couchbase server when I do the ScanConsistency to see why the data isn’t being populated. I was going to try passing the successful insert over which is cheating. I was also thinking of putting a timeout on my list to wait. But I’m not sure with 3 nodes how long I should wait.

It would be great to debug the ScanConsistency to see if that is working with my server nodes.

@schuranator -

What specific build/version of Couchbase are you using?


Three nodes running 4.0.0-4051 Community Edition