summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2021-06-17 11:03:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-17 11:27:24 +0000
commit817ffc748a45197542553b18549a35b4c2e9a2f2 (patch)
tree060764db7d5423bf294300b66369ec98e998304b
parentbf7e84984e992b7c994ba090d89fcd528973ff60 (diff)
downloadmongo-817ffc748a45197542553b18549a35b4c2e9a2f2.tar.gz
Revert "SERVER-57217 Don't report remainingOperationTimeEstimatedSecs in currentOp metrics for resharding for donors and coordinators"
This reverts commit e8f96019646425bc352f09b62d8e86b0e41f5d5b.
-rw-r--r--jstests/sharding/resharding_metrics.js2
-rw-r--r--src/mongo/db/s/resharding/resharding_metrics.cpp16
-rw-r--r--src/mongo/db/s/resharding/resharding_metrics_test.cpp13
3 files changed, 22 insertions, 9 deletions
diff --git a/jstests/sharding/resharding_metrics.js b/jstests/sharding/resharding_metrics.js
index e141e68df10..f051634ef7c 100644
--- a/jstests/sharding/resharding_metrics.js
+++ b/jstests/sharding/resharding_metrics.js
@@ -101,6 +101,7 @@ function verifyCurrentOpOutput(reshardingTest, inputCollection) {
"ns": kNamespace,
"originatingCommand": undefined,
"totalOperationTimeElapsedSecs": undefined,
+ "remainingOperationTimeEstimatedSecs": undefined,
"countWritesDuringCriticalSection": 0,
"totalCriticalSectionTimeElapsedSecs": undefined,
"donorState": undefined,
@@ -135,6 +136,7 @@ function verifyCurrentOpOutput(reshardingTest, inputCollection) {
"ns": kNamespace,
"originatingCommand": undefined,
"totalOperationTimeElapsedSecs": undefined,
+ "remainingOperationTimeEstimatedSecs": undefined,
"coordinatorState": undefined,
"opStatus": "running",
});
diff --git a/src/mongo/db/s/resharding/resharding_metrics.cpp b/src/mongo/db/s/resharding/resharding_metrics.cpp
index 483f0f2b04d..71c8542268d 100644
--- a/src/mongo/db/s/resharding/resharding_metrics.cpp
+++ b/src/mongo/db/s/resharding/resharding_metrics.cpp
@@ -85,16 +85,19 @@ Milliseconds remainingTime(Milliseconds elapsedTime, double elapsedWork, double
return Milliseconds(Milliseconds::rep(remainingMsec));
}
+// TODO SERVER-57217 Remove special-casing for the non-existence of the boost::optional.
static StringData serializeState(boost::optional<RecipientStateEnum> e) {
- return RecipientState_serializer(*e);
+ return RecipientState_serializer(e ? *e : RecipientStateEnum::kUnused);
}
+// TODO SERVER-57217 Remove special-casing for the non-existence of the boost::optional.
static StringData serializeState(boost::optional<DonorStateEnum> e) {
- return DonorState_serializer(*e);
+ return DonorState_serializer(e ? *e : DonorStateEnum::kUnused);
}
+// TODO SERVER-57217 Remove special-casing for the non-existence of the boost::optional.
static StringData serializeState(boost::optional<CoordinatorStateEnum> e) {
- return CoordinatorState_serializer(*e);
+ return CoordinatorState_serializer(e ? *e : CoordinatorStateEnum::kUnused);
}
// Allows tracking elapsed time for the resharding operation and its sub operations (e.g.,
@@ -189,6 +192,10 @@ void ReshardingMetrics::OperationMetrics::appendCurrentOpMetrics(BSONObjBuilder*
bob->append(kOpTimeElapsed, getElapsedTime(runningOperation));
+ bob->append(kOpTimeRemaining,
+ !remainingMsec ? int64_t{-1} /** -1 is a specified integer null value */
+ : durationCount<Seconds>(*remainingMsec));
+
switch (role) {
case Role::kDonor:
bob->append(kWritesDuringCritialSection, writesDuringCriticalSection);
@@ -197,9 +204,6 @@ void ReshardingMetrics::OperationMetrics::appendCurrentOpMetrics(BSONObjBuilder*
bob->append(kOpStatus, ReshardingOperationStatus_serializer(opStatus));
break;
case Role::kRecipient:
- bob->append(kOpTimeRemaining,
- !remainingMsec ? int64_t{-1} /** -1 is a specified integer null value */
- : durationCount<Seconds>(*remainingMsec));
bob->append(kDocumentsToCopy, documentsToCopy);
bob->append(kDocumentsCopied, documentsCopied);
bob->append(kBytesToCopy, bytesToCopy);
diff --git a/src/mongo/db/s/resharding/resharding_metrics_test.cpp b/src/mongo/db/s/resharding/resharding_metrics_test.cpp
index 4b6c7a1fcde..c90ec1e4c9d 100644
--- a/src/mongo/db/s/resharding/resharding_metrics_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_metrics_test.cpp
@@ -283,6 +283,11 @@ TEST_F(ReshardingMetricsTest, TestDonorAndRecipientMetrics) {
checkMetrics(
currentDonorOpReport, "countWritesDuringCriticalSection", kWritesDuringCriticalSection);
+ // Expected remaining time = totalCopyTimeElapsedSecs + 2 * estimated time to copy remaining
+ checkMetrics(currentDonorOpReport,
+ "remainingOperationTimeEstimatedSecs",
+ elapsedTime + 2 * (100 - kCopyProgress) / kCopyProgress * elapsedTime);
+
const auto cumulativeReportAfterCompletion = getReport(OpReportType::CumulativeReport);
checkMetrics(
cumulativeReportAfterCompletion, "bytesCopied", kBytesToCopy * kCopyProgress / 100);
@@ -402,7 +407,7 @@ TEST_F(ReshardingMetricsTest, EstimatedRemainingOperationTime) {
const auto elapsedTime = 1;
startOperation(ReshardingMetrics::Role::kRecipient);
- checkMetrics(kTag, -1, OpReportType::CurrentOpReportRecipientRole);
+ checkMetrics(kTag, -1, OpReportType::CurrentOpReportDonorRole);
const auto kDocumentsToCopy = 2;
const auto kBytesToCopy = 200;
@@ -414,7 +419,7 @@ TEST_F(ReshardingMetricsTest, EstimatedRemainingOperationTime) {
advanceTime(Seconds(elapsedTime));
// Since 50% of the data is copied, the remaining copy time equals the elapsed copy time, which
// is equal to `elapsedTime` seconds.
- checkMetrics(kTag, elapsedTime + 2 * elapsedTime, OpReportType::CurrentOpReportRecipientRole);
+ checkMetrics(kTag, elapsedTime + 2 * elapsedTime, OpReportType::CurrentOpReportDonorRole);
const auto kOplogEntriesFetched = 4;
const auto kOplogEntriesApplied = 2;
@@ -427,7 +432,7 @@ TEST_F(ReshardingMetricsTest, EstimatedRemainingOperationTime) {
// So far, the time to apply oplog entries equals `elapsedTime` seconds.
checkMetrics(kTag,
elapsedTime * (kOplogEntriesFetched / kOplogEntriesApplied - 1),
- OpReportType::CurrentOpReportRecipientRole);
+ OpReportType::CurrentOpReportDonorRole);
}
TEST_F(ReshardingMetricsTest, CurrentOpReportForDonor) {
@@ -455,6 +460,7 @@ TEST_F(ReshardingMetricsTest, CurrentOpReportForDonor) {
"unique: {3},"
"collation: {{ locale: \"simple\" }} }},"
"totalOperationTimeElapsedSecs: 5,"
+ "remainingOperationTimeEstimatedSecs: -1,"
"countWritesDuringCriticalSection: 0,"
"totalCriticalSectionTimeElapsedSecs : 3,"
"donorState: \"{4}\","
@@ -567,6 +573,7 @@ TEST_F(ReshardingMetricsTest, CurrentOpReportForCoordinator) {
"unique: {3},"
"collation: {{ locale: \"simple\" }} }},"
"totalOperationTimeElapsedSecs: {4},"
+ "remainingOperationTimeEstimatedSecs: -1,"
"coordinatorState: \"{5}\","
"opStatus: \"running\" }}",
options.id.toString(),