summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/catalog/collection.cpp4
-rw-r--r--src/mongo/db/catalog/collection_compact.cpp39
-rw-r--r--src/mongo/db/catalog/collection_compact.h7
-rw-r--r--src/mongo/db/commands/compact.cpp7
-rw-r--r--src/mongo/db/storage/record_store.h11
5 files changed, 19 insertions, 49 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index 685632a2f8d..0d86d5c1572 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -37,10 +37,6 @@
namespace mongo {
-std::string CompactOptions::toString() const {
- return str::stream() << " validateDocuments: " << validateDocuments;
-}
-
//
// CappedInsertNotifier
//
diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp
index 110e8497bda..fc1cbb9e628 100644
--- a/src/mongo/db/catalog/collection_compact.cpp
+++ b/src/mongo/db/catalog/collection_compact.cpp
@@ -70,9 +70,7 @@ Collection* getCollectionForCompact(OperationContext* opCtx,
} // namespace
-StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
- const NamespaceString& collectionNss,
- const CompactOptions* compactOptions) {
+Status compactCollection(OperationContext* opCtx, const NamespaceString& collectionNss) {
AutoGetDb autoDb(opCtx, collectionNss.db(), MODE_IX);
Database* database = autoDb.getDb();
uassert(ErrorCodes::NamespaceNotFound, "database does not exist", database);
@@ -90,10 +88,9 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
OldClientContext ctx(opCtx, collectionNss.ns());
if (!recordStore->compactSupported())
- return StatusWith<CompactStats>(ErrorCodes::CommandNotSupported,
- str::stream()
- << "cannot compact collection with record store: "
- << recordStore->name());
+ return Status(ErrorCodes::CommandNotSupported,
+ str::stream() << "cannot compact collection with record store: "
+ << recordStore->name());
if (recordStore->supportsOnlineCompaction()) {
// Storage engines that allow online compaction should do so using an intent lock on the
@@ -105,24 +102,22 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
recordStore = collection->getRecordStore();
}
- log(LogComponent::kCommand) << "compact " << collectionNss
- << " begin, options: " << *compactOptions;
+ log(LogComponent::kCommand) << "compact " << collectionNss << " begin";
auto indexCatalog = collection->getIndexCatalog();
if (recordStore->compactsInPlace()) {
- CompactStats stats;
Status status = recordStore->compact(opCtx);
if (!status.isOK())
- return StatusWith<CompactStats>(status);
+ return status;
// Compact all indexes (not including unfinished indexes)
status = indexCatalog->compactIndexes(opCtx);
if (!status.isOK())
- return StatusWith<CompactStats>(status);
+ return status;
log() << "compact " << collectionNss << " end";
- return StatusWith<CompactStats>(stats);
+ return status;
}
invariant(opCtx->lockState()->isCollectionLockedForMode(collectionNss, MODE_X));
@@ -147,9 +142,9 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
const Status keyStatus =
index_key_validate::validateKeyPattern(key, descriptor->version());
if (!keyStatus.isOK()) {
- return StatusWith<CompactStats>(
- ErrorCodes::CannotCreateIndex,
- str::stream() << "Cannot compact collection due to invalid index " << spec
+ return Status(ErrorCodes::CannotCreateIndex,
+ str::stream()
+ << "Cannot compact collection due to invalid index " << spec
<< ": " << keyStatus.reason() << " For more info see"
<< " http://dochub.mongodb.org/core/index-validation");
}
@@ -169,8 +164,6 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
wunit.commit();
}
- CompactStats stats;
-
MultiIndexBlock indexer;
indexer.ignoreUniqueConstraint(); // in compact we should be doing no checking
@@ -180,16 +173,16 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
Status status =
indexer.init(opCtx, collection, indexSpecs, MultiIndexBlock::kNoopOnInitFn).getStatus();
if (!status.isOK())
- return StatusWith<CompactStats>(status);
+ return status;
status = recordStore->compact(opCtx);
if (!status.isOK())
- return StatusWith<CompactStats>(status);
+ return status;
log() << "starting index commits";
status = indexer.dumpInsertsFromBulk(opCtx);
if (!status.isOK())
- return StatusWith<CompactStats>(status);
+ return status;
{
WriteUnitOfWork wunit(opCtx);
@@ -198,13 +191,13 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
MultiIndexBlock::kNoopOnCreateEachFn,
MultiIndexBlock::kNoopOnCommitFn);
if (!status.isOK()) {
- return StatusWith<CompactStats>(status);
+ return status;
}
wunit.commit();
}
log() << "compact " << collectionNss << " end";
- return StatusWith<CompactStats>(stats);
+ return Status::OK();
}
} // namespace mongo
diff --git a/src/mongo/db/catalog/collection_compact.h b/src/mongo/db/catalog/collection_compact.h
index 719ae06c47b..b9d8abb05d0 100644
--- a/src/mongo/db/catalog/collection_compact.h
+++ b/src/mongo/db/catalog/collection_compact.h
@@ -29,17 +29,14 @@
#pragma once
-#include "mongo/base/status_with.h"
+#include "mongo/base/status.h"
#include "mongo/db/storage/record_store.h"
namespace mongo {
/**
* Compacts collection.
- * See record_store.h for CompactStats and CompactOptions definitions.
*/
-StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
- const NamespaceString& collectionNss,
- const CompactOptions* options);
+Status compactCollection(OperationContext* opCtx, const NamespaceString& collectionNss);
} // namespace mongo
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index 64e59324a71..4557baaf1c8 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -105,12 +105,7 @@ public:
return false;
}
- CompactOptions compactOptions;
-
- if (cmdObj.hasElement("validate"))
- compactOptions.validateDocuments = cmdObj["validate"].trueValue();
-
- uassertStatusOK(compactCollection(opCtx, nss, &compactOptions));
+ uassertStatusOK(compactCollection(opCtx, nss));
return true;
}
};
diff --git a/src/mongo/db/storage/record_store.h b/src/mongo/db/storage/record_store.h
index fd7e1ef3b74..e48ca386c22 100644
--- a/src/mongo/db/storage/record_store.h
+++ b/src/mongo/db/storage/record_store.h
@@ -42,8 +42,6 @@ namespace mongo {
class CappedCallback;
class Collection;
-struct CompactOptions;
-struct CompactStats;
class MAdvise;
class OperationContext;
@@ -52,15 +50,6 @@ class RecordStore;
struct ValidateResults;
class ValidateAdaptor;
-struct CompactOptions {
- // other
- bool validateDocuments = true;
-
- std::string toString() const;
-};
-
-struct CompactStats {};
-
/**
* The data items stored in a RecordStore.
*/