1
0
Fork 0
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:
Borys 2024-11-18 09:28:07 +02:00 committed by GitHub
parent ee01dc4fb5
commit 5e2b48c3f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();