mirror of https://gitee.com/bigwinds/arangodb
Wait for sync repl to settle after db create.
This commit is contained in:
parent
3e1b745f64
commit
5153b230b8
|
@ -1911,6 +1911,48 @@ function supervisionState() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief wait for synchronous replication to settle
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
function waitForSyncReplOneCollection(dbName, collName) {
|
||||||
|
console.debug("waitForSyncRepl:", dbName, collName);
|
||||||
|
var cinfo = global.ArangoClusterInfo.getCollectionInfo(dbName, collName);
|
||||||
|
var count = 120;
|
||||||
|
while (--count > 0) {
|
||||||
|
var shards = Object.keys(cinfo.shards);
|
||||||
|
var ccinfo = shards.map(function(s) {
|
||||||
|
return global.ArangoClusterInfo.getCollectionInfoCurrent(dbName,
|
||||||
|
collName, s).servers;
|
||||||
|
});
|
||||||
|
console.debug("waitForSyncRepl", shards, cinfo.shards, ccinfo);
|
||||||
|
var ok = true;
|
||||||
|
for (var i = 0; i < shards.length; ++i) {
|
||||||
|
if (cinfo.shards[shards[i]].length !== ccinfo[i].length) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require("internal").wait(0.5);
|
||||||
|
if (ok) {
|
||||||
|
console.debug("waitForSyncRepl: OK");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.warn("waitForSyncRepl:", dbName, collName, ": BAD");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function waitForSyncRepl(dbName, collList) {
|
||||||
|
if (! isCoordinator()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var ok = true;
|
||||||
|
for (var i = 0; i < collList.length; ++i) {
|
||||||
|
ok = waitForSyncReplOneCollection(dbName, collList[i].name()) && ok;
|
||||||
|
}
|
||||||
|
require("internal").wait(3.0); // For all synchronouse replications to settle
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
exports.bootstrapDbServers = bootstrapDbServers;
|
exports.bootstrapDbServers = bootstrapDbServers;
|
||||||
exports.coordinatorId = coordinatorId;
|
exports.coordinatorId = coordinatorId;
|
||||||
|
@ -1928,3 +1970,4 @@ exports.shardDistribution = shardDistribution;
|
||||||
exports.rebalanceShards = rebalanceShards;
|
exports.rebalanceShards = rebalanceShards;
|
||||||
exports.moveShard = moveShard;
|
exports.moveShard = moveShard;
|
||||||
exports.supervisionState = supervisionState;
|
exports.supervisionState = supervisionState;
|
||||||
|
exports.waitForSyncRepl = waitForSyncRepl;
|
||||||
|
|
Loading…
Reference in New Issue