summaryrefslogtreecommitdiff
path: root/src/mongo/db
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-22 22:09:04 +0000
commitf2f5aa45d289349eaae9fdbf1f7bb54ea25819bf (patch)
tree783f6b4fe01399da2c4cc0c7c3cfa725bbdd0c6a /src/mongo/db
parente3ba5a35ed20eebe21dedcad2ceb021b467bf2cc (diff)
downloadmongo-f2f5aa45d289349eaae9fdbf1f7bb54ea25819bf.tar.gz
SERVER-57217 Don't report remainingOperationTimeEstimatedSecs in currentOp metrics for resharding for donors and coordinators
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/resharding/resharding_metrics.cpp16
-rw-r--r--src/mongo/db/s/resharding/resharding_metrics_test.cpp15
2 files changed, 10 insertions, 21 deletions
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..40d97f69d75 100644
--- a/src/mongo/db/s/resharding/resharding_metrics_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_metrics_test.cpp
@@ -237,7 +237,7 @@ TEST_F(ReshardingMetricsTest, TestOperationStatus) {
}
TEST_F(ReshardingMetricsTest, TestElapsedTime) {
- startOperation(ReshardingMetrics::Role::kRecipient);
+ startOperation(ReshardingMetrics::Role::kDonor);
const auto elapsedTime = 1;
advanceTime(Seconds(elapsedTime));
checkMetrics(
@@ -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(),