Details
-
Bug
-
Resolution: Won't Fix
-
Major
-
None
-
None
-
DOC-S19-Jun29, DOC-2019-S04-Feb22, DOC-2019-S05-Mar08, DOC-2019-S07-Apr05, DOC-2019-S09-May03, DOC-2019-S11-May31, DOC-2019-S14-Jul12, DOC-2019-S18-Sep06, DOC-2020-S1-Jan13, DOC-2020-S3-Feb23, DOC-2020-S5-Mar22
-
1
Description
At the bottom of the page there is code sample.
the code sample vary between languages and the getFromReplica part is reactive to a different exception which make it very difficult to determine when to use that piece of code.
for example, .Net is reacting to KeyNotFound (which is incorrect):
const string key = "ReplicaKey"; |
var value = bucket.Get<string>(key);
|
if (value.Status == ResponseStatus.KeyNotFound) |
{
|
var result = bucket.GetFromReplica<string>(key); //do something with the result |
}
|
Java - to any Couchbase Exception (which is incorrect as well): static JsonDocument
getOrGetReplica(Bucket bucket, String docId) {
|
try { return bucket.get(docId); |
} catch (CouchbaseException e) { |
Iterator<JsonDocument> docs = bucket.getFromReplica(docId);
|
return docs.hasNext() ? docs.next() : null; |
}
|
}
|
Python - to networkError:
try: |
result = cb.get("docid") |
except CouchbaseNetworkError as e:
|
print "Got error. Fetching from replica!" |
result = cb.get(‘docid’, replica=True)
|
Node.js to a general couchbaseException:
static JsonDocument getOrGetReplica(Bucket bucket, String docId) { |
try { return bucket.get(docId); } |
catch (CouchbaseException e) |
{ Iterator<JsonDocument> docs = bucket.getFromReplica(docId); return docs.hasNext() ? docs.next() : null; } |
}
|
It needed to be clear what is the scenario Couchbase recommending to use it.
Attachments
Issue Links
- has to be done after
-
PCBC-558 GetFromReplica / Failure Considerations
- Open
-
PYCBC-516 GetFromReplica / Failure Considerations
- Open
-
GOCBC-338 GetFromReplica / Failure Considerations
- Resolved
-
JCBC-1228 GetFromReplica / Failure Considerations
- Resolved
-
JSCBC-494 GetFromReplica / Failure Considerations
- Resolved
-
NCBC-1741 GetFromReplica / Failure Considerations
- Resolved
-
CCBC-962 GetFromReplica / Failure Considerations
- Closed
- relates to
-
DOC-2828 Address other cases in which a replica read should be used based on the ResponseStatus that is returned by the SDK.
- Closed