Skip to content

Commit 9205144

Browse files
committed
SERVER-19128 Fix crashing secondary index builds
1 parent 375b4ff commit 9205144

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/mongo/db/index_builder.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace {
159159
try {
160160
status = indexer.init(_index);
161161
if ( status.code() == ErrorCodes::IndexAlreadyExists ) {
162-
if (allowBackgroundBuilding) {
162+
if (allowBackgroundBuilding && !haveSetBgIndexStarting) {
163163
// Must set this in case anyone is waiting for this build.
164164
_setBgIndexStarting();
165165
}
@@ -209,11 +209,14 @@ namespace {
209209
status = wce.toStatus();
210210
}
211211

212-
if (status.code() != ErrorCodes::WriteConflict)
212+
if (status.code() == ErrorCodes::WriteConflict) {
213+
LOG(2) << "WriteConflictException while creating index in IndexBuilder, retrying.";
214+
} else if (status.code() == 28550) {
215+
LOG(2) << "Status 28550 when building an index in IndexBuilder, retrying";
216+
} else {
213217
return status;
218+
}
214219

215-
216-
LOG(2) << "WriteConflictException while creating index in IndexBuilder, retrying.";
217220
txn->recoveryUnit()->commitAndRestart();
218221
}
219222
}

src/mongo/db/repl/oplog.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ namespace {
313313
b.appendTimestamp("ts", slot.first.asDate());
314314
b.append("op", opstr);
315315
b.append("ns", ns);
316-
if (fromMigrate)
316+
if (fromMigrate)
317317
b.appendBool("fromMigrate", true);
318318
if ( bb )
319319
b.appendBool("b", *bb);
@@ -412,6 +412,8 @@ namespace {
412412
checkOplogInsert(localOplogRSCollection->insertDocument(txn, op, false));
413413

414414
if (!(lastOptime < ts)) {
415+
auto opBeingApplied = op.toString();
416+
auto previousOp = (--it)->toString();
415417
severe() << "replication oplog stream went back in time. "
416418
"previous timestamp: " << lastOptime << " newest timestamp: " << ts
417419
<< ". Op being applied: " << op;
@@ -680,9 +682,9 @@ namespace {
680682
// in the query for idempotence
681683
}
682684
}
683-
else {
685+
else {
684686
// this could happen benignly on an oplog duplicate replay of an upsert
685-
// (because we are idempotent),
687+
// (because we are idempotent),
686688
// if an regular non-mod update fails the item is (presumably) missing.
687689
if( !upsert ) {
688690
failedUpdate = true;

0 commit comments

Comments
 (0)