summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2018-12-14 11:42:51 -0500
committerJack Mulrow <jack.mulrow@mongodb.com>2018-12-20 22:42:27 -0500
commit3c140cdd63bbf20e585bbbccd21ed3ea64e656b1 (patch)
tree896333b3ce4d9b1109d1db51b970c261f045fd43
parentcf9acc9439eb02c9fbdf757b382611cc343e5ac6 (diff)
downloadmongo-3c140cdd63bbf20e585bbbccd21ed3ea64e656b1.tar.gz
SERVER-38661 Don't allow read commands to change global read timestamp for sharded transactions
-rw-r--r--src/mongo/db/pipeline/mongos_process_interface.cpp5
-rw-r--r--src/mongo/s/SConscript14
-rw-r--r--src/mongo/s/cluster_commands_helpers.cpp16
-rw-r--r--src/mongo/s/compute_at_cluster_time_test.cpp348
-rw-r--r--src/mongo/s/query/cluster_aggregate.cpp5
-rw-r--r--src/mongo/s/query/cluster_find.cpp9
-rw-r--r--src/mongo/s/transaction_router.cpp28
-rw-r--r--src/mongo/s/transaction_router.h19
-rw-r--r--src/mongo/s/transaction_router_test.cpp7
9 files changed, 0 insertions, 451 deletions
diff --git a/src/mongo/db/pipeline/mongos_process_interface.cpp b/src/mongo/db/pipeline/mongos_process_interface.cpp
index 05ae84b17a5..74da30e9d71 100644
--- a/src/mongo/db/pipeline/mongos_process_interface.cpp
+++ b/src/mongo/db/pipeline/mongos_process_interface.cpp
@@ -402,11 +402,6 @@ MongoSInterface::DispatchShardPipelineResults MongoSInterface::dispatchShardPipe
std::set<ShardId> shardIds = getTargetedShards(
opCtx, mustRunOnAll, executionNsRoutingInfo, shardQuery, aggRequest.getCollation());
- if (auto txnRouter = TransactionRouter::get(opCtx)) {
- txnRouter->computeAndSetAtClusterTime(
- opCtx, mustRunOnAll, shardIds, executionNss, shardQuery, aggRequest.getCollation());
- }
-
// Don't need to split the pipeline if we are only targeting a single shard, unless:
// - There is a stage that needs to be run on the primary shard and the single target shard
// is not the primary.
diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript
index 5fd0b5aec8e..0ec9c6b6f00 100644
--- a/src/mongo/s/SConscript
+++ b/src/mongo/s/SConscript
@@ -518,17 +518,3 @@ env.CppUnitTest(
'sharding_router_test_fixture',
]
)
-
-env.CppUnitTest(
- target='compute_at_cluster_time_test',
- source=[
- 'compute_at_cluster_time_test.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/db/auth/authmocks',
- '$BUILD_DIR/mongo/db/logical_clock',
- '$BUILD_DIR/mongo/unittest/unittest',
- 'catalog_cache_test_fixture',
- 'sharding_router_api',
- ]
-)
diff --git a/src/mongo/s/cluster_commands_helpers.cpp b/src/mongo/s/cluster_commands_helpers.cpp
index 3cff718147e..062e192140b 100644
--- a/src/mongo/s/cluster_commands_helpers.cpp
+++ b/src/mongo/s/cluster_commands_helpers.cpp
@@ -104,18 +104,6 @@ std::vector<AsyncRequestsSender::Request> buildUnversionedRequestsForShards(
cmdToSend = appendAllowImplicitCreate(cmdToSend, false);
}
- if (shardIds.size() == 1u) {
- // The commands that support snapshot read concern only send unversioned
- // requests to unsharded collections, so they should only be targeting
- // the primary shard.
- if (auto txnRouter = TransactionRouter::get(opCtx)) {
- txnRouter->computeAndSetAtClusterTimeForUnsharded(opCtx, shardIds[0]);
- }
- } else {
- invariant(repl::ReadConcernArgs::get(opCtx).getLevel() !=
- repl::ReadConcernLevel::kSnapshotReadConcern);
- }
-
std::vector<AsyncRequestsSender::Request> requests;
for (auto&& shardId : shardIds)
requests.emplace_back(std::move(shardId), cmdToSend);
@@ -162,10 +150,6 @@ std::vector<AsyncRequestsSender::Request> buildVersionedRequestsForTargetedShard
std::set<ShardId> shardIds;
routingInfo.cm()->getShardIdsForQuery(opCtx, query, collation, &shardIds);
- if (auto txnRouter = TransactionRouter::get(opCtx)) {
- txnRouter->computeAndSetAtClusterTime(opCtx, false, shardIds, nss, query, collation);
- }
-
for (const ShardId& shardId : shardIds) {
requests.emplace_back(shardId,
appendShardVersion(cmdToSend, routingInfo.cm()->getVersion(shardId)));
diff --git a/src/mongo/s/compute_at_cluster_time_test.cpp b/src/mongo/s/compute_at_cluster_time_test.cpp
deleted file mode 100644
index da30e27251f..00000000000
--- a/src/mongo/s/compute_at_cluster_time_test.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-
-/**
- * Copyright (C) 2018-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include <boost/optional.hpp>
-
-#include "mongo/client/remote_command_targeter_mock.h"
-#include "mongo/db/logical_clock.h"
-#include "mongo/db/logical_time.h"
-#include "mongo/s/catalog_cache_test_fixture.h"
-#include "mongo/s/client/shard_remote.h"
-#include "mongo/s/cluster_commands_helpers.h"
-#include "mongo/s/session_catalog_router.h"
-#include "mongo/s/shard_id.h"
-#include "mongo/s/sharding_router_test_fixture.h"
-#include "mongo/s/transaction_router.h"
-#include "mongo/unittest/unittest.h"
-
-namespace mongo {
-namespace {
-
-const HostAndPort kTestConfigShardHost = HostAndPort("FakeConfigHost", 12345);
-
-const ShardId shardOneId("shardOne");
-const HostAndPort shardOne("shardOne:1234");
-
-const ShardId shardTwoId("shardTwo");
-const HostAndPort shardTwo("shardTwo:1234");
-
-const NamespaceString kNss = NamespaceString("test", "coll");
-const BSONObj kEmptyQuery;
-const BSONObj kEmptyCollation;
-const LogicalTime kInMemoryLogicalTime(Timestamp(3, 1));
-
-const TxnNumber kTxnNumber = 3;
-
-class AtClusterTimeTest : public ShardingTestFixture {
-protected:
- void setUp() {
- ShardingTestFixture::setUp();
- configTargeter()->setFindHostReturnValue(kTestConfigShardHost);
- std::vector<std::tuple<ShardId, HostAndPort>> shardInfos;
- shardInfos.push_back(std::make_tuple(shardOneId, shardOne));
- shardInfos.push_back(std::make_tuple(shardTwoId, shardTwo));
-
- ShardingTestFixture::addRemoteShards(shardInfos);
-
- // Set up a logical clock with an initial time.
- auto logicalClock = stdx::make_unique<LogicalClock>(getServiceContext());
- logicalClock->setClusterTimeFromTrustedSource(kInMemoryLogicalTime);
- LogicalClock::set(getServiceContext(), std::move(logicalClock));
-
- operationContext()->setLogicalSessionId(makeLogicalSessionIdForTest());
- operationContext()->setTxnNumber(kTxnNumber);
- repl::ReadConcernArgs::get(operationContext()) =
- repl::ReadConcernArgs(repl::ReadConcernLevel::kSnapshotReadConcern);
-
- _scopedSession.emplace(operationContext());
- txnRouter()->beginOrContinueTxn(
- operationContext(), kTxnNumber, TransactionRouter::TransactionActions::kStart);
- }
-
- TransactionRouter* txnRouter() const {
- return TransactionRouter::get(operationContext());
- }
-
- LogicalTime getSelectedTime() {
- return txnRouter()->getAtClusterTime()->getTime();
- }
-
-private:
- boost::optional<RouterOperationContextSession> _scopedSession;
-};
-
-TEST_F(AtClusterTimeTest, ComputeValidValid) {
- auto shardOne = shardRegistry()->getShardNoReload(shardOneId);
- LogicalTime timeOne(Timestamp(10, 2));
- shardOne->updateLastCommittedOpTime(timeOne);
- ASSERT_EQ(timeOne, shardOne->getLastCommittedOpTime());
-
- auto shardTwo = shardRegistry()->getShardNoReload(shardTwoId);
- LogicalTime timeTwo(Timestamp(15, 1));
- shardTwo->updateLastCommittedOpTime(timeTwo);
- ASSERT_EQ(timeTwo, shardTwo->getLastCommittedOpTime());
-
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {shardOneId, shardTwoId}, kNss, kEmptyQuery, kEmptyCollation);
- // TODO SERVER-36312:
- // ASSERT_EQ(getSelectedTime(), timeTwo);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-TEST_F(AtClusterTimeTest, ComputeValidInvalid) {
- auto shardOne = shardRegistry()->getShardNoReload(shardOneId);
- ASSERT_EQ(LogicalTime(), shardOne->getLastCommittedOpTime());
-
- auto shardTwo = shardRegistry()->getShardNoReload(shardTwoId);
- LogicalTime timeTwo(Timestamp(15, 1));
- shardTwo->updateLastCommittedOpTime(timeTwo);
- ASSERT_EQ(timeTwo, shardTwo->getLastCommittedOpTime());
-
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {shardOneId, shardTwoId}, kNss, kEmptyQuery, kEmptyCollation);
- // TODO SERVER-36312:
- // ASSERT_EQ(getSelectedTime(), timeTwo);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-TEST_F(AtClusterTimeTest, ComputeInvalidInvalid) {
- auto shardOne = shardRegistry()->getShardNoReload(shardOneId);
- ASSERT_EQ(LogicalTime(), shardOne->getLastCommittedOpTime());
-
- auto shardTwo = shardRegistry()->getShardNoReload(shardTwoId);
- ASSERT_EQ(LogicalTime(), shardTwo->getLastCommittedOpTime());
-
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {shardOneId, shardTwoId}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-TEST_F(AtClusterTimeTest, ComputeForUnsharded) {
- auto shardOne = shardRegistry()->getShardNoReload(shardOneId);
-
- LogicalTime timeOne(Timestamp(10, 2));
- shardOne->updateLastCommittedOpTime(timeOne);
- ASSERT_EQ(timeOne, shardOne->getLastCommittedOpTime());
-
- txnRouter()->computeAndSetAtClusterTimeForUnsharded(operationContext(), shardOneId);
- // TODO SERVER-36312:
- // ASSERT_EQ(getSelectedTime(), timeOne);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-TEST_F(AtClusterTimeTest, ComputeForUnshardedNoCachedOpTime) {
- auto shardOne = shardRegistry()->getShardNoReload(shardOneId);
- ASSERT_EQ(LogicalTime(), shardOne->getLastCommittedOpTime());
-
- txnRouter()->computeAndSetAtClusterTimeForUnsharded(operationContext(), shardOneId);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-// TODO SERVER-36312: Verify computing atClusterTime for a single shard that does not exist returns
-// an error.
-
-class AtClusterTimeTargetingTest : public CatalogCacheTestFixture {
-protected:
- void setUp() {
- CatalogCacheTestFixture::setUp();
- CatalogCacheTestFixture::setupNShards(2);
-
- // Set up a logical clock with an initial time.
- auto logicalClock = stdx::make_unique<LogicalClock>(getServiceContext());
- logicalClock->setClusterTimeFromTrustedSource(kInMemoryLogicalTime);
- LogicalClock::set(getServiceContext(), std::move(logicalClock));
-
- operationContext()->setLogicalSessionId(makeLogicalSessionIdForTest());
- operationContext()->setTxnNumber(kTxnNumber);
- repl::ReadConcernArgs::get(operationContext()) =
- repl::ReadConcernArgs(repl::ReadConcernLevel::kSnapshotReadConcern);
-
- _scopedSession.emplace(operationContext());
- txnRouter()->beginOrContinueTxn(
- operationContext(), kTxnNumber, TransactionRouter::TransactionActions::kStart);
- }
-
- TransactionRouter* txnRouter() const {
- return TransactionRouter::get(operationContext());
- }
-
- LogicalTime getSelectedTime() {
- return txnRouter()->getAtClusterTime()->getTime();
- }
-
-private:
- boost::optional<RouterOperationContextSession> _scopedSession;
-};
-
-// Verifies that the latest in-memory logical time is returned when lastCommittedOpTime on one
-// targeted shard is not initialized.
-TEST_F(AtClusterTimeTargetingTest, ReturnsLatestInMemoryTime) {
- auto routingInfo = loadRoutingTableWithTwoChunksAndTwoShards(kNss);
- auto query = BSON("find" << kNss.coll());
- auto collation = BSONObj();
- auto shards = getTargetedShardsForQuery(operationContext(), routingInfo, query, collation);
-
- LogicalTime time(Timestamp(2, 1));
- shardRegistry()->getShardNoReload(ShardId("0"))->updateLastCommittedOpTime(time);
-
- ASSERT_LT(time, kInMemoryLogicalTime);
-
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, shards, kNss, query, collation);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-// Verifies that the greatest logical time is returned when all shard's lastCommittedOpTime values
-// are initialized.
-TEST_F(AtClusterTimeTargetingTest, ReturnsLatestTimeFromShard) {
- auto routingInfo = loadRoutingTableWithTwoChunksAndTwoShards(kNss);
- auto query = BSON("find" << kNss.coll());
- auto collation = BSONObj();
- auto shards = getTargetedShardsForQuery(operationContext(), routingInfo, query, collation);
-
- LogicalTime time1(Timestamp(2, 1));
- shardRegistry()->getShardNoReload(ShardId("0"))->updateLastCommittedOpTime(time1);
-
- LogicalTime time2(Timestamp(4, 1));
- shardRegistry()->getShardNoReload(ShardId("1"))->updateLastCommittedOpTime(time2);
-
- ASSERT_LT(time1, kInMemoryLogicalTime);
- ASSERT_GT(time2, kInMemoryLogicalTime);
-
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, shards, kNss, query, collation);
- // TODO SERVER-36312:
- // ASSERT_EQ(getSelectedTime(), time2);
- ASSERT_EQ(getSelectedTime(), kInMemoryLogicalTime);
-}
-
-// Verifies that if atClusterTime is specified in the request, atClusterTime is always greater than
-// or equal to it.
-TEST_F(AtClusterTimeTargetingTest, AfterClusterTime) {
- const auto afterClusterTime = LogicalTime(Timestamp(50, 2));
- repl::ReadConcernArgs::get(operationContext()) =
- repl::ReadConcernArgs(afterClusterTime, repl::ReadConcernLevel::kSnapshotReadConcern);
-
- // This cannot be true in a real cluster, but is done to verify that the chosen atClusterTime
- // cannot be less than afterClusterTime.
- ASSERT_GT(afterClusterTime, kInMemoryLogicalTime);
-
- const auto s0 = ShardId("0");
- const auto s1 = ShardId("1");
-
- // Neither shard has a last committed optime.
-
- // Target one shard.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- txnRouter()->computeAndSetAtClusterTimeForUnsharded(operationContext(), s0);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- // Target all shards.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0, s1}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- // One shard has a last committed optime.
-
- LogicalTime time1(Timestamp(1, 1));
- shardRegistry()->getShardNoReload(s0)->updateLastCommittedOpTime(time1);
- ASSERT_LT(time1, afterClusterTime);
-
- // Target one shard.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- txnRouter()->computeAndSetAtClusterTimeForUnsharded(operationContext(), s0);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- // Target all shards.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0, s1}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- // Both shards have a last committed optime.
-
- LogicalTime time2(Timestamp(2, 1));
- shardRegistry()->getShardNoReload(s1)->updateLastCommittedOpTime(time2);
- ASSERT_LT(time2, afterClusterTime);
-
- // Target one shard.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-
- // Target all shards.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0, s1}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_GTE(getSelectedTime(), afterClusterTime);
-}
-
-// Verify that when afterClusterTime is given, the smallest computed atClusterTime is equal to
-// afterClusterTime.
-TEST_F(AtClusterTimeTargetingTest, AfterClusterTimeLowerBound) {
- auto afterClusterTime = LogicalTime(kInMemoryLogicalTime);
- repl::ReadConcernArgs::get(operationContext()) =
- repl::ReadConcernArgs(afterClusterTime, repl::ReadConcernLevel::kSnapshotReadConcern);
-
- ASSERT_EQ(afterClusterTime, kInMemoryLogicalTime);
-
- const auto s0 = ShardId("0");
-
- // Target one shard without a last committed optime. The computed value should equal
- // afterClusterTime.
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_EQ(getSelectedTime(), afterClusterTime);
-
- txnRouter()->computeAndSetAtClusterTimeForUnsharded(operationContext(), s0);
- ASSERT_EQ(getSelectedTime(), afterClusterTime);
-
- // Target one shard with a last committed optime less than afterClusterTime. The computed value
- // should still equal afterClusterTime.
- LogicalTime time1(Timestamp(1, 1));
- shardRegistry()->getShardNoReload(s0)->updateLastCommittedOpTime(time1);
- ASSERT_LT(time1, afterClusterTime);
-
- txnRouter()->computeAndSetAtClusterTime(
- operationContext(), true, {s0}, kNss, kEmptyQuery, kEmptyCollation);
- ASSERT_EQ(getSelectedTime(), afterClusterTime);
-
- txnRouter()->computeAndSetAtClusterTimeForUnsharded(operationContext(), s0);
- ASSERT_EQ(getSelectedTime(), afterClusterTime);
-}
-
-} // namespace
-} // namespace mongo
diff --git a/src/mongo/s/query/cluster_aggregate.cpp b/src/mongo/s/query/cluster_aggregate.cpp
index 3ead06bc1f1..bda15a7477c 100644
--- a/src/mongo/s/query/cluster_aggregate.cpp
+++ b/src/mongo/s/query/cluster_aggregate.cpp
@@ -827,11 +827,6 @@ Status ClusterAggregate::aggPassthrough(OperationContext* opCtx,
}
auto shard = std::move(swShard.getValue());
- auto txnRouter = TransactionRouter::get(opCtx);
- if (txnRouter) {
- txnRouter->computeAndSetAtClusterTimeForUnsharded(opCtx, shardId);
- }
-
// Format the command for the shard. This adds the 'fromMongos' field, wraps the command as an
// explain if necessary, and rewrites the result into a format safe to forward to shards.
BSONObj cmdObj = CommandHelpers::filterCommandRequestForPassthrough(
diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp
index 371f4462be2..8b893f178f7 100644
--- a/src/mongo/s/query/cluster_find.cpp
+++ b/src/mongo/s/query/cluster_find.cpp
@@ -222,15 +222,6 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx,
query.getQueryRequest().getFilter(),
query.getQueryRequest().getCollation());
- if (auto txnRouter = TransactionRouter::get(opCtx)) {
- txnRouter->computeAndSetAtClusterTime(opCtx,
- false,
- shardIds,
- query.nss(),
- query.getQueryRequest().getFilter(),
- query.getQueryRequest().getCollation());
- }
-
// Construct the query and parameters.
ClusterClientCursorParams params(query.nss(), readPref);
diff --git a/src/mongo/s/transaction_router.cpp b/src/mongo/s/transaction_router.cpp
index a7c084933fe..d005772bfbe 100644
--- a/src/mongo/s/transaction_router.cpp
+++ b/src/mongo/s/transaction_router.cpp
@@ -431,34 +431,6 @@ void TransactionRouter::onSnapshotError(const Status& errorStatus) {
_atClusterTime.emplace();
}
-void TransactionRouter::computeAndSetAtClusterTime(OperationContext* opCtx,
- bool mustRunOnAll,
- const std::set<ShardId>& shardIds,
- const NamespaceString& nss,
- const BSONObj query,
- const BSONObj collation) {
- if (!_atClusterTime || !_atClusterTime->canChange(_latestStmtId)) {
- return;
- }
-
- // TODO SERVER-36312: Re-enable algorithm using the cached opTimes of the targeted shards.
- // TODO SERVER-37549: Use the shard's cached lastApplied opTime instead of lastCommitted.
- auto computedTime = LogicalClock::get(opCtx)->getClusterTime();
- _setAtClusterTime(repl::ReadConcernArgs::get(opCtx).getArgsAfterClusterTime(), computedTime);
-}
-
-void TransactionRouter::computeAndSetAtClusterTimeForUnsharded(OperationContext* opCtx,
- const ShardId& shardId) {
- if (!_atClusterTime || !_atClusterTime->canChange(_latestStmtId)) {
- return;
- }
-
- // TODO SERVER-36312: Re-enable algorithm using the cached opTimes of the targeted shard.
- // TODO SERVER-37549: Use the shard's cached lastApplied opTime instead of lastCommitted.
- auto computedTime = LogicalClock::get(opCtx)->getClusterTime();
- _setAtClusterTime(repl::ReadConcernArgs::get(opCtx).getArgsAfterClusterTime(), computedTime);
-}
-
void TransactionRouter::setDefaultAtClusterTime(OperationContext* opCtx) {
if (!_atClusterTime || !_atClusterTime->canChange(_latestStmtId)) {
return;
diff --git a/src/mongo/s/transaction_router.h b/src/mongo/s/transaction_router.h
index 8c2fd0521fb..574dac349e5 100644
--- a/src/mongo/s/transaction_router.h
+++ b/src/mongo/s/transaction_router.h
@@ -193,25 +193,6 @@ public:
void onViewResolutionError(const NamespaceString& nss);
/**
- * Computes and sets the atClusterTime for the current transaction based on the given query
- * parameters. Does nothing if the transaction does not have snapshot read concern or an
- * atClusterTime has already been selected and cannot be changed.
- */
- void computeAndSetAtClusterTime(OperationContext* opCtx,
- bool mustRunOnAll,
- const std::set<ShardId>& shardIds,
- const NamespaceString& nss,
- const BSONObj query,
- const BSONObj collation);
-
- /**
- * Computes and sets the atClusterTime for the current transaction based on the targeted shard.
- * Does nothing if the transaction does not have snapshot read concern or an atClusterTime has
- * already been selected and cannot be changed.
- */
- void computeAndSetAtClusterTimeForUnsharded(OperationContext* opCtx, const ShardId& shardId);
-
- /**
* Sets the atClusterTime for the current transaction to the latest time in the router's logical
* clock. Does nothing if the transaction does not have snapshot read concern or an
* atClusterTime has already been selected and cannot be changed.
diff --git a/src/mongo/s/transaction_router_test.cpp b/src/mongo/s/transaction_router_test.cpp
index 4088f250bf2..b9d3fb669a2 100644
--- a/src/mongo/s/transaction_router_test.cpp
+++ b/src/mongo/s/transaction_router_test.cpp
@@ -1537,13 +1537,6 @@ TEST_F(TransactionRouterTestWithDefaultSession, NonSnapshotReadConcernHasNoAtClu
txnRouter.setDefaultAtClusterTime(operationContext());
ASSERT_FALSE(txnRouter.getAtClusterTime());
- txnRouter.computeAndSetAtClusterTime(
- operationContext(), true, {shard1}, NamespaceString("test.coll"), BSONObj(), BSONObj());
- ASSERT_FALSE(txnRouter.getAtClusterTime());
-
- txnRouter.computeAndSetAtClusterTimeForUnsharded(operationContext(), shard1);
- ASSERT_FALSE(txnRouter.getAtClusterTime());
-
// Can't continue on snapshot errors.
ASSERT_THROWS_CODE(txnRouter.onSnapshotError(kDummyStatus),
AssertionException,