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

Detect and recover from a bad service node state #2241

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions llarp/router/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ namespace llarp
log::debug(logcat, "Network ID set to {}", conf.router.m_netId);
if (!conf.router.m_netId.empty() && strcmp(conf.router.m_netId.c_str(), llarp::DEFAULT_NETID))
{
is_default_netID = false;
const auto& netid = conf.router.m_netId;
llarp::LogWarn(
"!!!! you have manually set netid to be '",
Expand Down Expand Up @@ -933,6 +934,17 @@ namespace llarp
return;
// LogDebug("tick router");
const auto now = Now();

// If a node is deregistered while running (or is started before being registered),
// it can fail to properly connect to the network once registered (again). This does
// not *fix* that, but these symptoms should be sufficient to detect such a state and
// the node should recover upon restart.
if (is_default_netID and IsServiceNode() and uptime() > 1h and nodedb()->NumLoaded() < 10)
{
Stop();
return;
}

if (const auto delta = now - _lastTick; _lastTick != 0s and delta > TimeskipDetectedDuration)
{
// we detected a time skip into the futre, thaw the network
Expand Down
1 change: 1 addition & 0 deletions llarp/router/router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace llarp
{
llarp_time_t _lastPump = 0s;
bool ready;
bool is_default_netID{true};
// transient iwp encryption key
fs::path transport_keyfile;

Expand Down
1 change: 1 addition & 0 deletions llarp/util/thread/queue_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <algorithm>
#include <atomic>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <limits>
#include <string>
Expand Down