Silent Failure in Upsert while upserting documents Java SDK 2.3.3


We are using Java SDK 2.3.3 and we found that the upsert is failing without any exceptions. We are using couchbase server 4.1 and storing LegacyDocuments. Below is the code snippet for storing documnets.

/* Upsert Code*/
LegacyDocument document = LegacyDocument.create(key, ttl, value);
couchManager.getDataBucket(requestType).async().upsert(document); //This gives an AsyncBucket and does an upsert operation.

/* Environment Configuration*
couchbaseEnvironment = DefaultCouchbaseEnvironment.builder()
.keepAliveInterval(keepAliveInterval * 1000)

Please let me know if we are doing anything wrong? As this was running successfully on SDK version 2.1.2

Dhawal Patel

If you perform an async operation you need to subscribe to it, otherwise it will not be executed.

For blocking, try .upsert(document).toBlocking().single(); or if you want to still be async use .subscribe() and variants, but keep in mind that this won’t be executed on the current thread so don’t use .subscribe() and then let the main thread exit.

The documentation has lots of stuff on this topic!

The reason why it did work on 2.1 is that the observables were “hot” back then, but your code was still wrong from a contract perspective - you always need to subscribe to an observable to execute it.

Yeah it was hot observable that’s why we dint do any blocking subscription. I have one more doubt this subscription will execute on which threadpool? cb-io or cb-core?

cb-computation, like in 2.1

Ok… Thanks a lot for you help.

1 Like