Skip to content

Commit 56c8c75

Browse files
committed
Handle empty GC commands correctly (#6398)
1 parent 979d449 commit 56c8c75

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <ydb/core/blobstorage/ut_blobstorage/lib/env.h>
2+
3+
Y_UNIT_TEST_SUITE(GarbageCollection) {
4+
Y_UNIT_TEST(EmptyGcCmd) {
5+
TEnvironmentSetup env({
6+
.Erasure = TBlobStorageGroupType::Erasure4Plus2Block,
7+
});
8+
auto& runtime = env.Runtime;
9+
10+
env.CreateBoxAndPool(1, 1);
11+
auto info = env.GetGroupInfo(env.GetGroups().front());
12+
13+
auto ev = std::make_unique<TEvBlobStorage::TEvCollectGarbage>(1u, 1u, 1u, 0u, false, 0u, 0u, nullptr, nullptr,
14+
TInstant::Max(), true);
15+
const TActorId edge = runtime->AllocateEdgeActor(1, __FILE__, __LINE__);
16+
runtime->WrapInActorContext(edge, [&] {
17+
SendToBSProxy(edge, info->GroupID, ev.release());
18+
});
19+
auto res = env.WaitForEdgeActorEvent<TEvBlobStorage::TEvCollectGarbageResult>(edge);
20+
UNIT_ASSERT_VALUES_EQUAL(res->Get()->Status, NKikimrProto::ERROR);
21+
}
22+
}

ydb/core/blobstorage/ut_blobstorage/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SRCS(
1919
defrag.cpp
2020
encryption.cpp
2121
extra_block_checks.cpp
22+
gc.cpp
2223
gc_quorum_3dc.cpp
2324
group_reconfiguration.cpp
2425
incorrect_queries.cpp

ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ namespace NKikimr {
415415
if (!CheckGC(ctx, record))
416416
return {NKikimrProto::ERROR, 0, false}; // record has duplicates
417417

418+
if (!collect && !record.KeepSize() && !record.DoNotKeepSize()) {
419+
LOG_ERROR_S(ctx, NKikimrServices::BS_HULLRECS, HullDs->HullCtx->VCtx->VDiskLogPrefix
420+
<< "Db# Barriers ValidateGCCmd: empty garbage collection command"
421+
<< " TabletId# " << tabletID);
422+
return {NKikimrProto::ERROR, "empty garbage collection command"};
423+
}
424+
418425
auto blockStatus = THullDbRecovery::IsBlocked(record);
419426
switch (blockStatus.Status) {
420427
case TBlocksCache::EStatus::OK:

0 commit comments

Comments
 (0)