diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-01-14 16:45:39 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2015-01-15 18:08:36 -0500 |
commit | 59fec904c441998dc6381b8e26bd4b90d8718a3e (patch) | |
tree | ac9d21d5937844422c9cd3afc2f858bff42c01ba /src/mongo/db/catalog/collection_compact.cpp | |
parent | d1910c70e2e3eb6ce057a474dece00b737645631 (diff) | |
download | mongo-59fec904c441998dc6381b8e26bd4b90d8718a3e.tar.gz |
SERVER-16676 don't trash indexes for RecordStores that can compact in-place
Diffstat (limited to 'src/mongo/db/catalog/collection_compact.cpp')
-rw-r--r-- | src/mongo/db/catalog/collection_compact.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp index 352868694f9..264716ba889 100644 --- a/src/mongo/db/catalog/collection_compact.cpp +++ b/src/mongo/db/catalog/collection_compact.cpp @@ -106,11 +106,22 @@ namespace mongo { dassert(txn->lockState()->isCollectionLockedForMode(ns().toString(), MODE_X)); if ( !_recordStore->compactSupported() ) - return StatusWith<CompactStats>( ErrorCodes::BadValue, + return StatusWith<CompactStats>( ErrorCodes::CommandNotSupported, str::stream() << "cannot compact collection with record store: " << _recordStore->name() ); + if (_recordStore->compactsInPlace()) { + // Since we are compacting in-place, we don't need to touch the indexes. + // TODO SERVER-16856 compact indexes + CompactStats stats; + Status status = _recordStore->compact(txn, NULL, compactOptions, &stats); + if (!status.isOK()) + return StatusWith<CompactStats>(status); + + return StatusWith<CompactStats>(stats); + } + if ( _indexCatalog.numIndexesInProgress( txn ) ) return StatusWith<CompactStats>( ErrorCodes::BadValue, "cannot compact when indexes in progress" ); @@ -166,7 +177,9 @@ namespace mongo { MyCompactAdaptor adaptor(this, &indexer); - _recordStore->compact( txn, &adaptor, compactOptions, &stats ); + status = _recordStore->compact( txn, &adaptor, compactOptions, &stats); + if (!status.isOK()) + return StatusWith<CompactStats>(status); log() << "starting index commits"; status = indexer.doneInserting(); |