diff options
author | Ali Mir <ali.mir@mongodb.com> | 2020-09-09 11:24:36 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-09 23:27:41 +0000 |
commit | 3f247ef83d5ceb4d98766b003cece20dae4a768e (patch) | |
tree | 9648bfc01b49cd1011a32f4346c2ceb3ec67be71 | |
parent | 443a113df1c71dbc8ab33e91057a53bfba65c641 (diff) | |
download | mongo-3f247ef83d5ceb4d98766b003cece20dae4a768e.tar.gz |
SERVER-50417 Change notMasterUnacknowledgedWrites to notPrimaryUnacknowledgedWrites in serverStatus
(cherry picked from commit 0927e74e9d5dfb47c4f02d21029f68a3b17764b7)
-rw-r--r-- | etc/backports_required_for_multiversion_tests.yml | 8 | ||||
-rw-r--r-- | jstests/replsets/no_disconnect_on_stepdown.js | 2 | ||||
-rw-r--r-- | jstests/replsets/not_master_unacknowledged_write.js | 16 | ||||
-rw-r--r-- | jstests/replsets/read_operations_during_step_down.js | 2 | ||||
-rw-r--r-- | jstests/replsets/read_operations_during_step_up.js | 6 | ||||
-rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 10 |
6 files changed, 26 insertions, 18 deletions
diff --git a/etc/backports_required_for_multiversion_tests.yml b/etc/backports_required_for_multiversion_tests.yml index 09166bdd011..5e8044e8e9b 100644 --- a/etc/backports_required_for_multiversion_tests.yml +++ b/etc/backports_required_for_multiversion_tests.yml @@ -93,6 +93,14 @@ all: test_file: jstests/replsets/transactions_on_secondaries_not_allowed.js - ticket: SERVER-50416 test_file: jstests/replsets/disconnect_on_legacy_write_to_secondary.js + - ticket: SERVER-50417 + test_file: jstests/replsets/no_disconnect_on_stepdown.js + - ticket: SERVER-50417 + test_file: jstests/replsets/not_master_unacknowledged_write.js + - ticket: SERVER-50417 + test_file: jstests/replsets/read_operations_during_step_down.js + - ticket: SERVER-50417 + test_file: jstests/replsets/read_operations_during_step_up.js suites: diff --git a/jstests/replsets/no_disconnect_on_stepdown.js b/jstests/replsets/no_disconnect_on_stepdown.js index 863ece9e05c..9609b7ffdd1 100644 --- a/jstests/replsets/no_disconnect_on_stepdown.js +++ b/jstests/replsets/no_disconnect_on_stepdown.js @@ -73,7 +73,7 @@ function runStepDownTest({description, failpoint, operation, errorCode}) { assert.commandWorked(primaryAdmin.adminCommand({serverStatus: 1})).metrics.repl; assert.eq(replMetrics.stateTransition.lastStateTransition, "stepDown"); assert.eq(replMetrics.stateTransition.userOperationsKilled, 1); - assert.eq(replMetrics.network.notMasterUnacknowledgedWrites, 0); + assert.eq(replMetrics.network.notPrimaryUnacknowledgedWrites, 0); // Allow the primary to be re-elected, and wait for it. assert.commandWorked(primaryAdmin.adminCommand({replSetFreeze: 0})); diff --git a/jstests/replsets/not_master_unacknowledged_write.js b/jstests/replsets/not_master_unacknowledged_write.js index a1570de931a..1fc65ddb7ba 100644 --- a/jstests/replsets/not_master_unacknowledged_write.js +++ b/jstests/replsets/not_master_unacknowledged_write.js @@ -5,12 +5,12 @@ (function() { "use strict"; -function getNotMasterUnackWritesCounter() { +function getNotPrimaryUnackWritesCounter() { return assert.commandWorked(primaryDB.adminCommand({serverStatus: 1})) - .metrics.repl.network.notMasterUnacknowledgedWrites; + .metrics.repl.network.notPrimaryUnacknowledgedWrites; } -const collName = "not_master_unacknowledged_write"; +const collName = "not_primary_unacknowledged_write"; var rst = new ReplSetTest({nodes: [{}, {rsConfig: {priority: 0}}]}); rst.startSet(); @@ -22,8 +22,8 @@ var secondaryDB = secondary.getDB("test"); var primaryColl = primaryDB[collName]; var secondaryColl = secondaryDB[collName]; -// Verify that reading from secondaries does not impact `notMasterUnacknowledgedWrites`. -const preReadingCounter = getNotMasterUnackWritesCounter(); +// Verify that reading from secondaries does not impact `notPrimaryUnacknowledgedWrites`. +const preReadingCounter = getNotPrimaryUnackWritesCounter(); jsTestLog("Reading from secondary ..."); [{name: "findOne", fn: () => secondaryColl.findOne()}, {name: "distinct", fn: () => secondaryColl.distinct("item")}, @@ -32,7 +32,7 @@ jsTestLog("Reading from secondary ..."); assert.doesNotThrow(fn); assert.eq(assert.commandWorked(secondary.getDB("admin").isMaster()).ismaster, false); }); -const postReadingCounter = getNotMasterUnackWritesCounter(); +const postReadingCounter = getNotPrimaryUnackWritesCounter(); assert.eq(preReadingCounter, postReadingCounter); jsTestLog("Primary on port " + primary.port + " hangs up on unacknowledged writes"); @@ -71,7 +71,7 @@ var command = var awaitShell = startParallelShell(command, primary.port); -let failedUnackWritesBefore = getNotMasterUnackWritesCounter(); +let failedUnackWritesBefore = getNotPrimaryUnackWritesCounter(); jsTestLog("Beginning unacknowledged insert"); primaryColl.insertOne({}, {writeConcern: {w: 0}}); @@ -87,7 +87,7 @@ assert.includes(result.toString(), "network error while attempting to run comman // Validate the number of unacknowledged writes failed due to step down resulted in network // disconnection. -let failedUnackWritesAfter = getNotMasterUnackWritesCounter(); +let failedUnackWritesAfter = getNotPrimaryUnackWritesCounter(); assert.eq(failedUnackWritesAfter, failedUnackWritesBefore + 1); rst.stopSet(); diff --git a/jstests/replsets/read_operations_during_step_down.js b/jstests/replsets/read_operations_during_step_down.js index 96fa2651237..4909c7a9177 100644 --- a/jstests/replsets/read_operations_during_step_down.js +++ b/jstests/replsets/read_operations_during_step_down.js @@ -113,7 +113,7 @@ assert.eq(replMetrics.stateTransition.lastStateTransition, "stepDown"); assert.eq(replMetrics.stateTransition.userOperationsKilled, 0); // Should account for find and getmore commands issued before step down. assert.gte(replMetrics.stateTransition.userOperationsRunning, 2); -assert.eq(replMetrics.network.notMasterUnacknowledgedWrites, 0); +assert.eq(replMetrics.network.notPrimaryUnacknowledgedWrites, 0); rst.stopSet(); })(); diff --git a/jstests/replsets/read_operations_during_step_up.js b/jstests/replsets/read_operations_during_step_up.js index 91d202659a4..86b64ccba0b 100644 --- a/jstests/replsets/read_operations_during_step_up.js +++ b/jstests/replsets/read_operations_during_step_up.js @@ -36,10 +36,10 @@ assert.commandWorked( primaryColl.insert({_id: 0}, {"writeConcern": {"w": "majority"}})); rst.awaitReplication(); -// It's possible for notMasterUnacknowledgedWrites to be non-zero because of mirrored reads during +// It's possible for notPrimaryUnacknowledgedWrites to be non-zero because of mirrored reads during // initial sync. let replMetrics = assert.commandWorked(secondaryAdmin.adminCommand({serverStatus: 1})).metrics.repl; -const startingNumNotMasterErrors = replMetrics.network.notMasterUnacknowledgedWrites; +const startingNumNotMasterErrors = replMetrics.network.notPrimaryUnacknowledgedWrites; // Open a cursor on secondary. const cursorIdToBeReadAfterStepUp = @@ -127,7 +127,7 @@ assert.eq(replMetrics.stateTransition.lastStateTransition, "stepUp"); assert.eq(replMetrics.stateTransition.userOperationsKilled, 0); // Should account for find and getmore commands issued before step up. assert.gte(replMetrics.stateTransition.userOperationsRunning, 2); -assert.eq(replMetrics.network.notMasterUnacknowledgedWrites, startingNumNotMasterErrors); +assert.eq(replMetrics.network.notPrimaryUnacknowledgedWrites, startingNumNotMasterErrors); rst.stopSet(); })(); diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index ff5153ed627..6e02dc9af25 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -119,11 +119,11 @@ Counter64 notPrimaryLegacyUnackWrites; ServerStatusMetricField<Counter64> displayNotPrimaryLegacyUnackWrites( "repl.network.notPrimaryLegacyUnacknowledgedWrites", ¬PrimaryLegacyUnackWrites); -// Tracks the number of times an unacknowledged write failed due to not master error +// Tracks the number of times an unacknowledged write failed due to not primary error // resulted in network disconnection. -Counter64 notMasterUnackWrites; -ServerStatusMetricField<Counter64> displayNotMasterUnackWrites( - "repl.network.notMasterUnacknowledgedWrites", ¬MasterUnackWrites); +Counter64 notPrimaryUnackWrites; +ServerStatusMetricField<Counter64> displayNotPrimaryUnackWrites( + "repl.network.notPrimaryUnacknowledgedWrites", ¬PrimaryUnackWrites); namespace { @@ -1418,7 +1418,7 @@ DbResponse receivedCommands(OperationContext* opCtx, // Close the connection to get client to go through server selection again. if (LastError::get(opCtx->getClient()).hadNotPrimaryError()) { if (c && c->getReadWriteType() == Command::ReadWriteType::kWrite) - notMasterUnackWrites.increment(); + notPrimaryUnackWrites.increment(); uasserted(ErrorCodes::NotWritablePrimary, str::stream() << "Not-master error while processing '" << request.getCommandName() |