Forcing durability requirements failure

#1

For the sake of some unit tests I wish to force “Durability requirements failed” error. I am using the couchbase mock utility. I am running locally. I thought I would get the error if I for example did an upsert with options:

{ persist_to: 2, replicate_to: 2 }

But document gets upserted fine without any issues. Is there any way to force this error?

couchbase lib version: 2.0.12
npm version: 2.14.7
node version: 0.12.7

I also can’t seem to force it if I run it locally against my server (1 SSD, 1 node).

var data = {foo: 'bar'};
var key = 'sometestdoc::' + uuid.v4();
bucket.upsert(key, data, {persist_to: 4, replicate_to: 4}, function (err, createdDoc) {
      console.dir(err);
      console.dir(createdDoc);

      bucket.get(key, function(err, qdoc) {
        console.dir(err);
        console.dir(qdoc);
      });
    });

Everything works fine.
Couchbase Server Version 3.0.2-1603-rel

Thanks,

#2

In the node.js SDK, if you specify durability requirements which exceed available limits, the requirements are automatically rounded to the “maximum available”: https://github.com/couchbase/couchnode/blob/master/src/operations.cc#L373

Feel free to file an issue if you think this is a bug. It would seem that in most cases, the intent behind durability operations is to provide increased durability (to the extent of “as much as possible”) rather than a fixed form of durability to a specific number of nodes. Additionally, if a server is removed from the cluster and the durability requirements remain fixed in code, operations would start needlessly failing (unless of course, the application has some certain strict requirements to only function if an item is sufficiently durable to n number of nodes, rather than “as many as possible”).