TIL: Creating a redis transaction without sending any commands throws an exception

So let's not do that
This commit is contained in:
Grant Limberg 2020-05-18 13:58:29 -07:00
parent b637ced1ee
commit 7a138f963c
No known key found for this signature in database
GPG Key ID: 2BA62CCABBB4095A

View File

@ -1540,15 +1540,15 @@ void PostgreSQL::onlineNotification_Redis()
std::lock_guard<std::mutex> l(_lastOnline_l);
lastOnline.swap(_lastOnline);
}
if (_rc->clusterMode) {
auto tx = _cluster->redis(controllerId).transaction(true);
_doRedisUpdate(tx, controllerId, lastOnline);
} else {
auto tx = _redis->transaction(true);
_doRedisUpdate(tx, controllerId, 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);
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
@ -1557,6 +1557,7 @@ void PostgreSQL::_doRedisUpdate(sw::redis::Transaction &tx, std::string &control
std::unordered_map< std::pair<uint64_t,uint64_t>,std::pair<int64_t,InetAddress>,_PairHasher > &lastOnline)
{
fprintf(stderr, "Redis Update\n");
nlohmann::json jtmp1, jtmp2;
for (auto i=lastOnline.begin(); i != lastOnline.end(); ++i) {
uint64_t nwid_i = i->first.first;