1

I use couchbase 4.0.1 with Java SDK.

This is my code:

bucket.async()
            .get(key)
            .onErrorResumeNext(throwable -> {
                if (throwable instanceof TimeoutException) {
                    return getBucket().async().getFromReplica(key, ReplicaMode.ALL);
                }
                return Observable.error(throwable);
            })
            .map(doc -> doc.content())
            .toBlocking()
            .singleOrDefault(null);

If I get TimeoutException - I go to the replica, but last week, due to a sever issue, we got OutOfMemory exception from one of our servers. Ofcourse we did not get the document from the replica and we suffered some exceptions of our own.

I'd like to know if should I go to the replica in any exception or not?

Thanks,

Ido

Ido Barash
  • 4,856
  • 11
  • 41
  • 78

1 Answers1

0

Always going to the replica is not going to help for some classes of errors, like DocumentDoesNotExistException of course.

For others that might indicate a cluster-wide issue, like CouchbaseOutOfMemoryException, going to the replica is an option BUT it could put more pressure on the cluster and make the problem worse.

It might be better to back off, wait a little and retry.

Simon Baslé
  • 27,105
  • 5
  • 69
  • 70