Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcdaemon: improve close of state-changes stream after server-side termination #1973

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
better naming
canepat committed Apr 18, 2024
commit 56ecb797f24e0f0da60b24cc8abab60fedcd4887
12 changes: 6 additions & 6 deletions silkworm/rpc/ethdb/kv/state_changes_stream.cpp
Original file line number Diff line number Diff line change
@@ -61,8 +61,8 @@ Task<void> StateChangesStream::run() {

auto cancellation_slot = cancellation_signal_.slot();

bool cancelled{false};
while (!cancelled) {
bool closed{false};
while (!closed) {
auto state_changes_rpc{std::make_shared<StateChangesRpc>(*stub_, grpc_context_)};

{
@@ -81,14 +81,14 @@ Task<void> StateChangesStream::run() {
if (req_ec) {
std::error_code request_ec{req_ec};
if (request_ec.value() == grpc::StatusCode::CANCELLED || request_ec.value() == grpc::StatusCode::ABORTED) {
cancelled = true;
closed = true;
SILK_DEBUG << "State changes stream cancelled or closed by server while opening";
} else {
SILK_WARN << "State changes stream request error [" << req_ec.message() << "], schedule reopen";
retry_timer_.expires_after(registration_interval_);
const auto [ec] = co_await retry_timer_.async_wait(use_nothrow_awaitable);
if (ec == boost::asio::error::operation_aborted) {
cancelled = true;
closed = true;
SILK_DEBUG << "State changes wait before retry cancelled";
}
}
@@ -105,14 +105,14 @@ Task<void> StateChangesStream::run() {
cache_->on_new_block(reply);
} else {
if (read_ec.value() == grpc::StatusCode::CANCELLED || read_ec.value() == grpc::StatusCode::ABORTED) {
cancelled = true;
closed = true;
SILK_DEBUG << "State changes stream cancelled or closed by server while reading";
} else {
SILK_WARN << "State changes stream read error [" << read_ec.message() << "], schedule reopen";
retry_timer_.expires_after(registration_interval_);
const auto [ec] = co_await retry_timer_.async_wait(use_nothrow_awaitable);
if (ec == boost::asio::error::operation_aborted) {
cancelled = true;
closed = true;
SILK_DEBUG << "State changes wait before retry cancelled";
}
}