Consistency Nodejs


#1

Hi everyone, what’s the difference between the ‘strong consistency per request’ and the ‘strong consistency per statement’ provided by N1QL? I’m currently using NodeJS SDK and I noticed that I can request these types of consistency using REQUEST_PLUS AND STATEMENT_PLUS


#2

Hi @donadev, for a single-statement request, they are equivalent.

When we add support for multi-statement requests, there will be a distinction.


#3

ok, thanks @geraldss. i really want to use them in my system, but with request plus consistency I cannot actually see the consistency itself. For example, if I create a document of type ‘x’, and immediately query the all set of documents with type = ‘x’, I can’t see the document that I just created in the result set. Does this kind of consistency force n1ql to reload indexes?


#4

This should be working in Beta. Can you try using curl and the N1QL REST API, just to be sure the scan_consistency parameter is being passed? And are you using the latest version of the node.js driver?


#5

I’ve tried to run a script that creates a doc in the bucket and tries to get it using curl in NodeJS, and I appended the consistency parameter but… it doesn’t work. How can I fix this problem, assuming that I’ve got N1QL DP4 and I will want to update to Couchbase 4 only when there will be a non-BETA stable release? Can I edit the source code forcing N1QL to access indexes only in stale=false mode? Is it possible? How?


#6

Couchbase Server 4.0 Beta and then GA will be the way N1QL Query is delivered. It would be really helpful if you can repeat your test to verify there that things behave as you expect. We do expect scan_consistency to give you the expected behavior with what we’re currently shipping in 4.0 Beta and the current node.js client.

Regarding editing the source code, it’s certainly possible since it is Open Source. @geraldss can guide better here but my bet is it may be a big undertaking since there are hundreds of changes from N1QL DP4 to the query service integrated in Couchbase 4.0 Beta.


#7

@donadev, if you want to keep your data in CB 3.0 until CB 4.0 ships in GA, you should do the following:

  • data in CB 3.0.3
  • install CB 4.0 Beta on a separate node
  • do not launch CB 4.0 – just start cbq-engine from the CB 4.0 install, and point it to your 3.0.3 cluster

This will allow you to continue to pick up our fixes to CB 4.0, including GA.


#8

I’ve tried to install couchbase server beta 4 and still not work. My workflow is the following:

  • Create doc with some particular property (for example type:‘item’)
  • Run this query immediately after : 'SELECT * FROM x WHERE type = ‘item’'
    the query doesn’t return the newly creted doc.

#9

This is a complete 4.0 Beta environment, correct? What were you using for scan_consistency in your query and how were you issuing the query? Was it just an HTTP request, or did you go through one of the SDKs?


#10

Me too, how to set consistency in couchbase node.js module?


#11

https://blog.couchbase.com/defining-scan-consistency-node-js-couchbase-application/ cc @ingenthr