diff options
author | zalyalov <zalyalov@yandex-team.com> | 2023-05-19 16:02:30 +0300 |
---|---|---|
committer | zalyalov <zalyalov@yandex-team.com> | 2023-05-19 16:02:30 +0300 |
commit | 053e8c7c62846fdf05989d360f7ff25ad203a5c9 (patch) | |
tree | c4cf9484aa7bebd7d001642fae650bc9d6618aa5 | |
parent | efd64e4742f72120932dbe9aca8837dcf1759f51 (diff) | |
download | ydb-053e8c7c62846fdf05989d360f7ff25ad203a5c9.tar.gz |
fix group usage when changing channel params via CreateTablet
The old version updated channel binding info before releasing the AU. If the storage pool was changed, this led to the old storage pool retaining outdated resource values. If the storage pool remained the same, this led to incorrect value being subtracted from storage group's resources, and potentially to underflow.
-rw-r--r-- | ydb/core/mind/hive/hive_ut.cpp | 41 | ||||
-rw-r--r-- | ydb/core/mind/hive/tx__create_tablet.cpp | 1 | ||||
-rw-r--r-- | ydb/core/mind/hive/tx__update_tablet_groups.cpp | 2 |
3 files changed, 43 insertions, 1 deletions
diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index 884c0e1a754..4cffec5b525 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -1937,6 +1937,47 @@ Y_UNIT_TEST_SUITE(THiveTest) { } } + Y_UNIT_TEST(TestUpdateChannelValues) { + TTestBasicRuntime runtime(1, false); + Setup(runtime, true, 2); + + const ui64 hiveTablet = MakeDefaultHiveID(0); + const ui64 testerTablet = MakeDefaultHiveID(1); + const TActorId sender = runtime.AllocateEdgeActor(); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + CreateLocal(runtime, 0); + + TTabletTypes::EType tabletType = TTabletTypes::Dummy; + TChannelsBindings channels = BINDED_CHANNELS; + for (auto& bind : channels) { + bind.SetSize(1000); + } + TAutoPtr<TEvHive::TEvCreateTablet> createTablet(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, channels)); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, createTablet, 0, true); + + MakeSureTabletIsUp(runtime, tabletId, 0); + + for (auto& bind : channels) { + bind.SetSize(1001); + } + channels[0].SetStoragePoolName("def2"); + channels[1].SetStoragePoolName("def1"); + TAutoPtr<TEvHive::TEvCreateTablet> updateTablet(new TEvHive::TEvCreateTablet(testerTablet, 0, tabletType, channels)); + tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, updateTablet, 0, true); + + runtime.SendToPipe(hiveTablet, sender, new TEvHive::TEvRequestHiveStorageStats()); + TAutoPtr<IEventHandle> handle; + TEvHive::TEvResponseHiveStorageStats* storageStats = runtime.GrabEdgeEventRethrow<TEvHive::TEvResponseHiveStorageStats>(handle); + + for (const auto& pool : storageStats->Record.GetPools()) { + for (const auto& group : pool.GetGroups()) { + if (group.GetAcquiredSize() != 0) { + UNIT_ASSERT_VALUES_EQUAL(group.GetAcquiredSize(), 1001); + } + } + } + } + Y_UNIT_TEST(TestDeleteTablet) { TTestBasicRuntime runtime(1, false); Setup(runtime, true); diff --git a/ydb/core/mind/hive/tx__create_tablet.cpp b/ydb/core/mind/hive/tx__create_tablet.cpp index 426acd37f39..f38fde5e058 100644 --- a/ydb/core/mind/hive/tx__create_tablet.cpp +++ b/ydb/core/mind/hive/tx__create_tablet.cpp @@ -117,6 +117,7 @@ public: db.Table<Schema::TabletChannel>().Key(TabletId, channelId).Update<Schema::TabletChannel::Binding>(BoundChannels[channelId]); db.Table<Schema::TabletChannel>().Key(TabletId, channelId).Update<Schema::TabletChannel::NeedNewGroup>(true); newChannels.set(channelId); + tablet.ReleaseAllocationUnit(channelId); } } diff --git a/ydb/core/mind/hive/tx__update_tablet_groups.cpp b/ydb/core/mind/hive/tx__update_tablet_groups.cpp index abf42449848..36cb03f20b6 100644 --- a/ydb/core/mind/hive/tx__update_tablet_groups.cpp +++ b/ydb/core/mind/hive/tx__update_tablet_groups.cpp @@ -136,7 +136,7 @@ public: channel = &tabletChannels[channelId]; Y_VERIFY(channel->Channel == channelId); if (!tablet->ReleaseAllocationUnit(channelId)) { - BLOG_ERROR("Failed to release AU for tablet " << tablet->Id << " channel " << channelId); + BLOG_W("Failed to release AU for tablet " << tablet->Id << " channel " << channelId); } } else { // increasing number of tablet channels |