Skip to content

Commit

Permalink
CCBC-1397: reset "used" nodes when retrying query
Browse files Browse the repository at this point in the history
Change-Id: Ieec588c4a6e01bd3ff658fb0ec9483e572c16851
Reviewed-on: http://review.couchbase.org/c/libcouchbase/+/152801
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: David Kelly <davidmichaelkelly@gmail.com>
  • Loading branch information
avsej committed May 5, 2021
1 parent b185986 commit 37c7135
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/n1ql/n1ql.cc
Expand Up @@ -387,7 +387,20 @@ lcb_STATUS N1QLREQ::request_address()

int ix = lcbvb_get_randhost_ex(vbc, LCBVB_SVCTYPE_QUERY, mode, &used_nodes[0]);
if (ix < 0) {
return LCB_ERR_UNSUPPORTED_OPERATION;
/* check if we can reset list of used nodes for this request and start over */
bool reset_and_retry = false;
for (auto used : used_nodes) {
if (used) {
reset_and_retry = true;
break;
}
}
if (!reset_and_retry) {
return LCB_ERR_UNSUPPORTED_OPERATION;
}
used_nodes.clear();
used_nodes.resize(LCBVB_NSERVERS(vbc));
return request_address();
}
const char *rest_url = lcbvb_get_resturl(vbc, ix, LCBVB_SVCTYPE_QUERY, mode);
if (rest_url == nullptr) {
Expand Down

0 comments on commit 37c7135

Please sign in to comment.