summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/distributor/getoperationtest.cpp
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2020-01-17 09:53:05 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2020-01-17 10:02:20 +0000
commit72cec61c615bfe25628c375eade4c8d8832cd2da (patch)
treeb0cf200520cc40a9e42ffb874b712d02c910ef32 /storage/src/tests/distributor/getoperationtest.cpp
parentb9b0cf87f7335fed7af9854a2f1a63617c29451a (diff)
Add configurable support for weakly consistent client Gets
If configured, Get operations initiated by the client are flagged with weak internal consistency. This allows the backend to bypass certain internal synchronization mechanisms, which minimizes latency at the cost of possibly not observing a consistent view of the document. This config should only be used in a very restricted set of cases where the document set is effectively read-only, or cross- field consistency or freshness does not matter. To enable the weak consistency, use an explicit config override: ``` <config name="vespa.config.content.core.stor-distributormanager"> <use_weak_internal_read_consistency_for_client_gets> true </use_weak_internal_read_consistency_for_client_gets> </config> ``` This closes #11811
Diffstat (limited to 'storage/src/tests/distributor/getoperationtest.cpp')
-rw-r--r--storage/src/tests/distributor/getoperationtest.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp
index db790639869..0dbec8444cc 100644
--- a/storage/src/tests/distributor/getoperationtest.cpp
+++ b/storage/src/tests/distributor/getoperationtest.cpp
@@ -51,12 +51,13 @@ struct GetOperationTest : Test, DistributorTestUtil {
op.reset();
}
- void sendGet() {
+ void sendGet(api::InternalReadConsistency consistency = api::InternalReadConsistency::Strong) {
auto msg = std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId(0)), docId, "[all]");
op = std::make_unique<GetOperation>(
getExternalOperationHandler(), getDistributorBucketSpace(),
getDistributorBucketSpace().getBucketDatabase().acquire_read_guard(),
- msg, getDistributor().getMetrics(). gets[msg->getLoadType()]);
+ msg, getDistributor().getMetrics(). gets[msg->getLoadType()],
+ consistency);
op->start(_sender, framework::MilliSecTime(0));
}
@@ -127,6 +128,8 @@ struct GetOperationTest : Test, DistributorTestUtil {
void setClusterState(const std::string& clusterState) {
enableDistributorClusterState(clusterState);
}
+
+ void do_test_read_consistency_is_propagated(api::InternalReadConsistency consistency);
};
GetOperationTest::GetOperationTest() = default;
@@ -497,4 +500,23 @@ TEST_F(GetOperationTest, can_get_documents_when_all_replica_nodes_retired) {
EXPECT_EQ("Get => 0", _sender.getCommands(true));
}
+void GetOperationTest::do_test_read_consistency_is_propagated(api::InternalReadConsistency consistency) {
+ setClusterState("distributor:1 storage:1");
+ addNodesToBucketDB(bucketId, "0=4");
+ sendGet(consistency);
+ ASSERT_TRUE(op);
+ EXPECT_EQ(dynamic_cast<GetOperation&>(*op).desired_read_consistency(), consistency);
+ ASSERT_EQ("Get => 0", _sender.getCommands(true));
+ auto& cmd = dynamic_cast<const api::GetCommand&>(*_sender.command(0));
+ EXPECT_EQ(cmd.internal_read_consistency(), consistency);
+}
+
+TEST_F(GetOperationTest, can_send_gets_with_strong_internal_read_consistency) {
+ do_test_read_consistency_is_propagated(api::InternalReadConsistency::Strong);
+}
+
+TEST_F(GetOperationTest, can_send_gets_with_weak_internal_read_consistency) {
+ do_test_read_consistency_is_propagated(api::InternalReadConsistency::Weak);
+}
+
}