summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/write_ops_exec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ops/write_ops_exec.cpp')
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp57
1 files changed, 14 insertions, 43 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index 05e78ecfca6..e58146ac5cd 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -96,46 +96,6 @@
#include "mongo/util/scopeguard.h"
namespace mongo::write_ops_exec {
-class Atomic64Metric;
-} // namespace mongo::write_ops_exec
-
-namespace mongo {
-template <>
-struct BSONObjAppendFormat<write_ops_exec::Atomic64Metric> : FormatKind<NumberLong> {};
-} // namespace mongo
-
-
-namespace mongo::write_ops_exec {
-
-/**
- * Atomic wrapper for long long type for Metrics.
- */
-class Atomic64Metric {
-public:
- /** Set _value to the max of the current or newMax. */
- void setIfMax(long long newMax) {
- /* Note: compareAndSwap will load into val most recent value. */
- for (long long val = _value.load(); val < newMax && !_value.compareAndSwap(&val, newMax);) {
- }
- }
-
- /** store val into value. */
- void set(long long val) {
- _value.store(val);
- }
-
- /** Return the current value. */
- long long get() const {
- return _value.load();
- }
-
- operator long long() const {
- return get();
- }
-
-private:
- mongo::AtomicWord<long long> _value;
-};
// Convention in this file: generic helpers go in the anonymous namespace. Helpers that are for a
// single type of operation are static functions defined above their caller.
@@ -214,7 +174,7 @@ void finishCurOp(OperationContext* opCtx, CurOp* curOp) {
try {
curOp->done();
auto executionTimeMicros = duration_cast<Microseconds>(curOp->elapsedTimeExcludingPauses());
- curOp->debug().executionTime = executionTimeMicros;
+ curOp->debug().additiveMetrics.executionTime = executionTimeMicros;
recordCurOpMetrics(opCtx);
Top::get(opCtx->getServiceContext())
@@ -713,7 +673,6 @@ bool getFleCrudProcessed(OperationContext* opCtx,
WriteResult performInserts(OperationContext* opCtx,
const write_ops::InsertCommandRequest& wholeOp,
OperationSource source) {
-
// Insert performs its own retries, so we should only be within a WriteUnitOfWork when run in a
// transaction.
auto txnParticipant = TransactionParticipant::get(opCtx);
@@ -772,11 +731,20 @@ WriteResult performInserts(OperationContext* opCtx,
const size_t maxBatchBytes = write_ops::insertVectorMaxBytes;
batch.reserve(std::min(wholeOp.getDocuments().size(), maxBatchSize));
+ // If 'wholeOp.getBypassEmptyTsReplacement()' is true or if 'source' is 'kFromMigrate', set
+ // "bypassEmptyTsReplacement=true" for fixDocumentForInsert().
+ const bool bypassEmptyTsReplacement = (source == OperationSource::kFromMigrate) ||
+ static_cast<bool>(wholeOp.getBypassEmptyTsReplacement());
+
for (auto&& doc : wholeOp.getDocuments()) {
const bool isLastDoc = (&doc == &wholeOp.getDocuments().back());
bool containsDotsAndDollarsField = false;
- auto fixedDoc = fixDocumentForInsert(opCtx, doc, &containsDotsAndDollarsField);
+
+ auto fixedDoc = fixDocumentForInsert(
+ opCtx, doc, bypassEmptyTsReplacement, &containsDotsAndDollarsField);
+
const StmtId stmtId = getStmtIdForWriteOp(opCtx, wholeOp, stmtIdIndex++);
+
const bool wasAlreadyExecuted = opCtx->isRetryableWrite() &&
txnParticipant.checkStatementExecutedNoOplogEntryFetch(opCtx, stmtId);
@@ -1018,6 +986,7 @@ static SingleWriteResult performSingleUpdateOpWithDupKeyRetry(
const write_ops::UpdateOpEntry& op,
LegacyRuntimeConstants runtimeConstants,
const boost::optional<BSONObj>& letParams,
+ const OptionalBool& bypassEmptyTsReplacement,
OperationSource source,
bool forgoOpCounterIncrements) {
globalOpCounters.gotUpdate();
@@ -1046,6 +1015,7 @@ static SingleWriteResult performSingleUpdateOpWithDupKeyRetry(
if (letParams) {
request.setLetParameters(std::move(letParams));
}
+ request.setBypassEmptyTsReplacement(bypassEmptyTsReplacement);
request.setStmtIds(stmtIds);
request.setYieldPolicy(PlanYieldPolicy::YieldPolicy::YIELD_AUTO);
request.setSource(source);
@@ -1187,6 +1157,7 @@ WriteResult performUpdates(OperationContext* opCtx,
singleOp,
runtimeConstants,
wholeOp.getLet(),
+ wholeOp.getBypassEmptyTsReplacement(),
source,
forgoOpCounterIncrements);
out.results.emplace_back(reply);