summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunhson Jean-Baptiste <junhson.jean-baptiste@mongodb.com>2021-06-10 18:12:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-16 20:50:26 +0000
commite8f96019646425bc352f09b62d8e86b0e41f5d5b (patch)
tree743bab79b109f7fb31607ea6f855fd24ede3b865
parent236c58b92cf8738c3e950aa99c75c8cb57e7d18f (diff)
downloadmongo-e8f96019646425bc352f09b62d8e86b0e41f5d5b.tar.gz
SERVER-57217 Don't report remainingOperationTimeEstimatedSecs in currentOp metrics for resharding for donors and coordinators
-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, 9 insertions, 22 deletions
diff --git a/jstests/sharding/resharding_metrics.js b/jstests/sharding/resharding_metrics.js
index f051634ef7c..e141e68df10 100644
--- a/jstests/sharding/resharding_metrics.js
+++ b/jstests/sharding/resharding_metrics.js
@@ -101,7 +101,6 @@ function verifyCurrentOpOutput(reshardingTest, inputCollection) {
"ns": kNamespace,
"originatingCommand": undefined,
"totalOperationTimeElapsedSecs": undefined,
- "remainingOperationTimeEstimatedSecs": undefined,
"countWritesDuringCriticalSection": 0,
"totalCriticalSectionTimeElapsedSecs": undefined,
"donorState": undefined,
@@ -136,7 +135,6 @@ 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 71c8542268d..483f0f2b04d 100644
--- a/src/mongo/db/s/resharding/resharding_metrics.cpp
+++ b/src/mongo/db/s/resharding/resharding_metrics.cpp
@@ -85,19 +85,16 @@ 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 ? *e : RecipientStateEnum::kUnused);
+ return RecipientState_serializer(*e);
}
-// 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 ? *e : DonorStateEnum::kUnused);
+ return DonorState_serializer(*e);
}
-// 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 ? *e : CoordinatorStateEnum::kUnused);
+ return CoordinatorState_serializer(*e);
}
// Allows tracking elapsed time for the resharding operation and its sub operations (e.g.,
@@ -192,10 +189,6 @@ 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);
@@ -204,6 +197,9 @@ 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 c90ec1e4c9d..4b6c7a1fcde 100644
--- a/src/mongo/db/s/resharding/resharding_metrics_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_metrics_test.cpp
@@ -283,11 +283,6 @@ 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);
@@ -407,7 +402,7 @@ TEST_F(ReshardingMetricsTest, EstimatedRemainingOperationTime) {
const auto elapsedTime = 1;
startOperation(ReshardingMetrics::Role::kRecipient);
- checkMetrics(kTag, -1, OpReportType::CurrentOpReportDonorRole);
+ checkMetrics(kTag, -1, OpReportType::CurrentOpReportRecipientRole);
const auto kDocumentsToCopy = 2;
const auto kBytesToCopy = 200;
@@ -419,7 +414,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::CurrentOpReportDonorRole);
+ checkMetrics(kTag, elapsedTime + 2 * elapsedTime, OpReportType::CurrentOpReportRecipientRole);
const auto kOplogEntriesFetched = 4;
const auto kOplogEntriesApplied = 2;
@@ -432,7 +427,7 @@ TEST_F(ReshardingMetricsTest, EstimatedRemainingOperationTime) {
// So far, the time to apply oplog entries equals `elapsedTime` seconds.
checkMetrics(kTag,
elapsedTime * (kOplogEntriesFetched / kOplogEntriesApplied - 1),
- OpReportType::CurrentOpReportDonorRole);
+ OpReportType::CurrentOpReportRecipientRole);
}
TEST_F(ReshardingMetricsTest, CurrentOpReportForDonor) {
@@ -460,7 +455,6 @@ TEST_F(ReshardingMetricsTest, CurrentOpReportForDonor) {
"unique: {3},"
"collation: {{ locale: \"simple\" }} }},"
"totalOperationTimeElapsedSecs: 5,"
- "remainingOperationTimeEstimatedSecs: -1,"
"countWritesDuringCriticalSection: 0,"
"totalCriticalSectionTimeElapsedSecs : 3,"
"donorState: \"{4}\","
@@ -573,7 +567,6 @@ TEST_F(ReshardingMetricsTest, CurrentOpReportForCoordinator) {
"unique: {3},"
"collation: {{ locale: \"simple\" }} }},"
"totalOperationTimeElapsedSecs: {4},"
- "remainingOperationTimeEstimatedSecs: -1,"
"coordinatorState: \"{5}\","
"opStatus: \"running\" }}",
options.id.toString(),