Skip to content

Commit

Permalink
feat: add migration_finalization_timeout_ms flag (#4301)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev authored Dec 13, 2024
1 parent 5363779 commit 55bc981
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/server/cluster/incoming_slot_migration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "server/main_service.h"
#include "util/fibers/synchronization.h"

ABSL_DECLARE_FLAG(int, slot_migration_connection_timeout_ms);
ABSL_DECLARE_FLAG(int, migration_finalization_timeout_ms);

namespace dfly::cluster {

Expand Down Expand Up @@ -173,7 +173,7 @@ void IncomingSlotMigration::Pause(bool pause) {
bool IncomingSlotMigration::Join(long attempt) {
const absl::Time start = absl::Now();
const absl::Duration timeout =
absl::Milliseconds(absl::GetFlag(FLAGS_slot_migration_connection_timeout_ms));
absl::Milliseconds(absl::GetFlag(FLAGS_migration_finalization_timeout_ms));

while (true) {
const absl::Time now = absl::Now();
Expand Down Expand Up @@ -209,7 +209,7 @@ void IncomingSlotMigration::Stop() {
// we need to Join the migration process to prevent data corruption
const absl::Time start = absl::Now();
const absl::Duration timeout =
absl::Milliseconds(absl::GetFlag(FLAGS_slot_migration_connection_timeout_ms));
absl::Milliseconds(absl::GetFlag(FLAGS_migration_finalization_timeout_ms));

while (true) {
const absl::Time now = absl::Now();
Expand Down
7 changes: 5 additions & 2 deletions src/server/cluster/outgoing_slot_migration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
#include "server/server_family.h"
#include "util/fibers/synchronization.h"

ABSL_FLAG(int, slot_migration_connection_timeout_ms, 5000, "Timeout for network operations");
ABSL_FLAG(int, slot_migration_connection_timeout_ms, 2000,
"Connection creating timeout for migration operations");
ABSL_FLAG(int, migration_finalization_timeout_ms, 30000,
"Timeout for migration finalization operation");

using namespace std;
using namespace facade;
Expand Down Expand Up @@ -333,7 +336,7 @@ bool OutgoingMigration::FinalizeMigration(long attempt) {

const absl::Time start = absl::Now();
const absl::Duration timeout =
absl::Milliseconds(absl::GetFlag(FLAGS_slot_migration_connection_timeout_ms));
absl::Milliseconds(absl::GetFlag(FLAGS_migration_finalization_timeout_ms));
while (true) {
const absl::Time now = absl::Now();
const absl::Duration passed = now - start;
Expand Down
1 change: 1 addition & 0 deletions src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ void Service::Init(util::AcceptServer* acceptor, std::vector<facade::Listener*>

config_registry.RegisterMutable("replica_partial_sync");
config_registry.RegisterMutable("replication_timeout");
config_registry.RegisterMutable("migration_finalization_timeout_ms");
config_registry.RegisterMutable("table_growth_margin");
config_registry.RegisterMutable("tcp_keepalive");
config_registry.RegisterMutable("managed_service_info");
Expand Down

0 comments on commit 55bc981

Please sign in to comment.