Skip to content

Commit

Permalink
fix: Retry sentinel startup on failure
Browse files Browse the repository at this point in the history
In particular, retry N times (N = 3 for now), increasing the retry
delay on each failure (linearly, for the moment).

Co-authored-by: Michael L. Szulczewski <[email protected]>
Signed-off-by: Sam Stuewe <[email protected]>
  • Loading branch information
HalosGhost and mszulcz-mitre committed Dec 6, 2022
1 parent 5b3e8b1 commit 3411d13
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/uhs/twophase/sentinel_2pc/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ namespace cbdc::sentinel_2pc {
m_logger->info("Sentinel public key:", cbdc::to_string(pubkey));
}

if(!m_coordinator_client.init()) {
m_logger->warn("Failed to start coordinator client");
auto retry_delay = std::chrono::seconds(1);
auto retry_threshold = 3;
while(!m_coordinator_client.init() && retry_threshold-- > 0) {
m_logger->warn("Failed to start coordinator client.");
if(retry_threshold > 0) {
m_logger->warn("Retrying...");
}
std::this_thread::sleep_for(retry_delay++);
}

for(const auto& ep : m_opts.m_sentinel_endpoints) {
Expand Down

0 comments on commit 3411d13

Please sign in to comment.