Couchbase exception when master is down

Hi,

I’m trying to use getFromReplica in case I failed to get a document because the master is down.
Which exception should I catch in situation of the master is down?
I want to do getFromReplica only when the master is down, and not in any other case.

Thanks,
Asaf.

If a get-request is in-flight and the active node goes down, you’ll hit a RequestCancelledException. This one you definitely want to use falling back to the getFromReplica. For the other cases, it depends which retry strategy (configurable on the environment) you use: the default one is best-effort, so it will keep retrying the op (rescheduling) until the timeout hits, so you’ll get a timeout exception there. If you use fail fast, then it immediately short-circuits and you get a RequestCancelledException again.

You can use either of those, it depends a little on your use case. I’d say RCE for sure, and how and when to retry on a timeout depends on your app.

Thanks for your answer.
I have one more question please for just being sure - can I have a scenario that I’m getting TemporaryFailureException in this case?