summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2015-05-05 09:39:43 -0400
committerScott Hernandez <scotthernandez@gmail.com>2015-06-08 10:43:06 -0400
commit9706bfd8946fdcfdbd97b9f451522666355985f1 (patch)
treecaf5ba719ab41253d1c1dfbe897624001ed48811 /src/mongo/db
parentb1d6f667a771fb5768978e89ae32cc862b74904f (diff)
downloadmongo-9706bfd8946fdcfdbd97b9f451522666355985f1.tar.gz
SERVER-18326: do not shutdown if oplog is empty during rollback
(cherry picked from commit e74dc41583dde9e40e08f97c6bb6a307a973a199)
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index e411d7b8573..3f523b03e19 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -257,10 +257,10 @@ namespace {
fixUpInfo.toRefetch.insert(doc);
}
- void syncRollbackFindCommonPoint(OperationContext* txn,
- DBClientConnection* them,
- FixUpInfo& fixUpInfo) {
+ StatusWith<FixUpInfo> syncRollbackFindCommonPoint(OperationContext* txn,
+ DBClientConnection* them) {
Client::Context ctx(txn, rsoplog);
+ FixUpInfo fixUpInfo;
boost::scoped_ptr<PlanExecutor> exec(
InternalPlanner::collectionScan(txn,
@@ -272,7 +272,7 @@ namespace {
RecordId ourLoc;
if (PlanExecutor::ADVANCED != exec->getNext(&ourObj, &ourLoc)) {
- throw RSFatalException("our oplog empty or unreadable");
+ return StatusWith<FixUpInfo>(ErrorCodes::OplogStartMissing, "no oplog during initsync");
}
const Query query = Query().sort(reverseNaturalObj);
@@ -315,7 +315,7 @@ namespace {
log() << "replSet rollback findcommonpoint scanned : " << scanned;
fixUpInfo.commonPoint = ourTime;
fixUpInfo.commonPointOurDiskloc = ourLoc;
- return;
+ break;
}
refetch(fixUpInfo, ourObj);
@@ -364,6 +364,8 @@ namespace {
ourTime = ourObj["ts"]._opTime();
}
}
+
+ return StatusWith<FixUpInfo>(fixUpInfo);
}
bool copyCollectionFromRemote(OperationContext* txn,
@@ -787,7 +789,18 @@ namespace {
log() << "rollback 2 FindCommonPoint";
try {
- syncRollbackFindCommonPoint(txn, oplogreader->conn(), how);
+ StatusWith<FixUpInfo> res = syncRollbackFindCommonPoint(txn, oplogreader->conn());
+ if (!res.isOK()) {
+ switch (res.getStatus().code()) {
+ case ErrorCodes::OplogStartMissing:
+ return 1;
+ default:
+ throw new RSFatalException(res.getStatus().toString());
+ }
+ }
+ else {
+ how = res.getValue();
+ }
}
catch (RSFatalException& e) {
error() << string(e.what());