Hello,
So now that it is clear what the source of the problem is let me explain it.
As you probably know the set operation is asynchronous, so the client push the key,value on the network without blocking or checking anything. (it will only failed at this point if the socket/connection is not valid anymore).
So what you have to do in your application is to “check” the status of the operation, the way it is done with Couchbase client API is using a java Future, the OperationFuture object that allows you to check to get the status.
When I asked you to do a client.set(K,V).get()
it is a way to do a “synchronous” call since it will wait to have the response to go to the next operation.
The proper way to work if you want to “inject” many many things is to:
- inject document in Couchbase
- keep a reference to the OperationFuture
- check the status of the operation, and in case of failure redo the operation and/or log the error.
I have created a gist with the code:
Some part of it:
…
for (int i = 0 ; i <= 500000 ; i++) {
allOps.add(cb.set(“key::” + i, UUID.randomUUID().toString()));
}
…
for(OperationFuture op : allOps) {
if (! op.getStatus().isSuccess()) {
System.out.println(“Key: key:”+ op.getKey() +" not saved due to ‘"+ op.getStatus().getMessage() +"’. Please retry" );
}
}
…
So if you look in the stats of your bucket using the Web console or the cbstats command you will see the error too.
Regards
Tug
@tgrall