Skip to content

Commit

Permalink
Fix brpc randomly print stack issue (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
tongke6 authored Dec 12, 2024
1 parent 3df391a commit 871832a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bazel_dep(name = "rules_foreign_cc", version = "0.12.0")
bazel_dep(name = "platforms", version = "0.0.8")

# self-hosted registry
bazel_dep(name = "brpc", version = "1.11.0-20241119-72ce354")
bazel_dep(name = "brpc", version = "1.11.0-20241212-282bc90")
bazel_dep(name = "cpu_features", version = "0.9.0")
bazel_dep(name = "simplest-ot", version = "0.0.1")
bazel_dep(name = "libtommath", version = "0.0.0-20240407-42b3fb0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ bool DummyBlackBoxServiceImpl::OnPush(brpc::Controller* cntl,
"Header: x-ptp-target-node-id: {} is not configed", *target_node));
} else {
auto old_cntl = std::make_unique<brpc::Controller>();
old_cntl->http_request().Swap(cntl->http_request());
old_cntl->request_attachment().swap(cntl->request_attachment());
old_cntl->http_request() = cntl->http_request();
old_cntl->request_attachment() = cntl->request_attachment();

bool success = false;
for (uint32_t i = 0; i != invoke_max_retry_cnt_; ++i) {
auto new_cntl = std::make_unique<brpc::Controller>();
new_cntl->http_request().Swap(old_cntl->http_request());
new_cntl->http_request() = old_cntl->http_request();
new_cntl->ignore_eovercrowded();
new_cntl->http_request().set_method(brpc::HTTP_METHOD_POST);
new_cntl->http_request().uri() =
node_id_to_ip_[*target_node] + "/v1/interconn/chan/invoke";
new_cntl->request_attachment().swap(old_cntl->request_attachment());
new_cntl->request_attachment() = old_cntl->request_attachment();
SPDLOG_DEBUG("push: target_node {}, retry: {}",
new_cntl->request_attachment().to_string(), i);
node_channels_[*target_node]->CallMethod(nullptr, new_cntl.get(), nullptr,
Expand All @@ -95,7 +95,6 @@ bool DummyBlackBoxServiceImpl::OnPush(brpc::Controller* cntl,
"{}:{}/v1/interconn/chan/invoke",
new_cntl->ErrorCode(), new_cntl->ErrorText(), *target_node,
node_id_to_ip_[*target_node]);
new_cntl.swap(old_cntl);
std::this_thread::sleep_for(
std::chrono::milliseconds(invoke_retry_interval_ms_));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ class MockTransportTest : public ::testing::Test {
auto brpc_channel = std::make_unique<brpc::Channel>();

int res = brpc_channel->Init(server_url_.c_str(), "", &options);
if (res != 0) {
YACL_THROW_NETWORK_ERROR(
"Fail to connect to transport service, host={}, err_code={}",
server_url_, res);
}
ASSERT_TRUE(res == 0) << fmt::format(
"Fail to connect to transport service, host={}, err_code={}",
server_url_, res);
channel_ = std::move(brpc_channel);
}

Expand Down

0 comments on commit 871832a

Please sign in to comment.