summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/storage_interface_impl.cpp
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2018-02-02 10:27:21 -0500
committerJudah Schvimer <judah@mongodb.com>2018-02-02 10:46:16 -0500
commitb2a7398e663ef090a651a93bedfc6d107a64cf33 (patch)
tree478c4e1c7e5bd5d6ebeb36c2ed50f9ac4a120d41 /src/mongo/db/repl/storage_interface_impl.cpp
parent488709dde37d13d42321b5ad8989331960602b53 (diff)
downloadmongo-b2a7398e663ef090a651a93bedfc6d107a64cf33.tar.gz
SERVER-32206 timestamp catalog change to declare index multikey
Diffstat (limited to 'src/mongo/db/repl/storage_interface_impl.cpp')
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 7657dae752b..0c9f7a399a0 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -499,6 +499,46 @@ Status StorageInterfaceImpl::renameCollection(OperationContext* opCtx,
});
}
+Status StorageInterfaceImpl::setIndexIsMultikey(OperationContext* opCtx,
+ const NamespaceString& nss,
+ const std::string& indexName,
+ const MultikeyPaths& paths,
+ Timestamp ts) {
+ if (ts.isNull()) {
+ return Status(ErrorCodes::InvalidOptions,
+ str::stream() << "Cannot set index " << indexName << " on " << nss.ns()
+ << " as multikey at null timestamp");
+ }
+
+ return writeConflictRetry(opCtx, "StorageInterfaceImpl::setIndexIsMultikey", nss.ns(), [&] {
+ AutoGetCollection autoColl(opCtx, nss, MODE_X);
+ auto collectionResult = getCollection(
+ autoColl, nss, "The collection must exist before setting an index to multikey.");
+ if (!collectionResult.isOK()) {
+ return collectionResult.getStatus();
+ }
+ auto collection = collectionResult.getValue();
+
+ WriteUnitOfWork wunit(opCtx);
+ auto tsResult = opCtx->recoveryUnit()->setTimestamp(ts);
+ if (!tsResult.isOK()) {
+ return tsResult;
+ }
+
+ auto idx = collection->getIndexCatalog()->findIndexByName(
+ opCtx, indexName, true /* includeUnfinishedIndexes */);
+ if (!idx) {
+ return Status(ErrorCodes::IndexNotFound,
+ str::stream() << "Could not find index " << indexName << " in "
+ << nss.ns()
+ << " to set to multikey.");
+ }
+ collection->getIndexCatalog()->getIndex(idx)->setIndexIsMultikey(opCtx, paths);
+ wunit.commit();
+ return Status::OK();
+ });
+}
+
namespace {
/**