Skip to content

Commit

Permalink
SERVER-7181 Fix error reporting in mongorestore during index build
Browse files Browse the repository at this point in the history
  • Loading branch information
renctan authored and milkie committed Oct 3, 2012
1 parent 19ecdc6 commit a84fe31
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/mongo/tools/restore.cpp
Expand Up @@ -480,18 +480,26 @@ class Restore : public BSONTool {
// We're stricter about errors for indexes than for regular data
BSONObj err = conn().getLastErrorDetailed(_curdb, false, false, _w);

if ( ! ( err["err"].isNull() ) ) {
if (err["err"].String() == "norepl" && _w > 1) {
if (err.hasField("err") && !err["err"].isNull()) {
if (err["err"].str() == "norepl" && _w > 1) {
error() << "Cannot specify write concern for non-replicas" << endl;
}
else {
error() << "Error creating index " << o["ns"].String();
error() << ": " << err["code"].Int() << " " << err["err"].String() << endl;
error() << "To resume index restoration, run " << _name << " on file" << _fileName << " manually." << endl;
string errCode;

if (err.hasField("code")) {
errCode = str::stream() << err["code"].numberInt();
}

error() << "Error creating index " << o["ns"].String() << ": "
<< errCode << " " << err["err"] << endl;
}

::abort();
}

massert(16439, str::stream() << "Error calling getLastError: " << err["errmsg"],
err["ok"].trueValue());
}
};

Expand Down

0 comments on commit a84fe31

Please sign in to comment.