summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPol Pinol Castuera <pol.pinol@mongodb.com>2023-03-07 08:34:07 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-07 10:05:58 +0000
commita1828809c81e1e96e51784095bfc9055a4e2b4d6 (patch)
tree9a672964ff8f665f9a00036d450102bfb59f25f0
parenta139508e0d0146690f74fcea529571871b33dca7 (diff)
downloadmongo-a1828809c81e1e96e51784095bfc9055a4e2b4d6.tar.gz
SERVER-73394 Remove operationsBlockedByRefresh metrics
-rw-r--r--jstests/sharding/catalog_cache_refresh_counters.js117
-rw-r--r--src/mongo/s/catalog_cache.cpp59
-rw-r--r--src/mongo/s/catalog_cache.h19
-rw-r--r--src/mongo/s/commands/cluster_find_cmd.h5
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp7
-rw-r--r--src/mongo/s/commands/strategy.cpp10
6 files changed, 0 insertions, 217 deletions
diff --git a/jstests/sharding/catalog_cache_refresh_counters.js b/jstests/sharding/catalog_cache_refresh_counters.js
deleted file mode 100644
index 807c9f9819f..00000000000
--- a/jstests/sharding/catalog_cache_refresh_counters.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Test that operations that get blocked by catalog cache refreshes get logged to
- * shardingStatistics.
- */
-
-(function() {
-'use strict';
-
-load('jstests/sharding/libs/sharded_transactions_helpers.js');
-load("jstests/sharding/libs/chunk_bounds_util.js");
-load("jstests/sharding/libs/find_chunks_util.js");
-
-let st = new ShardingTest({mongos: 2, shards: 2});
-const configDB = st.s.getDB('config');
-const dbName = "test";
-const collName = "foo";
-const ns = dbName + "." + collName;
-const mongos0DB = st.s0.getDB(dbName);
-const mongos1DB = st.s1.getDB(dbName);
-const mongos0Coll = mongos0DB[collName];
-const mongos1Coll = mongos1DB[collName];
-
-let setUp = () => {
- /**
- * Sets up a test by moving chunks to such that one chunk is on each
- * shard, with the following distribution:
- * shard0: [-inf, 0)
- * shard1: [0, inf)
- */
- assert.commandWorked(st.s0.adminCommand({enableSharding: dbName}));
- assert.commandWorked(st.s0.adminCommand({movePrimary: dbName, to: st.shard0.shardName}));
- assert.commandWorked(st.s0.adminCommand({shardCollection: ns, key: {x: 1}}));
- assert.commandWorked(st.s0.adminCommand({split: ns, middle: {x: 0}}));
-
- flushRoutersAndRefreshShardMetadata(st, {ns});
-};
-
-let getOpsBlockedByRefresh = () => {
- return assert.commandWorked(st.s1.adminCommand({serverStatus: 1}))
- .shardingStatistics.catalogCache.operationsBlockedByRefresh;
-};
-
-let verifyBlockedOperationsChange = (oldOperationsCount, increasedOps) => {
- let newOperationsCount = getOpsBlockedByRefresh();
- increasedOps.forEach(op => {
- assert.eq(newOperationsCount[op.opType], oldOperationsCount[op.opType] + op.increase);
- });
-};
-
-let getShardToTargetForMoveChunk = () => {
- const chunkDocs = findChunksUtil.findChunksByNs(configDB, ns).toArray();
- const shardChunkBounds = chunkBoundsUtil.findShardChunkBounds(chunkDocs);
- const shardThatOwnsChunk = chunkBoundsUtil.findShardForShardKey(st, shardChunkBounds, {x: 100});
- return st.getOther(shardThatOwnsChunk).shardName;
-};
-
-let runTest = (operationToRunFn, expectedOpIncreases) => {
- let opsBlockedByRefresh = getOpsBlockedByRefresh();
-
- // Move chunk to ensure stale shard version for the next operation.
- assert.commandWorked(
- st.s0.adminCommand({moveChunk: ns, find: {x: 100}, to: getShardToTargetForMoveChunk()}));
-
- operationToRunFn();
- verifyBlockedOperationsChange(opsBlockedByRefresh, expectedOpIncreases);
-};
-
-setUp();
-
-// TODO (SERVER-71289): Remove mongos version check in catalog_cache_refresh_counters.js.
-const isLatestMongos = jsTestOptions().mongosBinVersion !== "last-lts";
-
-/**
- * Verify that insert operations get logged when blocked by a refresh.
- */
-runTest(() => assert.commandWorked(mongos1Coll.insert({x: 250})), [
- {opType: 'countAllOperations', increase: isLatestMongos ? 1 : 2},
- {opType: 'countInserts', increase: 1},
- {opType: 'countCommands', increase: isLatestMongos ? 0 : 1}
-]);
-
-/**
- * Verify that queries get logged when blocked by a refresh.
- */
-runTest(() => mongos1Coll.findOne({x: 250}),
- [{opType: 'countAllOperations', increase: 1}, {opType: 'countQueries', increase: 1}]);
-
-/**
- * Verify that updates get logged when blocked by a refresh.
- */
-runTest(() => assert.commandWorked(mongos1Coll.update({x: 250}, {$set: {a: 1}})), [
- {opType: 'countAllOperations', increase: isLatestMongos ? 1 : 2},
- {opType: 'countUpdates', increase: 1},
- {opType: 'countCommands', increase: isLatestMongos ? 0 : 1}
-]);
-
-/**
- * Verify that deletes get logged when blocked by a refresh.
- */
-runTest(() => assert.commandWorked(mongos1Coll.remove({x: 250})), [
- {opType: 'countAllOperations', increase: isLatestMongos ? 1 : 2},
- {opType: 'countDeletes', increase: 1},
- {opType: 'countCommands', increase: isLatestMongos ? 0 : 1}
-]);
-
-/**
- * Verify that non-CRUD commands get logged when blocked by a refresh.
- */
-runTest(() => assert.commandWorked(mongos1DB.runCommand(
- {createIndexes: collName, indexes: [{key: {a: 1}, name: 'index'}]})),
- [
- {opType: 'countAllOperations', increase: 1},
- {opType: 'countCommands', increase: 1},
- ]);
-
-st.stop();
-})();
diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp
index 5f600abc056..997f5164311 100644
--- a/src/mongo/s/catalog_cache.cpp
+++ b/src/mongo/s/catalog_cache.cpp
@@ -71,9 +71,6 @@ const int kIndexCacheSize = 10000;
const OperationContext::Decoration<bool> operationShouldBlockBehindCatalogCacheRefresh =
OperationContext::declareDecoration<bool>();
-const OperationContext::Decoration<bool> operationBlockedBehindCatalogCacheRefresh =
- OperationContext::declareDecoration<bool>();
-
std::shared_ptr<RoutingTableHistory> createUpdatedRoutingTableHistory(
OperationContext* opCtx,
const NamespaceString& nss,
@@ -381,9 +378,6 @@ StatusWith<ChunkManager> CatalogCache::_getCollectionPlacementInfoAt(
}
// From this point we can guarantee that allowLocks is false
-
- operationBlockedBehindCatalogCacheRefresh(opCtx) = true;
-
size_t acquireTries = 0;
Timer t;
@@ -503,8 +497,6 @@ boost::optional<ShardingIndexesCatalogCache> CatalogCache::_getCollectionIndexIn
// From this point we can guarantee that allowLocks is false
size_t acquireTries = 0;
- operationBlockedBehindCatalogCacheRefresh(opCtx) = true;
-
while (true) {
try {
auto indexEntry = indexEntryFuture.get(opCtx);
@@ -742,37 +734,6 @@ void CatalogCache::report(BSONObjBuilder* builder) const {
_collectionCache.reportStats(&cacheStatsBuilder);
}
-void CatalogCache::checkAndRecordOperationBlockedByRefresh(OperationContext* opCtx,
- mongo::LogicalOp opType) {
- if (!isMongos() || !operationBlockedBehindCatalogCacheRefresh(opCtx)) {
- return;
- }
-
- auto& opsBlockedByRefresh = _stats.operationsBlockedByRefresh;
-
- opsBlockedByRefresh.countAllOperations.fetchAndAddRelaxed(1);
-
- switch (opType) {
- case LogicalOp::opInsert:
- opsBlockedByRefresh.countInserts.fetchAndAddRelaxed(1);
- break;
- case LogicalOp::opQuery:
- opsBlockedByRefresh.countQueries.fetchAndAddRelaxed(1);
- break;
- case LogicalOp::opUpdate:
- opsBlockedByRefresh.countUpdates.fetchAndAddRelaxed(1);
- break;
- case LogicalOp::opDelete:
- opsBlockedByRefresh.countDeletes.fetchAndAddRelaxed(1);
- break;
- case LogicalOp::opCommand:
- opsBlockedByRefresh.countCommands.fetchAndAddRelaxed(1);
- break;
- default:
- MONGO_UNREACHABLE;
- }
-}
-
void CatalogCache::invalidateDatabaseEntry_LINEARIZABLE(const StringData& dbName) {
_databaseCache.invalidateKey(dbName);
}
@@ -791,26 +752,6 @@ void CatalogCache::Stats::report(BSONObjBuilder* builder) const {
builder->append("countStaleConfigErrors", countStaleConfigErrors.load());
builder->append("totalRefreshWaitTimeMicros", totalRefreshWaitTimeMicros.load());
-
- if (isMongos()) {
- BSONObjBuilder operationsBlockedByRefreshBuilder(
- builder->subobjStart("operationsBlockedByRefresh"));
-
- operationsBlockedByRefreshBuilder.append(
- "countAllOperations", operationsBlockedByRefresh.countAllOperations.load());
- operationsBlockedByRefreshBuilder.append("countInserts",
- operationsBlockedByRefresh.countInserts.load());
- operationsBlockedByRefreshBuilder.append("countQueries",
- operationsBlockedByRefresh.countQueries.load());
- operationsBlockedByRefreshBuilder.append("countUpdates",
- operationsBlockedByRefresh.countUpdates.load());
- operationsBlockedByRefreshBuilder.append("countDeletes",
- operationsBlockedByRefresh.countDeletes.load());
- operationsBlockedByRefreshBuilder.append("countCommands",
- operationsBlockedByRefresh.countCommands.load());
-
- operationsBlockedByRefreshBuilder.done();
- }
}
CatalogCache::DatabaseCache::DatabaseCache(ServiceContext* service,
diff --git a/src/mongo/s/catalog_cache.h b/src/mongo/s/catalog_cache.h
index f8766ad35d4..7ccc091ee62 100644
--- a/src/mongo/s/catalog_cache.h
+++ b/src/mongo/s/catalog_cache.h
@@ -293,13 +293,6 @@ public:
void report(BSONObjBuilder* builder) const;
/**
- * Checks if the current operation was ever marked as needing refresh. If the curent operation
- * was marked as needing refresh, updates the relevant counters inside the Stats struct.
- */
- void checkAndRecordOperationBlockedByRefresh(OperationContext* opCtx, mongo::LogicalOp opType);
-
-
- /**
* Non-blocking method that marks the current database entry for the dbName as needing
* refresh. Will cause all further targetting attempts to block on a catalog cache refresh,
* even if they do not require causal consistency.
@@ -425,18 +418,6 @@ private:
// combined
AtomicWord<long long> totalRefreshWaitTimeMicros{0};
- // Cumulative, always-increasing counter of how many operations have been blocked by a
- // catalog cache refresh. Broken down by operation type to match the operations tracked
- // by the OpCounters class.
- struct OperationsBlockedByRefresh {
- AtomicWord<long long> countAllOperations{0};
- AtomicWord<long long> countInserts{0};
- AtomicWord<long long> countQueries{0};
- AtomicWord<long long> countUpdates{0};
- AtomicWord<long long> countDeletes{0};
- AtomicWord<long long> countCommands{0};
- } operationsBlockedByRefresh;
-
/**
* Reports the accumulated statistics for serverStatus.
*/
diff --git a/src/mongo/s/commands/cluster_find_cmd.h b/src/mongo/s/commands/cluster_find_cmd.h
index 23b99fcea2d..00a1378d308 100644
--- a/src/mongo/s/commands/cluster_find_cmd.h
+++ b/src/mongo/s/commands/cluster_find_cmd.h
@@ -209,11 +209,6 @@ public:
Impl::checkCanRunHere(opCtx);
- ON_BLOCK_EXIT([opCtx] {
- Grid::get(opCtx)->catalogCache()->checkAndRecordOperationBlockedByRefresh(
- opCtx, mongo::LogicalOp::opQuery);
- });
-
auto findCommand = _parseCmdObjectToFindCommandRequest(opCtx, ns(), _request.body);
const boost::intrusive_ptr<ExpressionContext> expCtx;
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index a39072fbe74..2343ce2c6d6 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -556,22 +556,17 @@ bool ClusterWriteCmd::InvocationBase::runImpl(OperationContext* opCtx,
// TODO: increase opcounters by more than one
auto& debug = CurOp::get(opCtx)->debug();
- auto catalogCache = Grid::get(opCtx)->catalogCache();
switch (_batchedRequest.getBatchType()) {
case BatchedCommandRequest::BatchType_Insert:
for (size_t i = 0; i < numAttempts; ++i) {
globalOpCounters.gotInsert();
}
- catalogCache->checkAndRecordOperationBlockedByRefresh(opCtx,
- mongo::LogicalOp::opInsert);
debug.additiveMetrics.ninserted = response.getN();
break;
case BatchedCommandRequest::BatchType_Update:
for (size_t i = 0; i < numAttempts; ++i) {
globalOpCounters.gotUpdate();
}
- catalogCache->checkAndRecordOperationBlockedByRefresh(opCtx,
- mongo::LogicalOp::opUpdate);
// The response.getN() count is the sum of documents matched and upserted.
if (response.isUpsertDetailsSet()) {
@@ -604,8 +599,6 @@ bool ClusterWriteCmd::InvocationBase::runImpl(OperationContext* opCtx,
for (size_t i = 0; i < numAttempts; ++i) {
globalOpCounters.gotDelete();
}
- catalogCache->checkAndRecordOperationBlockedByRefresh(opCtx,
- mongo::LogicalOp::opDelete);
debug.additiveMetrics.ndeleted = response.getN();
break;
}
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 34a6f2cda0b..c46654ec116 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -430,14 +430,6 @@ public:
explicit RunInvocation(ParseAndRunCommand* parc) : _parc(parc) {}
- ~RunInvocation() {
- if (!_shouldAffectCommandCounter)
- return;
- auto opCtx = _parc->_rec->getOpCtx();
- Grid::get(opCtx)->catalogCache()->checkAndRecordOperationBlockedByRefresh(
- opCtx, mongo::LogicalOp::opCommand);
- }
-
Future<void> run();
private:
@@ -446,7 +438,6 @@ private:
ParseAndRunCommand* const _parc;
boost::optional<RouterOperationContextSession> _routerSession;
- bool _shouldAffectCommandCounter = false;
};
/*
@@ -905,7 +896,6 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
if (command->shouldAffectCommandCounter()) {
globalOpCounters.gotCommand();
- _shouldAffectCommandCounter = true;
}
return Status::OK();