diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-11-09 10:39:05 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-09 21:40:55 +0000 |
commit | 54364b43839b4b181ed41fb98205f3d7d5831923 (patch) | |
tree | aae85a270a5fc3fe292b958adb08c862fa9558ac | |
parent | 02a35aec01bbc093eb9d6b500174f850869bb582 (diff) | |
download | mongo-54364b43839b4b181ed41fb98205f3d7d5831923.tar.gz |
SERVER-52698 Protect ViewCatalog with mutex also in rollback handlers
-rw-r--r-- | src/mongo/db/views/view_catalog.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/views/view_catalog.cpp b/src/mongo/db/views/view_catalog.cpp index 5fd9116f931..98931116973 100644 --- a/src/mongo/db/views/view_catalog.cpp +++ b/src/mongo/db/views/view_catalog.cpp @@ -226,8 +226,12 @@ Status ViewCatalog::_createOrUpdateView(WithLock lk, catalog.addResource(viewRid, viewName.ns()); opCtx->recoveryUnit()->onRollback([this, viewName, opCtx, viewRid]() { - this->_viewMap.erase(viewName.ns()); - this->_viewGraphNeedsRefresh = true; + { + stdx::lock_guard<Latch> lk(_mutex); + this->_viewMap.erase(viewName.ns()); + this->_viewGraphNeedsRefresh = true; + } + CollectionCatalog& catalog = CollectionCatalog::get(opCtx); catalog.removeResource(viewRid, viewName.ns()); }); @@ -452,7 +456,11 @@ Status ViewCatalog::modifyView(OperationContext* opCtx, ViewDefinition savedDefinition = *viewPtr; opCtx->recoveryUnit()->onRollback([this, viewName, savedDefinition, opCtx]() { - this->_viewMap[viewName.ns()] = std::make_shared<ViewDefinition>(savedDefinition); + auto definition = std::make_shared<ViewDefinition>(savedDefinition); + { + stdx::lock_guard<Latch> lk(_mutex); + this->_viewMap[viewName.ns()] = std::move(definition); + } auto viewRid = ResourceId(RESOURCE_COLLECTION, viewName.ns()); CollectionCatalog& catalog = CollectionCatalog::get(opCtx); catalog.addResource(viewRid, viewName.ns()); |