diff options
author | Geert Bosch <geert@mongodb.com> | 2018-04-27 14:05:31 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2018-05-08 17:40:27 -0400 |
commit | 2f523f843dbfa351d5ef6867017d14478d7a0d6d (patch) | |
tree | e3c5f9255c7fdf97dfc76dbc0634ae2979daace4 | |
parent | 5cd9fda822a6a813b4e0c5eb0003f222d86c1f35 (diff) | |
download | mongo-2f523f843dbfa351d5ef6867017d14478d7a0d6d.tar.gz |
SERVER-34423 Avoid reloading UUID on collMod rollback
(cherry picked from commit bf76453a0dcb0e4309f5b249cfe30cffe101b1b4)
Conflicts:
src/mongo/db/storage/write_unit_of_work.cpp
src/mongo/db/storage/write_unit_of_work.h
-rw-r--r-- | src/mongo/db/catalog/coll_mod.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/catalog/collection_impl.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/catalog/collection_impl.h | 5 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 012413a9d71..81d3ebc9be1 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -448,7 +448,6 @@ Status _collModInternal(OperationContext* opCtx, << nss.ns()); } coll->refreshUUID(opCtx); - opCtx->recoveryUnit()->onRollback([coll, opCtx]() { coll->refreshUUID(opCtx); }); } // Only observe non-view collMods, as view operations are observed as operations on the diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp index 6d86145afc8..687291c3ce0 100644 --- a/src/mongo/db/catalog/collection_impl.cpp +++ b/src/mongo/db/catalog/collection_impl.cpp @@ -199,6 +199,15 @@ CollectionImpl::~CollectionImpl() { _magic = 0; } +void CollectionImpl::refreshUUID(OperationContext* opCtx) { + auto options = getCatalogEntry()->getCollectionOptions(opCtx); + // refreshUUID may be called from outside a WriteUnitOfWork. In such cases, there is no + // change to any on disk data, so no rollback handler is needed. + if (opCtx->lockState()->inAWriteUnitOfWork()) + opCtx->recoveryUnit()->onRollback([ this, oldUUID = _uuid ] { this->_uuid = oldUUID; }); + _uuid = options.uuid; +} + bool CollectionImpl::requiresIdIndex() const { if (_ns.isVirtualized() || _ns.isOplog()) { // No indexes on virtual collections or the oplog. diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h index ea74bbf6419..28ec6d7a6c8 100644 --- a/src/mongo/db/catalog/collection_impl.h +++ b/src/mongo/db/catalog/collection_impl.h @@ -84,10 +84,7 @@ public: return _uuid; } - void refreshUUID(OperationContext* opCtx) final { - auto options = getCatalogEntry()->getCollectionOptions(opCtx); - _uuid = options.uuid; - } + void refreshUUID(OperationContext* opCtx) final; const IndexCatalog* getIndexCatalog() const final { return &_indexCatalog; |