mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-15 17:51:06 +00:00
fix: migration ACK response processing (#4140)
This commit is contained in:
parent
ee01dc4fb5
commit
5e2b48c3f3
1 changed files with 25 additions and 13 deletions
|
@ -317,21 +317,33 @@ bool OutgoingMigration::FinalizeMigration(long attempt) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (auto resp = ReadRespReply(absl::GetFlag(FLAGS_slot_migration_connection_timeout_ms)); !resp) {
|
||||
LOG(WARNING) << resp.error();
|
||||
return false;
|
||||
}
|
||||
const absl::Time start = absl::Now();
|
||||
const absl::Duration timeout =
|
||||
absl::Milliseconds(absl::GetFlag(FLAGS_slot_migration_connection_timeout_ms));
|
||||
while (true) {
|
||||
const absl::Time now = absl::Now();
|
||||
const absl::Duration passed = now - start;
|
||||
if (passed >= timeout) {
|
||||
LOG(WARNING) << "Timeout fot ACK " << attempt;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckRespFirstTypes({RespExpr::INT64})) {
|
||||
LOG(WARNING) << "Incorrect response type: "
|
||||
<< facade::ToSV(LastResponseArgs().front().GetBuf());
|
||||
return false;
|
||||
}
|
||||
if (auto resp = ReadRespReply(absl::ToInt64Milliseconds(passed - timeout)); !resp) {
|
||||
LOG(WARNING) << resp.error();
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto attempt_res = get<int64_t>(LastResponseArgs().front().u);
|
||||
if (attempt_res != attempt) {
|
||||
LOG(WARNING) << "Incorrect attempt payload, sent " << attempt << " received " << attempt_res;
|
||||
return false;
|
||||
if (!CheckRespFirstTypes({RespExpr::INT64})) {
|
||||
LOG(WARNING) << "Incorrect response type: "
|
||||
<< facade::ToSV(LastResponseArgs().front().GetBuf());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (const auto res = get<int64_t>(LastResponseArgs().front().u); res == attempt) {
|
||||
break;
|
||||
} else {
|
||||
LOG(WARNING) << "Incorrect attempt payload, sent " << attempt << " received " << res;
|
||||
}
|
||||
}
|
||||
|
||||
auto is_error = CheckFlowsForErrors();
|
||||
|
|
Loading…
Reference in a new issue