summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2020-01-30 14:27:25 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-30 19:38:39 +0000
commitab01304d9c3e2b635f43a88920eef629be26c56e (patch)
tree1e4c9a0ad1bf872216d41bcb352e4fb89d5aa0b7 /src/mongo
parente6468fe7daf0da3cd82521202ca32d6781242250 (diff)
downloadmongo-ab01304d9c3e2b635f43a88920eef629be26c56e.tar.gz
SERVER-45525 ReplBatcher should explicitly read at kNoTimestamp
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/oplog_batcher.cpp9
-rw-r--r--src/mongo/db/repl/oplog_batcher.h2
3 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index ca73084c4e0..74e6d088279 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -520,6 +520,7 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/auth/authorization_manager_global',
+ '$BUILD_DIR/mongo/db/db_raii',
'$BUILD_DIR/mongo/db/namespace_string',
'$BUILD_DIR/mongo/executor/task_executor_interface',
'$BUILD_DIR/mongo/util/concurrency/thread_pool',
diff --git a/src/mongo/db/repl/oplog_batcher.cpp b/src/mongo/db/repl/oplog_batcher.cpp
index da2f7bf049f..80f0ffbbec6 100644
--- a/src/mongo/db/repl/oplog_batcher.cpp
+++ b/src/mongo/db/repl/oplog_batcher.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/repl/oplog_batcher.h"
+#include "mongo/db/catalog_raii.h"
#include "mongo/db/commands/txn_cmds_gen.h"
#include "mongo/db/repl/oplog_applier.h"
#include "mongo/db/repl/repl_server_parameters_gen.h"
@@ -341,6 +342,14 @@ std::size_t getBatchLimitOplogEntries() {
}
std::size_t getBatchLimitOplogBytes(OperationContext* opCtx, StorageInterface* storageInterface) {
+ // We can't change the timestamp source within a write unit of work.
+ invariant(!opCtx->lockState()->inAWriteUnitOfWork());
+ // We're only reading oplog metadata, so the timestamp is not important. If we read with the
+ // default (which is kLastApplied on secondaries), we may end up with a reader that is at
+ // kLastApplied. If we then roll back, then when we reconstruct prepared transactions during
+ // rollback recovery we will be preparing transactions before the read timestamp, which triggers
+ // an assertion in WiredTiger.
+ ReadSourceScope readSourceScope(opCtx, RecoveryUnit::ReadSource::kNoTimestamp);
auto oplogMaxSizeResult =
storageInterface->getOplogMaxSize(opCtx, NamespaceString::kRsOplogNamespace);
auto oplogMaxSize = fassert(40301, oplogMaxSizeResult);
diff --git a/src/mongo/db/repl/oplog_batcher.h b/src/mongo/db/repl/oplog_batcher.h
index f68808294ea..973977fc0c9 100644
--- a/src/mongo/db/repl/oplog_batcher.h
+++ b/src/mongo/db/repl/oplog_batcher.h
@@ -209,7 +209,7 @@ std::size_t getBatchLimitOplogEntries();
/**
* Calculates batch limit size (in bytes) using the maximum capped collection size of the oplog
- * size.
+ * size. Must not be called from within a WriteUnitOfWork.
* Batches are limited to 10% of the oplog.
*/
std::size_t getBatchLimitOplogBytes(OperationContext* opCtx, StorageInterface* storageInterface);