From 332781c598c51e19001e05727679901a94c7fe27 Mon Sep 17 00:00:00 2001 From: David Storch Date: Tue, 7 Jul 2015 16:54:49 -0400 Subject: [PATCH] SERVER-2454 improve error messages for CollectionScan DEAD cases --- src/mongo/base/error_codes.err | 1 + src/mongo/db/exec/collection_scan.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mongo/base/error_codes.err b/src/mongo/base/error_codes.err index e7d60bc8ee9..76f575aef6d 100644 --- a/src/mongo/base/error_codes.err +++ b/src/mongo/base/error_codes.err @@ -135,6 +135,7 @@ error_code("ConfigServersInconsistent", 132) error_code("FailedToSatisfyReadPreference", 133) error_code("XXX_TEMP_NAME_ReadCommittedCurrentlyUnavailable", 134) error_code("StaleTerm", 135) +error_code("CappedPositionLost", 136) # Non-sequential error codes (for compatibility only) error_code("NotMaster", 10107) #this comes from assert_util.h diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp index 22e72d0557a..d5a5d550bea 100644 --- a/src/mongo/db/exec/collection_scan.cpp +++ b/src/mongo/db/exec/collection_scan.cpp @@ -76,7 +76,11 @@ PlanStage::StageState CollectionScan::work(WorkingSetID* out) { ScopedTimer timer(&_commonStats.executionTimeMillis); if (_isDead) { - Status status(ErrorCodes::InternalError, "CollectionScan died"); + Status status( + ErrorCodes::CappedPositionLost, + str::stream() + << "CollectionScan died due to position in capped collection being deleted. " + << "Last seen record id: " << _lastSeenId); *out = WorkingSetCommon::allocateStatusMember(_workingSet, status); return PlanStage::DEAD; } @@ -106,8 +110,10 @@ PlanStage::StageState CollectionScan::work(WorkingSetID* out) { // time we'd need to create a cursor after already getting a record out of it. if (!_cursor->seekExact(_lastSeenId)) { _isDead = true; - Status status(ErrorCodes::InternalError, - "CollectionScan died: Unexpected RecordId"); + Status status(ErrorCodes::CappedPositionLost, + str::stream() << "CollectionScan died due to failure to restore " + << "tailable cursor position. " + << "Last seen record id: " << _lastSeenId); *out = WorkingSetCommon::allocateStatusMember(_workingSet, status); return PlanStage::DEAD; } @@ -222,8 +228,7 @@ void CollectionScan::restoreState(OperationContext* opCtx) { ++_commonStats.unyields; if (_cursor) { if (!_cursor->restore(opCtx)) { - warning() << "Collection dropped or state deleted during yield of CollectionScan: " - << opCtx->getNS(); + warning() << "Could not restore RecordCursor for CollectionScan: " << opCtx->getNS(); _isDead = true; } }