summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2020-11-05 17:20:31 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-12 17:54:28 +0000
commitccd024d9fb5c0587e33a3a3321e7f9a0430d0190 (patch)
treee4035ba5b8f90bc300b7645d8d1ae4cf3df3c401 /src/mongo/db
parentc1ad4eab08f4679ca5071d76cfa845a9652881fe (diff)
downloadmongo-ccd024d9fb5c0587e33a3a3321e7f9a0430d0190.tar.gz
SERVER-52562 Enable two-phase drop for standalone mode; allow Lock-Free reads for standalone mode.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/mongod_options.cpp10
-rw-r--r--src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.cpp2
-rw-r--r--src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.h3
-rw-r--r--src/mongo/db/storage/storage_engine_impl.cpp10
-rw-r--r--src/mongo/db/storage/storage_engine_impl.h6
-rw-r--r--src/mongo/db/storage/storage_util.cpp14
6 files changed, 25 insertions, 20 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index c4a364fee1d..04d88cfbf5d 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -505,16 +505,6 @@ Status storeMongodOptions(const moe::Environment& params) {
// storage engines will continue to perform regular capped collection handling for the oplog
// collection, regardless of this parameter setting.
storageGlobalParams.allowOplogTruncation = false;
-
- // Standalone mode does not currently support lock-free reads, so we disable it. If the user
- // tries to explicitly enable it by specifying --disableLockFreeReads=false, log a warning
- // so that the user knows the feature will not run in standalone mode.
- if (!storageGlobalParams.disableLockFreeReads) {
- LOGV2_WARNING(
- 4788400,
- "Lock-free reads is not supported in standalone mode: disabling lock-free reads.");
- storageGlobalParams.disableLockFreeReads = true;
- }
}
if (params.count("replication.enableMajorityReadConcern")) {
diff --git a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.cpp b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.cpp
index e507ad57e06..f7ab3ec27c1 100644
--- a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.cpp
+++ b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.cpp
@@ -94,7 +94,7 @@ void KVDropPendingIdentReaper::dropIdentsOlderThan(OperationContext* opCtx, cons
{
stdx::lock_guard<Latch> lock(_mutex);
for (auto it = _dropPendingIdents.cbegin();
- it != _dropPendingIdents.cend() && it->first < ts;
+ it != _dropPendingIdents.cend() && (it->first < ts || it->first == Timestamp::min());
++it) {
// This collection/index satisfies the 'ts' requirement to be safe to drop, but we must
// also check that there are no active operations remaining that still retain a
diff --git a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.h b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.h
index db9668fa507..320bbfda213 100644
--- a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.h
+++ b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper.h
@@ -98,7 +98,8 @@ public:
/**
* Notifies this class that the storage engine has advanced its oldest timestamp.
- * Drops all unreferenced drop-pending idents with drop timestamps before 'ts'.
+ * Drops all unreferenced drop-pending idents with drop timestamps before 'ts', as well as all
+ * unreferenced idents with Timestamp::min() drop timestamps (untimestamped on standalones).
*/
void dropIdentsOlderThan(OperationContext* opCtx, const Timestamp& ts);
diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp
index 5c9f90bc56f..9a1ea732079 100644
--- a/src/mongo/db/storage/storage_engine_impl.cpp
+++ b/src/mongo/db/storage/storage_engine_impl.cpp
@@ -1048,13 +1048,9 @@ void StorageEngineImpl::checkpoint() {
}
void StorageEngineImpl::_onMinOfCheckpointAndOldestTimestampChanged(const Timestamp& timestamp) {
- if (timestamp.isNull()) {
- return;
- }
-
// No drop-pending idents present if getEarliestDropTimestamp() returns boost::none.
if (auto earliestDropTimestamp = _dropPendingIdentReaper.getEarliestDropTimestamp()) {
- if (timestamp > *earliestDropTimestamp) {
+ if (timestamp >= *earliestDropTimestamp) {
LOGV2(22260,
"Removing drop-pending idents with drop timestamps before timestamp",
"timestamp"_attr = timestamp);
@@ -1145,6 +1141,10 @@ void StorageEngineImpl::TimestampMonitor::startup() {
_currentTimestamps.minOfCheckpointAndOldest !=
minOfCheckpointAndOldest) {
listener->notify(minOfCheckpointAndOldest);
+ } else if (stable == Timestamp::min()) {
+ // Special case notification of all listeners when writes do not have
+ // timestamps. This handles standalone mode.
+ listener->notify(Timestamp::min());
}
}
}
diff --git a/src/mongo/db/storage/storage_engine_impl.h b/src/mongo/db/storage/storage_engine_impl.h
index 9233a6120b3..912f31cef8a 100644
--- a/src/mongo/db/storage/storage_engine_impl.h
+++ b/src/mongo/db/storage/storage_engine_impl.h
@@ -194,6 +194,9 @@ public:
*
* The TimestampListener must be registered in the TimestampMonitor in order to be notified
* of timestamp changes and react to changes for the duration it's part of the monitor.
+ *
+ * Listeners expected to run in standalone mode should handle Timestamp::min() notifications
+ * appropriately.
*/
class TimestampListener {
public:
@@ -255,7 +258,8 @@ public:
~TimestampMonitor();
/**
- * Monitor changes in timestamps and to notify the listeners on change.
+ * Monitor changes in timestamps and to notify the listeners on change. Notifies all
+ * listeners on Timestamp::min() in order to support standalone mode that is untimestamped.
*/
void startup();
diff --git a/src/mongo/db/storage/storage_util.cpp b/src/mongo/db/storage/storage_util.cpp
index 684df92aa9a..1556b3469c4 100644
--- a/src/mongo/db/storage/storage_util.cpp
+++ b/src/mongo/db/storage/storage_util.cpp
@@ -84,7 +84,11 @@ void removeIndex(OperationContext* opCtx,
nss,
indexNameStr = indexName.toString(),
ident](boost::optional<Timestamp> commitTimestamp) {
- if (storageEngine->supportsPendingDrops() && commitTimestamp) {
+ if (storageEngine->supportsPendingDrops()) {
+ if (!commitTimestamp) {
+ // Standalone mode will not provide a timestamp.
+ commitTimestamp = Timestamp::min();
+ }
LOGV2(22206,
"Deferring table drop for index '{index}' on collection "
"'{namespace}{uuid}. Ident: '{ident}', commit timestamp: '{commitTimestamp}'",
@@ -96,6 +100,8 @@ void removeIndex(OperationContext* opCtx,
"commitTimestamp"_attr = commitTimestamp);
storageEngine->addDropPendingIdent(*commitTimestamp, nss, ident);
} else {
+ // Intentionally ignoring failure here. Since we've removed the metadata pointing to
+ // the collection, we should never see it again anyway.
auto kvEngine = storageEngine->getEngine();
kvEngine->dropIdent(recoveryUnit, ident->getIdent()).ignore();
}
@@ -155,7 +161,11 @@ Status dropCollection(OperationContext* opCtx,
}
};
- if (storageEngine->supportsPendingDrops() && commitTimestamp) {
+ if (storageEngine->supportsPendingDrops()) {
+ if (!commitTimestamp) {
+ // Standalone mode will not provide a timestamp.
+ commitTimestamp = Timestamp::min();
+ }
LOGV2(22214,
"Deferring table drop for collection",
logAttrs(nss),