summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/collection_compact.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-01-14 16:45:39 -0500
committerMathias Stearn <mathias@10gen.com>2015-01-15 18:08:36 -0500
commit59fec904c441998dc6381b8e26bd4b90d8718a3e (patch)
treeac9d21d5937844422c9cd3afc2f858bff42c01ba /src/mongo/db/catalog/collection_compact.cpp
parentd1910c70e2e3eb6ce057a474dece00b737645631 (diff)
downloadmongo-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.cpp17
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();