summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2018-10-11 12:14:10 -0400
committerJack Mulrow <jack.mulrow@mongodb.com>2018-10-12 14:29:03 -0400
commitefd0d5bd565b5edba222057da24287d08c19056e (patch)
treec98755abf3d416b46f4db84616ca3eb6936facf5
parent47498446e41980899fe43fced08b0f8f7e27e870 (diff)
downloadmongo-efd0d5bd565b5edba222057da24287d08c19056e.tar.gz
SERVER-37568 computeAtClusterTimeForOneShard should always return the latest logical clock time
-rw-r--r--src/mongo/s/at_cluster_time_util.cpp19
-rw-r--r--src/mongo/s/compute_at_cluster_time_test.cpp18
2 files changed, 13 insertions, 24 deletions
diff --git a/src/mongo/s/at_cluster_time_util.cpp b/src/mongo/s/at_cluster_time_util.cpp
index 1ace3e9dc40..3a44e50923d 100644
--- a/src/mongo/s/at_cluster_time_util.cpp
+++ b/src/mongo/s/at_cluster_time_util.cpp
@@ -49,7 +49,8 @@ LogicalTime _computeAtClusterTime(OperationContext* opCtx,
const NamespaceString& nss,
const BSONObj query,
const BSONObj collation) {
- // TODO: SERVER-31767
+ // 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.
return LogicalClock::get(opCtx)->getClusterTime();
}
} // namespace
@@ -122,19 +123,9 @@ boost::optional<LogicalTime> computeAtClusterTimeForOneShard(OperationContext* o
return boost::none;
}
- auto shardRegistry = Grid::get(opCtx)->shardRegistry();
- invariant(shardRegistry);
-
- auto shard = shardRegistry->getShardNoReload(shardId);
- uassert(ErrorCodes::ShardNotFound, str::stream() << "Could not find shard " << shardId, shard);
-
- // Return the cached last committed opTime for the shard if there is one, otherwise return the
- // latest cluster time from the logical clock.
- auto lastCommittedOpTime = shard->getLastCommittedOpTime();
-
- auto atClusterTime = lastCommittedOpTime != LogicalTime::kUninitialized
- ? lastCommittedOpTime
- : LogicalClock::get(opCtx)->getClusterTime();
+ // 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 atClusterTime = LogicalClock::get(opCtx)->getClusterTime();
// If the user passed afterClusterTime, atClusterTime must be greater than or equal to it.
const auto afterClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAfterClusterTime();
diff --git a/src/mongo/s/compute_at_cluster_time_test.cpp b/src/mongo/s/compute_at_cluster_time_test.cpp
index 088ad79da2c..be93abf9103 100644
--- a/src/mongo/s/compute_at_cluster_time_test.cpp
+++ b/src/mongo/s/compute_at_cluster_time_test.cpp
@@ -91,7 +91,7 @@ TEST_F(AtClusterTimeTest, ComputeValidValid) {
auto maxTime = at_cluster_time_util::computeAtClusterTime(
operationContext(), true, {shardOneId, shardTwoId}, kNss, kEmptyQuery, kEmptyCollation);
- // TODO: SERVER-31767
+ // TODO: SERVER-36312
// ASSERT_EQ(*maxTime, timeTwo);
ASSERT_EQ(*maxTime, kInMemoryLogicalTime);
}
@@ -107,7 +107,7 @@ TEST_F(AtClusterTimeTest, ComputeValidInvalid) {
auto maxTime = at_cluster_time_util::computeAtClusterTime(
operationContext(), true, {shardOneId, shardTwoId}, kNss, kEmptyQuery, kEmptyCollation);
- // TODO: SERVER-31767
+ // TODO: SERVER-36312
// ASSERT_EQ(*maxTime, timeTwo);
ASSERT_EQ(*maxTime, kInMemoryLogicalTime);
}
@@ -133,7 +133,9 @@ TEST_F(AtClusterTimeTest, ComputeForOneShard) {
auto atClusterTime =
at_cluster_time_util::computeAtClusterTimeForOneShard(operationContext(), shardOneId);
- ASSERT_EQ(*atClusterTime, timeOne);
+ // TODO SERVER-36312
+ // ASSERT_EQ(*atClusterTime, timeOne);
+ ASSERT_EQ(*atClusterTime, kInMemoryLogicalTime);
}
TEST_F(AtClusterTimeTest, ComputeForOneShardNoCachedOpTime) {
@@ -145,12 +147,8 @@ TEST_F(AtClusterTimeTest, ComputeForOneShardNoCachedOpTime) {
ASSERT_EQ(*atClusterTime, kInMemoryLogicalTime);
}
-TEST_F(AtClusterTimeTest, ComputeForOneShardNoShard) {
- ASSERT_THROWS_CODE(at_cluster_time_util::computeAtClusterTimeForOneShard(operationContext(),
- ShardId("fakeShard")),
- AssertionException,
- ErrorCodes::ShardNotFound);
-}
+// TODO SERVER-36312: Verify computing atClusterTime for a single shard that does not exist returns
+// an error.
class AtClusterTimeTargetingTest : public CatalogCacheTestFixture {
protected:
@@ -203,7 +201,7 @@ TEST_F(AtClusterTimeTargetingTest, ReturnsLatestTimeFromShard) {
repl::ReadConcernArgs::get(operationContext()) =
repl::ReadConcernArgs(repl::ReadConcernLevel::kSnapshotReadConcern);
- // TODO: SERVER-31767
+ // TODO: SERVER-36312
// ASSERT_EQ(time2,
// *at_cluster_time_util::computeAtClusterTime(operationContext(), true, shards, kNss,
// query, collation));