mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-16 12:06:55 +02:00
error recovery in redis online notification
If a redis cluster member fails over to the slave, we'll get an error from not specifying the key for the insert. Recover from that instead of crashing the controller
This commit is contained in:
parent
7a138f963c
commit
0f17508cac
1 changed files with 12 additions and 8 deletions
|
@ -1540,15 +1540,19 @@ void PostgreSQL::onlineNotification_Redis()
|
|||
std::lock_guard<std::mutex> l(_lastOnline_l);
|
||||
lastOnline.swap(_lastOnline);
|
||||
}
|
||||
if (!lastOnline.empty()) {
|
||||
if (_rc->clusterMode) {
|
||||
auto tx = _cluster->redis(controllerId).transaction(true);
|
||||
_doRedisUpdate(tx, controllerId, lastOnline);
|
||||
} else {
|
||||
auto tx = _redis->transaction(true);
|
||||
_doRedisUpdate(tx, controllerId, lastOnline);
|
||||
try {
|
||||
if (!lastOnline.empty()) {
|
||||
if (_rc->clusterMode) {
|
||||
auto tx = _cluster->redis(controllerId).transaction(true);
|
||||
_doRedisUpdate(tx, controllerId, lastOnline);
|
||||
} else {
|
||||
auto tx = _redis->transaction(true);
|
||||
_doRedisUpdate(tx, controllerId, lastOnline);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (sw::redis::Error &e) {
|
||||
fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what());
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue