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

fix(replication): slave blocks until keepalive timer is reached when master is gone without fin/rst notification #2662

Merged
merged 17 commits into from
Nov 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
16 changes: 15 additions & 1 deletion src/cluster/replication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,16 @@ Status ReplicationThread::parallelFetchFile(const std::string &dir,
if (this->stop_flag_) {
return {Status::NotOK, "replication thread was stopped"};
}
int sock_timeout_ms = 3000;
PragmaTwice marked this conversation as resolved.
Show resolved Hide resolved
ssl_st *ssl = nullptr;
#ifdef ENABLE_OPENSSL
if (this->srv_->GetConfig()->tls_replication) {
ssl = SSL_new(this->srv_->ssl_ctx.get());
}
auto exit = MakeScopeExit([ssl] { SSL_free(ssl); });
#endif
int sock_fd = GET_OR_RET(util::SockConnect(this->host_, this->port_, ssl).Prefixed("connect the server err"));
int sock_fd = GET_OR_RET(util::SockConnect(this->host_, this->port_, ssl, sock_timeout_ms, sock_timeout_ms)
PragmaTwice marked this conversation as resolved.
Show resolved Hide resolved
.Prefixed("connect the server err"));
#ifdef ENABLE_OPENSSL
exit.Disable();
#endif
Expand Down Expand Up @@ -874,6 +876,12 @@ Status ReplicationThread::fetchFile(int sock_fd, evbuffer *evbuf, const std::str
UniqueEvbufReadln line(evbuf, EVBUFFER_EOL_CRLF_STRICT);
if (!line) {
if (auto s = util::EvbufferRead(evbuf, sock_fd, -1, ssl); !s) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
git-hulk marked this conversation as resolved.
Show resolved Hide resolved
if (stop_flag_) {
return {Status::NotOK, "replication thread was stopped"};
}
continue;
}
PragmaTwice marked this conversation as resolved.
Show resolved Hide resolved
return std::move(s).Prefixed("read size");
}
continue;
Expand Down Expand Up @@ -907,6 +915,12 @@ Status ReplicationThread::fetchFile(int sock_fd, evbuffer *evbuf, const std::str
remain -= data_len;
} else {
if (auto s = util::EvbufferRead(evbuf, sock_fd, -1, ssl); !s) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
if (stop_flag_) {
return {Status::NotOK, "replication thread was stopped"};
}
continue;
}
return std::move(s).Prefixed("read sst file");
}
}
Expand Down
Loading