mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Merge pull request #2330 from zerotier/controller-redis
break up redis tx inserts into smaller chunks
This commit is contained in:
commit
93fd93da5c
1 changed files with 26 additions and 2 deletions
|
@ -780,11 +780,25 @@ void PostgreSQL::initializeNetworks()
|
||||||
fprintf(stderr, "adding networks to redis...\n");
|
fprintf(stderr, "adding networks to redis...\n");
|
||||||
if (_rc->clusterMode) {
|
if (_rc->clusterMode) {
|
||||||
auto tx = _cluster->transaction(_myAddressStr, true, false);
|
auto tx = _cluster->transaction(_myAddressStr, true, false);
|
||||||
tx.sadd(setKey, networkSet.begin(), networkSet.end());
|
uint64_t count = 0;
|
||||||
|
for (std::string nwid : networkSet) {
|
||||||
|
tx.sadd(setKey, nwid);
|
||||||
|
if (++count % 30000 == 0) {
|
||||||
|
tx.exec();
|
||||||
|
tx = _cluster->transaction(_myAddressStr, true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
tx.exec();
|
tx.exec();
|
||||||
} else {
|
} else {
|
||||||
auto tx = _redis->transaction(true, false);
|
auto tx = _redis->transaction(true, false);
|
||||||
tx.sadd(setKey, networkSet.begin(), networkSet.end());
|
uint64_t count = 0;
|
||||||
|
for (std::string nwid : networkSet) {
|
||||||
|
tx.sadd(setKey, nwid);
|
||||||
|
if (++count % 30000 == 0) {
|
||||||
|
tx.exec();
|
||||||
|
tx = _redis->transaction(true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
tx.exec();
|
tx.exec();
|
||||||
}
|
}
|
||||||
fprintf(stderr, "done.\n");
|
fprintf(stderr, "done.\n");
|
||||||
|
@ -1005,14 +1019,24 @@ void PostgreSQL::initializeMembers()
|
||||||
fprintf(stderr, "Load member data into redis...\n");
|
fprintf(stderr, "Load member data into redis...\n");
|
||||||
if (_rc->clusterMode) {
|
if (_rc->clusterMode) {
|
||||||
auto tx = _cluster->transaction(_myAddressStr, true, false);
|
auto tx = _cluster->transaction(_myAddressStr, true, false);
|
||||||
|
uint64_t count = 0;
|
||||||
for (auto it : networkMembers) {
|
for (auto it : networkMembers) {
|
||||||
tx.sadd(it.first, it.second);
|
tx.sadd(it.first, it.second);
|
||||||
|
if (++count % 30000 == 0) {
|
||||||
|
tx.exec();
|
||||||
|
tx = _cluster->transaction(_myAddressStr, true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tx.exec();
|
tx.exec();
|
||||||
} else {
|
} else {
|
||||||
auto tx = _redis->transaction(true, false);
|
auto tx = _redis->transaction(true, false);
|
||||||
|
uint64_t count = 0;
|
||||||
for (auto it : networkMembers) {
|
for (auto it : networkMembers) {
|
||||||
tx.sadd(it.first, it.second);
|
tx.sadd(it.first, it.second);
|
||||||
|
if (++count % 30000 == 0) {
|
||||||
|
tx.exec();
|
||||||
|
tx = _redis->transaction(true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tx.exec();
|
tx.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue