mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 00:17:37 +01:00
SERVER-95422: restructured totalOplogSlotDurationMicros calculation (#29229)
GitOrigin-RevId: abff1fd21fa13a3231edc71f8572810384b91540
This commit is contained in:
parent
186e57a23d
commit
82f5da4e8e
@ -913,6 +913,7 @@ mongo_cc_library(
|
||||
"//src/mongo/db/auth:authprivilege", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db/auth:user_acquisition_stats",
|
||||
"//src/mongo/db/catalog:collection_options", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db/catalog:local_oplog_info",
|
||||
"//src/mongo/db/commands:create_command", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db/commands:server_status_core", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db/commands:test_commands_enabled", # TODO(SERVER-93876): Remove.
|
||||
|
@ -86,7 +86,6 @@ mongo_cc_library(
|
||||
],
|
||||
deps = [
|
||||
"//src/mongo/db:server_base", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db:shard_role_api", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db:vector_clock_mutable",
|
||||
"//src/mongo/db/repl:optime",
|
||||
"//src/mongo/db/repl:repl_coordinator_interface", # TODO(SERVER-93876): Remove.
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
|
||||
#include "mongo/db/curop.h"
|
||||
#include "mongo/db/logical_time.h"
|
||||
#include "mongo/db/repl/oplog.h"
|
||||
#include "mongo/db/repl/optime.h"
|
||||
@ -154,7 +153,8 @@ std::vector<OplogSlot> LocalOplogInfo::getNextOpTimes(OperationContext* opCtx, s
|
||||
// If we abort a transaction that has reserved an optime, we should make sure to update the
|
||||
// stable timestamp if necessary, since this oplog hole may have been holding back the stable
|
||||
// timestamp.
|
||||
shard_role_details::getRecoveryUnit(opCtx)->onRollback([replCoord,
|
||||
shard_role_details::getRecoveryUnit(opCtx)->onRollback([this,
|
||||
replCoord,
|
||||
oplogSlotDurationTimer,
|
||||
isFirstOpTime,
|
||||
prevAssertOnLockAttempt,
|
||||
@ -162,8 +162,7 @@ std::vector<OplogSlot> LocalOplogInfo::getNextOpTimes(OperationContext* opCtx, s
|
||||
OperationContext* opCtx) {
|
||||
replCoord->attemptToAdvanceStableTimestamp();
|
||||
// Sum the oplog slot durations. An operation may participate in multiple transactions.
|
||||
CurOp::get(opCtx)->debug().totalOplogSlotDurationMicros +=
|
||||
Microseconds(oplogSlotDurationTimer.elapsed());
|
||||
_totalOplogSlotDurationMicros += Microseconds(oplogSlotDurationTimer.elapsed());
|
||||
|
||||
// Only reset these properties when the first slot is released.
|
||||
if (isFirstOpTime) {
|
||||
@ -172,21 +171,22 @@ std::vector<OplogSlot> LocalOplogInfo::getNextOpTimes(OperationContext* opCtx, s
|
||||
}
|
||||
});
|
||||
|
||||
shard_role_details::getRecoveryUnit(opCtx)->onCommit(
|
||||
[oplogSlotDurationTimer, isFirstOpTime, prevAssertOnLockAttempt, prevRuBlockingAllowed](
|
||||
OperationContext* opCtx, boost::optional<Timestamp>) {
|
||||
// Sum the oplog slot durations. An operation may participate in multiple transactions.
|
||||
CurOp::get(opCtx)->debug().totalOplogSlotDurationMicros +=
|
||||
Microseconds(oplogSlotDurationTimer.elapsed());
|
||||
shard_role_details::getRecoveryUnit(opCtx)->onCommit([this,
|
||||
oplogSlotDurationTimer,
|
||||
isFirstOpTime,
|
||||
prevAssertOnLockAttempt,
|
||||
prevRuBlockingAllowed](
|
||||
OperationContext* opCtx,
|
||||
boost::optional<Timestamp>) {
|
||||
// Sum the oplog slot durations. An operation may participate in multiple transactions.
|
||||
_totalOplogSlotDurationMicros += Microseconds(oplogSlotDurationTimer.elapsed());
|
||||
|
||||
// Only reset these properties when the first slot is released.
|
||||
if (isFirstOpTime) {
|
||||
shard_role_details::getLocker(opCtx)->setAssertOnLockAttempt(
|
||||
prevAssertOnLockAttempt);
|
||||
shard_role_details::getRecoveryUnit(opCtx)->setBlockingAllowed(
|
||||
prevRuBlockingAllowed);
|
||||
}
|
||||
});
|
||||
// Only reset these properties when the first slot is released.
|
||||
if (isFirstOpTime) {
|
||||
shard_role_details::getLocker(opCtx)->setAssertOnLockAttempt(prevAssertOnLockAttempt);
|
||||
shard_role_details::getRecoveryUnit(opCtx)->setBlockingAllowed(prevRuBlockingAllowed);
|
||||
}
|
||||
});
|
||||
|
||||
return oplogSlots;
|
||||
}
|
||||
|
@ -58,6 +58,9 @@ public:
|
||||
RecordStore* getRecordStore() const;
|
||||
void setRecordStore(RecordStore* rs);
|
||||
void resetRecordStore();
|
||||
auto getTotalOplogSlotDurationMicros() const {
|
||||
return _totalOplogSlotDurationMicros;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global Timestamp to be 'newTime'.
|
||||
@ -76,6 +79,12 @@ private:
|
||||
// destroyed. See "oplogCheckCloseDatabase".
|
||||
RecordStore* _rs = nullptr;
|
||||
|
||||
// Stores the total time an operation spends with an uncommitted oplog slot held open. Indicator
|
||||
// that an operation is holding back replication by causing oplog holes to remain open for
|
||||
// unusual amounts of time.
|
||||
Microseconds _totalOplogSlotDurationMicros{0};
|
||||
|
||||
|
||||
// Synchronizes the section where a new Timestamp is generated and when it is registered in the
|
||||
// storage engine.
|
||||
mutable stdx::mutex _newOpMutex;
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "mongo/db/admission/execution_admission_context.h"
|
||||
#include "mongo/db/admission/ingress_admission_context.h"
|
||||
#include "mongo/db/auth/user_name.h"
|
||||
#include "mongo/db/catalog/local_oplog_info.h"
|
||||
#include "mongo/db/client.h"
|
||||
#include "mongo/db/commands.h"
|
||||
#include "mongo/db/commands/server_status_metric.h"
|
||||
@ -1165,7 +1166,9 @@ void OpDebug::report(OperationContext* opCtx,
|
||||
pAttrs->add("placementVersionRefreshDuration", placementVersionRefreshMillis);
|
||||
}
|
||||
|
||||
if (totalOplogSlotDurationMicros > Microseconds::zero()) {
|
||||
if (const auto& totalOplogSlotDurationMicros =
|
||||
LocalOplogInfo::get(opCtx)->getTotalOplogSlotDurationMicros();
|
||||
totalOplogSlotDurationMicros > Microseconds::zero()) {
|
||||
pAttrs->add("totalOplogSlotDuration", totalOplogSlotDurationMicros);
|
||||
}
|
||||
|
||||
@ -1550,7 +1553,9 @@ void OpDebug::append(OperationContext* opCtx,
|
||||
|
||||
OPDEBUG_APPEND_OPTIONAL(b, "estimatedCardinality", estimatedCardinality);
|
||||
|
||||
if (totalOplogSlotDurationMicros > Microseconds::zero()) {
|
||||
if (const auto& totalOplogSlotDurationMicros =
|
||||
LocalOplogInfo::get(opCtx)->getTotalOplogSlotDurationMicros();
|
||||
totalOplogSlotDurationMicros > Microseconds::zero()) {
|
||||
b.appendNumber("totalOplogSlotDurationMicros",
|
||||
durationCount<Microseconds>(totalOplogSlotDurationMicros));
|
||||
}
|
||||
@ -1900,9 +1905,10 @@ std::function<BSONObj(ProfileFilter::Args)> OpDebug::appendStaged(StringSet requ
|
||||
});
|
||||
|
||||
addIfNeeded("totalOplogSlotDurationMicros", [](auto field, auto args, auto& b) {
|
||||
if (args.op.totalOplogSlotDurationMicros > Nanoseconds::zero()) {
|
||||
b.appendNumber(field,
|
||||
durationCount<Microseconds>(args.op.totalOplogSlotDurationMicros));
|
||||
if (const auto& totalOplogSlotDurationMicros =
|
||||
LocalOplogInfo::get(args.opCtx)->getTotalOplogSlotDurationMicros();
|
||||
totalOplogSlotDurationMicros > Nanoseconds::zero()) {
|
||||
b.appendNumber(field, durationCount<Microseconds>(totalOplogSlotDurationMicros));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -506,11 +506,6 @@ public:
|
||||
// Stores the duration of execution after removing time spent blocked.
|
||||
Milliseconds workingTimeMillis{0};
|
||||
|
||||
// Stores the total time an operation spends with an uncommitted oplog slot held open. Indicator
|
||||
// that an operation is holding back replication by causing oplog holes to remain open for
|
||||
// unusual amounts of time.
|
||||
Microseconds totalOplogSlotDurationMicros{0};
|
||||
|
||||
// Stores the amount of the data processed by the throttle cursors in MB/sec.
|
||||
boost::optional<float> dataThroughputLastSecond;
|
||||
boost::optional<float> dataThroughputAverage;
|
||||
|
@ -204,7 +204,6 @@ mongo_cc_library(
|
||||
":flow_control_parameters",
|
||||
"//src/mongo/db:server_base",
|
||||
"//src/mongo/db:service_context", # TODO(SERVER-93876): Remove.
|
||||
"//src/mongo/db:shard_role_api",
|
||||
"//src/mongo/db/commands:server_status_core",
|
||||
"//src/mongo/db/concurrency:flow_control_ticketholder",
|
||||
"//src/mongo/util:background_job",
|
||||
|
Loading…
Reference in New Issue
Block a user