From c67f1bf8e1383d2e2340e52bd7bb3d2b672ada75 Mon Sep 17 00:00:00 2001 From: Andrei Strelkovskii Date: Thu, 19 Dec 2024 15:59:10 +0100 Subject: [PATCH] issue-2559: initializing BlockSize + added comments to ut (#2736) --- .../libs/storage/service/service_ut_sharding.cpp | 15 +++++++++++++++ .../libs/storage/tablet/model/shard_balancer.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cloud/filestore/libs/storage/service/service_ut_sharding.cpp b/cloud/filestore/libs/storage/service/service_ut_sharding.cpp index 098c907e9cb..cd8cd0893cd 100644 --- a/cloud/filestore/libs/storage/service/service_ut_sharding.cpp +++ b/cloud/filestore/libs/storage/service/service_ut_sharding.cpp @@ -4061,6 +4061,10 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest) auto headers = service.InitSession(fsId, "client"); + // creating 5 files - we should have round-robin balancing at this + // point since all shards have enough free space - more than the + // DesiredFreeSpaceReserve threshold + TVector handles; TVector nodes; TSet shards; @@ -4080,8 +4084,13 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest) handles.push_back(handleId); } + // checking that we indeed created those 5 files in 5 shards + UNIT_ASSERT_VALUES_EQUAL(5, shards.size()); + // writing some data to 3 of the 5 files to make 3 of the 5 shards have + // less than DesiredFreeSpaceReserve free space + service.WriteData( headers, fsId, @@ -4121,6 +4130,10 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest) nodes.clear(); shards.clear(); + // creating 5 new files - these files should be balanced among the + // 2 remaining shards which still have more than DesiredFreeSpaceReserve + // free space + for (ui32 i = 0; i < 5; ++i) { auto createHandleResponse = service.CreateHandle( headers, @@ -4137,6 +4150,8 @@ Y_UNIT_TEST_SUITE(TStorageServiceShardingTest) handles.push_back(handleId); } + // checking that the new 5 files were indeed created in those 2 shards + UNIT_ASSERT_VALUES_EQUAL(2, shards.size()); auto l = emptyShards.begin(); auto r = shards.begin(); diff --git a/cloud/filestore/libs/storage/tablet/model/shard_balancer.h b/cloud/filestore/libs/storage/tablet/model/shard_balancer.h index f9ffe3240c2..e67f110eb09 100644 --- a/cloud/filestore/libs/storage/tablet/model/shard_balancer.h +++ b/cloud/filestore/libs/storage/tablet/model/shard_balancer.h @@ -36,7 +36,7 @@ class TShardBalancer }; private: - ui32 BlockSize; + ui32 BlockSize = 4_KB; ui64 DesiredFreeSpaceReserve = 0; ui64 MinFreeSpaceReserve = 0;