summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2019-03-18 13:06:30 -0400
committerDianna Hohensee <dianna.hohensee@10gen.com>2019-03-27 14:36:40 -0400
commit4b859c936a6ba27506d11a2879b75b4bf6bfa876 (patch)
treeab53d6c922c59014007225570ed36bb0b069bad2
parent79be33d4f24e8a38a42546b4f4e61885a8a3ce6d (diff)
downloadmongo-4b859c936a6ba27506d11a2879b75b4bf6bfa876.tar.gz
SERVER-40024 Only allow collection/index minimum visible snapshots to be moved forward in time
(cherry picked from commit 751ac6e4692ebe5a5026d96596ca4cffd40f8ffa)
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp6
-rw-r--r--src/mongo/db/catalog/collection_impl.h8
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.cpp6
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.h8
4 files changed, 22 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index c33b0748b9c..6a84b0716a5 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -550,6 +550,12 @@ Status CollectionImpl::_insertDocuments(OperationContext* opCtx,
return status;
}
+void CollectionImpl::setMinimumVisibleSnapshot(Timestamp newMinimumVisibleSnapshot) {
+ if (!_minVisibleSnapshot || (newMinimumVisibleSnapshot > _minVisibleSnapshot.get())) {
+ _minVisibleSnapshot = newMinimumVisibleSnapshot;
+ }
+}
+
bool CollectionImpl::haveCappedWaiters() {
// Waiters keep a shared_ptr to '_cappedNotifier', so there are waiters if this CollectionImpl's
// shared_ptr is not unique (use_count > 1).
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index 92d226ce81a..aedcfcc0c64 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -356,9 +356,11 @@ public:
return _minVisibleSnapshot;
}
- void setMinimumVisibleSnapshot(Timestamp name) final {
- _minVisibleSnapshot = name;
- }
+ /**
+ * Updates the minimum visible snapshot. The 'newMinimumVisibleSnapshot' is ignored if it would
+ * set the minimum visible snapshot backwards in time.
+ */
+ void setMinimumVisibleSnapshot(Timestamp newMinimumVisibleSnapshot) final;
bool haveCappedWaiters() final;
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
index cbb0fb6356d..e8cfc4fb970 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
@@ -228,6 +228,12 @@ MultikeyPaths IndexCatalogEntryImpl::getMultikeyPaths(OperationContext* opCtx) c
// ---
+void IndexCatalogEntryImpl::setMinimumVisibleSnapshot(Timestamp newMinimumVisibleSnapshot) {
+ if (!_minVisibleSnapshot || (newMinimumVisibleSnapshot > _minVisibleSnapshot.get())) {
+ _minVisibleSnapshot = newMinimumVisibleSnapshot;
+ }
+}
+
void IndexCatalogEntryImpl::setIsReady(bool newIsReady) {
_isReady = newIsReady;
}
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.h b/src/mongo/db/catalog/index_catalog_entry_impl.h
index dfda831ac62..b95ca5b7eb6 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.h
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.h
@@ -163,9 +163,11 @@ public:
return _minVisibleSnapshot;
}
- void setMinimumVisibleSnapshot(Timestamp name) final {
- _minVisibleSnapshot = name;
- }
+ /**
+ * Updates the minimum visible snapshot. The 'newMinimumVisibleSnapshot' is ignored if it would
+ * set the minimum visible snapshot backwards in time.
+ */
+ void setMinimumVisibleSnapshot(Timestamp newMinimumVisibleSnapshot) final;
private:
class SetMultikeyChange;