N1qlQuery always fail


First of all, bkt_sample is proofed to be a valid bucket.
Then, callback if a built-in function in loopback.

query = N1qlQuery.fromString('SELECT DISTINCT category, style' + 'FROMbeer-sample' + 'WHERE type = "beer" AND ' + ' style LIKE "%Imperial%"' + 'ORDER BY category, style;'); bkt_sample.query(query, function(err, rows, meta) { callback( null, err ); });
After running, I always have an error of “cannot perform operations on a shutdown bucket”.
I found a thread on this forum to solve this issue by increase the timeout. So I added
bkt_sample.operationTimeout = 120 * 100000;
before bkt_sample.query

Now it returns “Segmentation fault (core dumped)”.
Anyone who knows how should fix this? Lots of thanks.


Hey @jcplus,

Could you provide more of your example code showing how you are connecting to the cluster? Usually you would get the shutdown bucket issue if you have attempted to connect to the cluster, but the connection failed. You could also subscribe to the ‘error’ event of the bucket to receive a notification when the bucket connection fails along with the reason why it failed in the form of an error object.

Cheers, Brett


Hi @brett19,

Please find code attached below. I also changed the query statement to a simpler one in case it doesn’t take too many space.
var config = require('./libs/config.json'); var couchbase = require('couchbase'); var cluster = new couchbase.Cluster( config.server ); var N1qlQuery = couchbase.N1qlQuery; var bkt_sample = cluster.openBucket( config.buckets.sample.name, config.buckets.buckets.password ); query = N1qlQuery.fromString('SELECT name FROM default LIMIT 1'); bkt_sample.query(query, function(err, rows, meta) { if (err) { console.log(err); } else { console.log(rows); } });


Not sure what happened but I found my newly created bucket is not indexed. So after I created and built the primary index of if, it’s working now.


Hey @jcplus,
That’s awesome to hear, let me know if you run into any further issues!
Cheers, Brett