Skip to content

Commit

Permalink
issue-122: AddConfirmedBlobs should do ProcessCommitQueue, otherwise …
Browse files Browse the repository at this point in the history
…compaction may get stuck (#863)
  • Loading branch information
SvartMetal authored Mar 30, 2024
1 parent fd6bbe9 commit b1d617a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ void TPartitionActor::HandleAddConfirmedBlobsCompleted(
PartCounters->RequestCounters.AddConfirmedBlobs.AddRequest(time);

EnqueueAddConfirmedBlobsIfNeeded(ctx);
ProcessCommitQueue(ctx);
}

} // namespace NCloud::NBlockStore::NStorage::NPartition
54 changes: 52 additions & 2 deletions cloud/blockstore/libs/storage/partition/part_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9666,6 +9666,56 @@ Y_UNIT_TEST_SUITE(TPartitionTest)
}
}

Y_UNIT_TEST(ShouldCompactAfterAddingConfirmedBlobs)
{
auto config = DefaultConfig();
config.SetAddingUnconfirmedBlobsEnabled(true);
auto runtime = PrepareTestActorRuntime(config);

TPartitionClient partition(*runtime);
partition.WaitReady();

partition.WriteBlocks(TBlockRange32::WithLength(0, 1024), 1);

TAutoPtr<IEventHandle> addConfirmedBlobs;
bool interceptAddConfirmedBlobs = true;

runtime->SetEventFilter(
[&] (TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& event)
{
switch (event->GetTypeRewrite()) {
case TEvPartitionPrivate::EvAddConfirmedBlobsRequest: {
if (interceptAddConfirmedBlobs) {
UNIT_ASSERT(!addConfirmedBlobs);
addConfirmedBlobs = event.Release();
return true;
}
break;
}
}

return false;
}
);

partition.WriteBlocks(TBlockRange32::WithLength(0, 1024), 2);
UNIT_ASSERT(addConfirmedBlobs);

partition.SendCompactionRequest();
// wait for compaction to be queued
runtime->DispatchEvents(TDispatchOptions(), TDuration::Seconds(1));

interceptAddConfirmedBlobs = false;
runtime->Send(addConfirmedBlobs.Release());

{
auto compactResponse = partition.RecvCompactionResponse();
// should fail on S_ALREADY and S_FALSE to ensure that compaction
// was really taken place here
UNIT_ASSERT_VALUES_EQUAL(S_OK, compactResponse->GetStatus());
}
}

Y_UNIT_TEST(ShouldConfirmBlobs)
{
auto config = DefaultConfig();
Expand Down Expand Up @@ -10774,7 +10824,7 @@ Y_UNIT_TEST_SUITE(TPartitionTest)
response->GetStatus(),
response->GetErrorReason());
}

Y_UNIT_TEST(ShouldProperlyCalculateBlockChecksumsForBatchedWrites)
{
constexpr ui32 blockCount = 1024 * 1024;
Expand Down Expand Up @@ -10895,7 +10945,7 @@ Y_UNIT_TEST_SUITE(TPartitionTest)
response->GetErrorReason());
}
}

Y_UNIT_TEST(ShouldCancelRequestsOnTabletRestart)
{
constexpr ui32 blockCount = 1024 * 1024;
Expand Down

0 comments on commit b1d617a

Please sign in to comment.