Skip to content

Commit

Permalink
Merge to stable-23-3 (#864)
Browse files Browse the repository at this point in the history
* [Blockstore] output WriteAndZeroRequestsInProgress on partition mon-page (#847)

* [Blockstore] verify that GroupRequests does not forget requests (#846)

* issue-122: AddConfirmedBlobs should do ProcessCommitQueue, otherwise compaction may get stuck (#863)
  • Loading branch information
SvartMetal authored Mar 31, 2024
1 parent 6d982c9 commit 38b655c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cloud/blockstore/libs/storage/core/write_buffer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,27 @@ namespace NCloud::NBlockStore::NStorage {

using TRequest = TRequestInBuffer<TWriteBufferRequestData>;

namespace {

////////////////////////////////////////////////////////////////////////////////

ui32 CalculateRequestCount(
const TRequestGrouping& g,
const TVector<TRequest>& requests)
{
ui32 groupedRequestCount = 0;
for (const auto& group: g.Groups) {
groupedRequestCount += group.Requests.size();
}

ui32 ungroupedRequestCount = requests.end() - g.FirstUngrouped;
return groupedRequestCount + ungroupedRequestCount;
}

} // namespace

TRequestGrouping GroupRequests(
TVector<TRequestInBuffer<TWriteBufferRequestData>>& requests,
TVector<TRequest>& requests,
ui32 totalWeight,
ui32 minWeight,
ui32 maxWeight,
Expand Down Expand Up @@ -146,6 +165,8 @@ TRequestGrouping GroupRequests(
}
}

Y_DEBUG_ABORT_UNLESS(requests.size() == CalculateRequestCount(g, requests));

return g;
}

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ void TPartitionActor::HandleHttpInfo_Default(
TABLED() { out << "Executor Reject Probability"; }
TABLED() { out << Executor()->GetRejectProbability(); }
}
TABLER() {
TABLED() { out << "Write and zero requests in progress"; }
TABLED() { out << WriteAndZeroRequestsInProgress; }
}
}
}
}
Expand Down
50 changes: 50 additions & 0 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

0 comments on commit 38b655c

Please sign in to comment.