diff options
author | Mathias Stearn <mathias@10gen.com> | 2014-08-18 16:32:08 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2014-10-27 13:07:20 -0400 |
commit | 9c6ec970c5e7c7c8058008d30951430d149b3968 (patch) | |
tree | 315b0eb49d8e92ac180308e81804ee52f4c8563c /src/mongo/db | |
parent | ca29cc4f4f9b7de04dc507c0428da898cbd1c9cd (diff) | |
download | mongo-9c6ec970c5e7c7c8058008d30951430d149b3968.tar.gz |
SERVER-13951 Changes that depend on rollback
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/catalog/collection.cpp | 30 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog.cpp | 61 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_catalog.h | 8 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_access_method.cpp | 14 |
4 files changed, 12 insertions, 101 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp index d78ddc0664c..3dbb2ad5a98 100644 --- a/src/mongo/db/catalog/collection.cpp +++ b/src/mongo/db/catalog/collection.cpp @@ -191,13 +191,6 @@ namespace mongo { } } - if ( isCapped() ) { - // TOOD: old god not done - Status ret = _indexCatalog.checkNoIndexConflicts( txn, docToInsert ); - if ( !ret.isOK() ) - return StatusWith<DiskLoc>( ret ); - } - return _insertDocument( txn, docToInsert, enforceQuota ); } @@ -241,22 +234,9 @@ namespace mongo { _infoCache.notifyOfWriteOp(); - try { - _indexCatalog.indexRecord(txn, docToInsert, loc.getValue()); - } - catch ( AssertionException& e ) { - if ( isCapped() ) { - return StatusWith<DiskLoc>( ErrorCodes::InternalError, - str::stream() << "unexpected index insertion failure on" - << " capped collection" << e.toString() - << " - collection and its index will not match" ); - } - - // indexRecord takes care of rolling back indexes - // so we just have to delete the main storage - _recordStore->deleteRecord( txn, loc.getValue() ); - return StatusWith<DiskLoc>( e.toStatus( "insertDocument" ) ); - } + Status s = _indexCatalog.indexRecord(txn, docToInsert, loc.getValue()); + if (!s.isOK()) + return StatusWith<DiskLoc>(s); return loc; } @@ -368,7 +348,9 @@ namespace mongo { debug->nmoved += 1; } - _indexCatalog.indexRecord(txn, objNew, newLocation.getValue()); + Status s = _indexCatalog.indexRecord(txn, objNew, newLocation.getValue()); + if (!s.isOK()) + return StatusWith<DiskLoc>(s); return newLocation; } diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 9fe6288a8ea..8c9ad091af3 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -1015,44 +1015,19 @@ namespace { } - void IndexCatalog::indexRecord(OperationContext* txn, + Status IndexCatalog::indexRecord(OperationContext* txn, const BSONObj& obj, const DiskLoc &loc ) { for ( IndexCatalogEntryContainer::const_iterator i = _entries.begin(); i != _entries.end(); ++i ) { - - IndexCatalogEntry* entry = *i; - - try { - Status s = _indexRecord( txn, entry, obj, loc ); - uassertStatusOK( s ); - } - catch ( AssertionException& ae ) { - LOG(2) << "IndexCatalog::indexRecord failed: " << ae; - - for ( IndexCatalogEntryContainer::const_iterator j = _entries.begin(); - j != _entries.end(); - ++j ) { - - IndexCatalogEntry* toDelete = *j; - - try { - _unindexRecord(txn, toDelete, obj, loc, false); - } - catch ( DBException& e ) { - LOG(1) << "IndexCatalog::indexRecord rollback failed: " << e; - } - - if ( toDelete == entry ) - break; - } - - throw; - } + Status s = _indexRecord(txn, *i, obj, loc); + if (!s.isOK()) + return s; } + return Status::OK(); } void IndexCatalog::unindexRecord(OperationContext* txn, @@ -1072,32 +1047,6 @@ namespace { } } - Status IndexCatalog::checkNoIndexConflicts( OperationContext* txn, const BSONObj &obj ) { - IndexIterator ii = getIndexIterator( txn, true ); - while ( ii.more() ) { - IndexDescriptor* descriptor = ii.next(); - - if ( !descriptor->unique() ) - continue; - - if (repl::getGlobalReplicationCoordinator()->shouldIgnoreUniqueIndex(descriptor)) - continue; - - IndexAccessMethod* iam = getIndex( descriptor ); - - InsertDeleteOptions options; - options.logIfError = false; - options.dupsAllowed = false; - - UpdateTicket ticket; - Status ret = iam->validateUpdate(txn, BSONObj(), obj, DiskLoc(), options, &ticket); - if ( !ret.isOK() ) - return ret; - } - - return Status::OK(); - } - BSONObj IndexCatalog::fixIndexKey( const BSONObj& key ) { if ( IndexDescriptor::isIdIndexPattern( key ) ) { return _idObj; diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h index 50ba248e6aa..00c8d883ab5 100644 --- a/src/mongo/db/catalog/index_catalog.h +++ b/src/mongo/db/catalog/index_catalog.h @@ -253,19 +253,13 @@ namespace mongo { // ----- data modifiers ------ // this throws for now - void indexRecord(OperationContext* txn, const BSONObj& obj, const DiskLoc &loc); + Status indexRecord(OperationContext* txn, const BSONObj& obj, const DiskLoc &loc); void unindexRecord(OperationContext* txn, const BSONObj& obj, const DiskLoc& loc, bool noWarn); - /** - * checks all unique indexes and checks for conflicts - * should not throw - */ - Status checkNoIndexConflicts( OperationContext* txn, const BSONObj& obj ); - // ------- temp internal ------- std::string getAccessMethodName(OperationContext* txn, const BSONObj& keyPattern) { diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp index a92a0484b91..f8e8ffdd2ed 100644 --- a/src/mongo/db/index/btree_based_access_method.cpp +++ b/src/mongo/db/index/btree_based_access_method.cpp @@ -255,20 +255,6 @@ namespace mongo { setDifference(data->oldKeys, data->newKeys, &data->removed); setDifference(data->newKeys, data->oldKeys, &data->added); - bool checkForDups = !data->added.empty() - && (KeyPattern::isIdKeyPattern(_descriptor->keyPattern()) || _descriptor->unique()) - && !options.dupsAllowed; - - if (checkForDups) { - for (vector<BSONObj*>::iterator i = data->added.begin(); i != data->added.end(); i++) { - Status check = _newInterface->dupKeyCheck(txn, **i, record); - if (!check.isOK()) { - status->_isValid = false; - return check; - } - } - } - status->_isValid = true; return Status::OK(); |