0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

clearer error msgs

This commit is contained in:
dwight 2010-11-12 20:46:02 -05:00
parent 57e6a4f575
commit 786801bb70
2 changed files with 38 additions and 22 deletions

View File

@ -1331,7 +1331,15 @@ const StringData _jscode_raw_utils =
"cfg.arbiterOnly = true;\n"
"}\n"
"c.members.push(cfg);\n"
"return db._adminCommand({ replSetReconfig: c });\n"
"var res = null;\n"
"try {\n"
"res = db.adminCommand({ replSetReconfig: c });\n"
"}\n"
"catch (e) {\n"
"print(\"shell got exception during reconfig: \" + e);\n"
"print(\"in some circumstances, the primary steps down and closes connections on a reconfig\");\n"
"}\n"
"return res;\n"
"}\n"
"rs.stepDown = function (secs) { return db._adminCommand({ replSetStepDown:secs||60}); }\n"
"rs.freeze = function (secs) { return db._adminCommand({replSetFreeze:secs}); }\n"

View File

@ -1306,27 +1306,35 @@ rs.reconfig = function (cfg) {
print("in some circumstances, the primary steps down and closes connections on a reconfig");
}
return res;
}
rs.add = function (hostport, arb) {
var cfg = hostport;
var local = db.getSisterDB("local");
assert(local.system.replset.count() <= 1, "error: local.system.replset has unexpected contents");
var c = local.system.replset.findOne();
assert(c, "no config object retrievable from local.system.replset");
c.version++;
var max = 0;
for (var i in c.members)
if (c.members[i]._id > max) max = c.members[i]._id;
if (isString(hostport)) {
cfg = { _id: max + 1, host: hostport };
if (arb)
cfg.arbiterOnly = true;
}
c.members.push(cfg);
return db._adminCommand({ replSetReconfig: c });
}
rs.add = function (hostport, arb) {
var cfg = hostport;
var local = db.getSisterDB("local");
assert(local.system.replset.count() <= 1, "error: local.system.replset has unexpected contents");
var c = local.system.replset.findOne();
assert(c, "no config object retrievable from local.system.replset");
c.version++;
var max = 0;
for (var i in c.members)
if (c.members[i]._id > max) max = c.members[i]._id;
if (isString(hostport)) {
cfg = { _id: max + 1, host: hostport };
if (arb)
cfg.arbiterOnly = true;
}
c.members.push(cfg);
var res = null;
try {
res = db.adminCommand({ replSetReconfig: c });
}
catch (e) {
print("shell got exception during reconfig: " + e);
print("in some circumstances, the primary steps down and closes connections on a reconfig");
}
return res;
}
rs.stepDown = function (secs) { return db._adminCommand({ replSetStepDown:secs||60}); }
rs.freeze = function (secs) { return db._adminCommand({replSetFreeze:secs}); }