Skip to content

Commit 13a335a

Browse files
kruallydbot
authored andcommitted
Fix alter volume in keyvalue api (#29615)
1 parent 8fd50d8 commit 13a335a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

ydb/core/grpc_services/rpc_keyvalue.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,9 @@ class TAlterVolumeRequest
633633
modifyScheme->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpAlterSolomonVolume);
634634
tableDesc = modifyScheme->MutableAlterSolomonVolume();
635635
tableDesc->SetName(name);
636-
tableDesc->SetPartitionCount(req->alter_partition_count());
636+
if (req->alter_partition_count()) {
637+
tableDesc->SetPartitionCount(req->alter_partition_count());
638+
}
637639

638640
if (GetProtoRequest()->has_storage_config()) {
639641
tableDesc->SetUpdateChannelsBinding(true);

ydb/core/tx/schemeshard/schemeshard__operation_alter_solomon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class TAlterSolomon: public TSubOperation {
243243
return result;
244244
}
245245

246-
if (alter.GetPartitionCount() == solomon->Partitions.size()) {
246+
if (alter.GetPartitionCount() == solomon->Partitions.size() && !alter.HasStorageConfig()) {
247247
result->SetError(NKikimrScheme::StatusSuccess, "solomon volume has already the same shards as requested");
248248
return result;
249249
}

ydb/services/keyvalue/grpc_service_ut.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,16 @@ Y_UNIT_TEST_SUITE(KeyValueGRPCService) {
809809
UNIT_ASSERT_VALUES_EQUAL(channel.media(), "ssd");
810810
}
811811
812-
AlterVolume(channel, tablePath, 3, describeVolumeResult.storage_config());
812+
ui32 currentChannelCount = describeVolumeResult.storage_config().channel_size();
813+
Ydb::KeyValue::StorageConfig storageConfig = describeVolumeResult.storage_config();
814+
auto newChannel = storageConfig.add_channel();
815+
newChannel->set_media("ssd");
816+
817+
AlterVolume(channel, tablePath, 2, storageConfig);
813818
describeVolumeResult = DescribeVolume(channel, tablePath);
814-
UNIT_ASSERT_VALUES_EQUAL(3, describeVolumeResult.partition_count());
819+
UNIT_ASSERT_VALUES_EQUAL(2, describeVolumeResult.partition_count());
815820
UNIT_ASSERT(describeVolumeResult.has_storage_config());
816-
UNIT_ASSERT_VALUES_EQUAL(describeVolumeResult.storage_config().channel_size(), 3);
821+
UNIT_ASSERT_VALUES_EQUAL(describeVolumeResult.storage_config().channel_size(), currentChannelCount + 1);
817822
for (const auto& channel : describeVolumeResult.storage_config().channel()) {
818823
UNIT_ASSERT_VALUES_EQUAL(channel.media(), "ssd");
819824
}

0 commit comments

Comments
 (0)