@brett19 this is a new issue introduced in couchbase 2.1.7. On running many n1ql queries you get the stack trace below.
In the future, if couchbase on github enables issues, I’d file this there.
/Users/mda/sw/ow-back/node_modules/couchbase/lib/n1qlquery.js:82
throw new Error('consistency and consistentWith must be use exclusively.');
^
Error: consistency and consistentWith must be use exclusively.
at N1qlStringQuery.consistency (/Users/mda/sw/ow-back/node_modules/couchbase/lib/n1qlquery.js:82:11)
at Models.runN1ql (/Users/mda/sw/ow-back/dist/models/index.js:346:12)
at /Users/mda/sw/ow-back/dist/models/index.js:234:13
at handler (/Users/mda/sw/ow-back/node_modules/ottoman/lib/ottoman.js:901:9)
at /Users/mda/sw/ow-back/node_modules/ottoman/lib/cbstoreadapter.js:508:7
at /Users/mda/sw/ow-back/node_modules/ottoman/lib/cbstoreadapter.js:443:32
at N1qlQueryResponse.<anonymous> (/Users/mda/sw/ow-back/node_modules/couchbase/lib/bucket.js:733:7)
at emitTwo (events.js:100:13)
at N1qlQueryResponse.emit (events.js:185:7)
at /Users/mda/sw/ow-back/node_modules/couchbase/lib/bucket.js:667:17
The problem I tracked down to this bit of this commit:
Here, a consistentWith
function is introduced that can’t be used in combination with consistency
. It seems if some other code does N1qlQuery.fromString
and then adjusts the consistency with consistency
this results, although I can’t trace where/how consistentWith is getting called to create the conflict.
Here’s the code of the function (runN1ql) that’s provoking the error:
/**
* Returns a promise to run the given n1ql query against the db.
* @param query either a couchbase.N1qlQuery (pre-prepared) or a stringify
* @param parameterBindings if any
* @returns a promise that resolves to query results.
*/
runN1ql(query, parameterBindings = {}, options = {}) {
let n1ql = query;
if (!(query instanceof couchbase.N1qlQuery)) {
n1ql = couchbase.N1qlQuery.fromString(query);
}
// log.info('Executing n1ql query', { n1ql });
n1ql.consistency(options.consistency || DEFAULT_N1QL_CONSISTENCY);
return new Promise((resolve, reject) => {
this.bucket.query(n1ql, parameterBindings, (err, rows, meta) => {
if (err) { return reject(err); }
return resolve({ rows, meta });
});
});
}