summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-01-01 05:57:23 -0500
committerBenety Goh <benety@mongodb.com>2019-01-01 05:57:23 -0500
commit671f529e1f0a3f6b5701d6ada2331099e7e72f4a (patch)
tree23e7d4707d60c13d7c7a10e37cf632d94a22e63f /src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp
parent46dd8e03cdef50a4d3b5714619d7a097c9a1578f (diff)
downloadmongo-671f529e1f0a3f6b5701d6ada2331099e7e72f4a.tar.gz
SERVER-38548 dropping an index removes catalog entry immediately and defers ident drop
If drop-pending idents are supported by the storage engine, catalog::openCatalog() will not need to rebuild the indexes on rollback/recovery. Instead, the storage engine will manage the removal of the idents from disk.
Diffstat (limited to 'src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp')
-rw-r--r--src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp b/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp
index 22b20d39099..7e8f17445a0 100644
--- a/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp
+++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp
@@ -30,16 +30,21 @@
* it in the license file.
*/
-#include <memory>
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
+
+#include "mongo/platform/basic.h"
#include "mongo/db/storage/kv/kv_collection_catalog_entry.h"
+#include <memory>
+
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/storage/kv/kv_catalog.h"
#include "mongo/db/storage/kv/kv_catalog_feature_tracker.h"
#include "mongo/db/storage/kv/kv_engine.h"
#include "mongo/db/storage/kv/kv_storage_engine.h"
+#include "mongo/util/log.h"
namespace mongo {
@@ -84,11 +89,20 @@ public:
_ident(ident.toString()) {}
virtual void rollback() {}
- virtual void commit(boost::optional<Timestamp>) {
+ virtual void commit(boost::optional<Timestamp> commitTimestamp) {
// Intentionally ignoring failure here. Since we've removed the metadata pointing to the
// index, we should never see it again anyway.
+ // TODO(SERVER-38800): Remove special case for _id index. The rollback process is unable to
+ // fix collection counts and currently relies on catalog::openCatalog() to update the
+ // collection count as it rebuilds missing indexes. Removing the ident for the _id index
+ // immediately ensures that we have at least one index to rebuild coming out of rollback.
auto engine = _cce->_engine;
- {
+ auto storageEngine = engine->getStorageEngine();
+ if (storageEngine->supportsPendingDrops() && commitTimestamp && _indexName != "_id_") {
+ log() << "Deferring ident drop for " << _ident << " (" << _indexNss
+ << ") with commit timestamp: " << commitTimestamp->toBSON();
+ engine->addDropPendingIdent(*commitTimestamp, _indexNss, _ident);
+ } else {
auto kvEngine = engine->getEngine();
MONGO_COMPILER_VARIABLE_UNUSED auto status = kvEngine->dropIdent(_opCtx, _ident);
}