summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@vespa.ai>2023-10-30 14:20:20 +0000
committerTor Brede Vekterli <vekterli@vespa.ai>2023-11-01 15:36:56 +0000
commit6567a48a55f05f2f20c0cc7ae63dc454319c87e1 (patch)
tree81f292dd2c7f3fe9f6d5604bf5de7cca1184f057 /storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp
parentb04b6184f8d8fe0b9d569caf6ed46c69312c1821 (diff)
Add content node soft limit on max memory used by merges
If configured, the active merge window is limited so that the sum of estimated memory usage for its merges does not go beyond the configured soft memory limit. The window can always fit a minimum of 1 merge regardless of its size to ensure progress in the cluster (thus this is a soft limit, not a hard limit).
Diffstat (limited to 'storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp')
-rw-r--r--storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp b/storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp
index addc80e4150..698d8dee573 100644
--- a/storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp
+++ b/storage/src/tests/storageapi/mbusprot/storageprotocoltest.cpp
@@ -79,7 +79,7 @@ struct StorageProtocolTest : TestWithParam<vespalib::Version> {
_protocol(_docMan.getTypeRepoSP())
{
}
- ~StorageProtocolTest();
+ ~StorageProtocolTest() override;
void set_dummy_bucket_info_reply_fields(BucketInfoReply& reply) {
reply.setBucketInfo(_dummy_bucket_info);
@@ -456,18 +456,12 @@ TEST_P(StorageProtocolTest, delete_bucket) {
TEST_P(StorageProtocolTest, merge_bucket) {
using Node = api::MergeBucketCommand::Node;
- std::vector<Node> nodes;
- nodes.push_back(Node(4, false));
- nodes.push_back(Node(13, true));
- nodes.push_back(Node(26, true));
-
- std::vector<uint16_t> chain;
- // Not a valid chain wrt. the nodes, but just want to have unique values
- chain.push_back(7);
- chain.push_back(14);
+ std::vector<Node> nodes = {{4, false}, {13, true}, {26, true}};
+ std::vector<uint16_t> chain = {7, 14}; // Not a valid chain wrt. the nodes, but just want to have unique values
auto cmd = std::make_shared<MergeBucketCommand>(_bucket, nodes, Timestamp(1234), 567, chain);
cmd->set_use_unordered_forwarding(true);
+ cmd->set_estimated_memory_footprint(123'456'789);
auto cmd2 = copyCommand(cmd);
EXPECT_EQ(_bucket, cmd2->getBucket());
EXPECT_EQ(nodes, cmd2->getNodes());
@@ -475,6 +469,7 @@ TEST_P(StorageProtocolTest, merge_bucket) {
EXPECT_EQ(uint32_t(567), cmd2->getClusterStateVersion());
EXPECT_EQ(chain, cmd2->getChain());
EXPECT_EQ(cmd2->use_unordered_forwarding(), cmd->use_unordered_forwarding());
+ EXPECT_EQ(cmd2->estimated_memory_footprint(), 123'456'789);
auto reply = std::make_shared<MergeBucketReply>(*cmd);
auto reply2 = copyReply(reply);
@@ -485,6 +480,17 @@ TEST_P(StorageProtocolTest, merge_bucket) {
EXPECT_EQ(chain, reply2->getChain());
}
+TEST_P(StorageProtocolTest, merge_bucket_estimated_memory_footprint_is_zero_by_default) {
+ using Node = api::MergeBucketCommand::Node;
+ std::vector<Node> nodes = {{4, false}, {13, true}, {26, true}};
+ std::vector<uint16_t> chain = {7, 14};
+
+ auto cmd = std::make_shared<MergeBucketCommand>(_bucket, nodes, Timestamp(1234), 567, chain);
+ cmd->set_use_unordered_forwarding(true);
+ auto cmd2 = copyCommand(cmd);
+ EXPECT_EQ(cmd2->estimated_memory_footprint(), 0);
+}
+
TEST_P(StorageProtocolTest, split_bucket) {
auto cmd = std::make_shared<SplitBucketCommand>(_bucket);
EXPECT_EQ(0u, cmd->getMinSplitBits());