Skip to content

Commit

Permalink
[dcpdrain] Check the status for DcpStreamReq
Browse files Browse the repository at this point in the history
The user may not have access to stream the given
scope causing StreamReq to fail with "no access".
Previously this would cause dcpdrain to "hang" forever
sending DCP no-ops to the server.

Change-Id: I7b30835874518659625eab361b94e880fbf3bf2c
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/176965
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Richard de Mellow <richard.demellow@couchbase.com>
  • Loading branch information
trondn committed Jul 4, 2022
1 parent d188002 commit 6a16c25
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion programs/dcpdrain/dcpdrain.cc
Expand Up @@ -303,7 +303,22 @@ class DcpConnection {
}

void handleResponse(const cb::mcbp::Response& response) {
// Do nothing
if (cb::mcbp::isStatusSuccess(response.getStatus())) {
return;
}

if (response.getClientOpcode() ==
cb::mcbp::ClientOpcode::DcpStreamReq) {
std::cerr << TerminalColor::Red << response.toJSON(true).dump()
<< TerminalColor::Reset << std::endl;
stream_end++;
if (stream_end == vbuckets.size()) {
// we got all we wanted
connection->getUnderlyingAsyncSocket().setReadCB(nullptr);
connection->getUnderlyingAsyncSocket().close();
stop = std::chrono::steady_clock::now();
}
}
}

void handleDcpNoop(const cb::mcbp::Request& header) {
Expand Down

0 comments on commit 6a16c25

Please sign in to comment.