Skip to content

Commit e39c1fe

Browse files
authored
Fix incorrect requestSize via using multiput (#17208)
1 parent 36d4243 commit e39c1fe

File tree

4 files changed

+80
-20
lines changed

4 files changed

+80
-20
lines changed

ydb/core/blobstorage/ut_blobstorage/lib/env.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,9 @@ struct TEnvironmentSetup {
10001000
return SyncQueryFactory<TResult>(actorId, [&] { return std::make_unique<TQuery>(args...); });
10011001
}
10021002

1003-
ui64 AggregateVDiskCounters(TString storagePool, ui32 nodesCount, ui32 groupSize, ui32 groupId,
1004-
const std::vector<ui32>& pdiskLayout, TString subsystem, TString counter, bool derivative = false) {
1003+
ui64 AggregateVDiskCountersBase(TString storagePool, ui32 nodesCount, ui32 groupSize, ui32 groupId,
1004+
const std::vector<ui32>& pdiskLayout, TString subsgroupName, TString subgroupValue,
1005+
TString counter, bool derivative = false) {
10051006
ui64 ctr = 0;
10061007

10071008
for (ui32 nodeId = 1; nodeId <= nodesCount; ++nodeId) {
@@ -1019,12 +1020,24 @@ struct TEnvironmentSetup {
10191020
GetSubgroup("orderNumber", orderNumber)->
10201021
GetSubgroup("pdisk", pdisk)->
10211022
GetSubgroup("media", "rot")->
1022-
GetSubgroup("subsystem", subsystem)->
1023+
GetSubgroup(subsgroupName, subgroupValue)->
10231024
GetCounter(counter, derivative)->Val();
10241025
}
10251026
}
10261027
return ctr;
1027-
};
1028+
}
1029+
1030+
ui64 AggregateVDiskCounters(TString storagePool, ui32 nodesCount, ui32 groupSize, ui32 groupId,
1031+
const std::vector<ui32>& pdiskLayout, TString subsystem, TString counter, bool derivative = false) {
1032+
return AggregateVDiskCountersBase(storagePool, nodesCount, groupSize, groupId, pdiskLayout,
1033+
"subsystem", subsystem, counter, derivative);
1034+
}
1035+
1036+
ui64 AggregateVDiskCountersWithHandleClass(TString storagePool, ui32 nodesCount, ui32 groupSize, ui32 groupId,
1037+
const std::vector<ui32>& pdiskLayout, TString handleclass, TString counter) {
1038+
return AggregateVDiskCountersBase(storagePool, nodesCount, groupSize, groupId, pdiskLayout,
1039+
"handleclass", handleclass, counter);
1040+
}
10281041

10291042
void SetIcbControl(ui32 nodeId, TString controlName, ui64 value) {
10301043
if (nodeId == 0) {

ydb/core/blobstorage/ut_blobstorage/monitoring.cpp

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,10 @@ void TestDSProxyAndVDiskEqualCost(const TBlobStorageGroupInfo::TTopology& topolo
106106
if (dsproxyCost == vdiskCost) {
107107
return;
108108
}
109+
UNIT_ASSERT(queuePut != 0);
109110
UNIT_ASSERT_C(oks != actor->RequestsSent || queuePut != queueSent, str.Str());
110111
}
111112

112-
#define MAKE_TEST(erasure, requestType, requests, inflight) \
113-
Y_UNIT_TEST(Test##requestType##erasure##Requests##requests##Inflight##inflight) { \
114-
auto groupType = TBlobStorageGroupType::Erasure##erasure; \
115-
ui32 realms = (groupType == TBlobStorageGroupType::ErasureMirror3dc) ? 3 : 1; \
116-
ui32 domains = (groupType == TBlobStorageGroupType::ErasureMirror3dc) ? 3 : 8; \
117-
TBlobStorageGroupInfo::TTopology topology(groupType, realms, domains, 1, true); \
118-
auto actor = new TInflightActor##requestType({requests, inflight}); \
119-
TestDSProxyAndVDiskEqualCost(topology, actor); \
120-
}
121-
122113
#define MAKE_TEST_W_DATASIZE(erasure, requestType, requests, inflight, dataSize) \
123114
Y_UNIT_TEST(Test##requestType##erasure##Requests##requests##Inflight##inflight##BlobSize##dataSize) { \
124115
auto groupType = TBlobStorageGroupType::Erasure##erasure; \
@@ -283,4 +274,54 @@ Y_UNIT_TEST_SUITE(DiskTimeAvailable) {
283274
}
284275
}
285276

277+
template <typename TInflightActor>
278+
void TestDSProxyAndVDiskEqualByteCounters(TInflightActor* actor) {
279+
std::unique_ptr<TEnvironmentSetup> env;
280+
ui32 groupSize;
281+
TBlobStorageGroupType groupType;
282+
ui32 groupId;
283+
std::vector<ui32> pdiskLayout;
284+
TBlobStorageGroupInfo::TTopology topology(TBlobStorageGroupType::ErasureMirror3dc, 3, 3, 1, true);
285+
SetupEnv(topology, env, groupSize, groupType, groupId, pdiskLayout);
286+
actor->SetGroupId(TGroupId::FromValue(groupId));
287+
env->Runtime->Register(actor, 1);
288+
env->Sim(TDuration::Minutes(10));
289+
ui64 dsproxyCounter = 0;
290+
ui64 vdiskCounter = 0;
291+
292+
for (ui32 nodeId = 1; nodeId <= groupSize; ++nodeId) {
293+
auto* appData = env->Runtime->GetNode(nodeId)->AppData.get();
294+
for(auto sizeClass : {"256", "4096", "262144", "1048576", "16777216", "4194304"})
295+
dsproxyCounter += GetServiceCounters(appData->Counters, "dsproxynode")->
296+
GetSubgroup("subsystem", "request")->
297+
GetSubgroup("storagePool", env->StoragePoolName)->
298+
GetSubgroup("handleClass", "PutTabletLog")->
299+
GetSubgroup("sizeClass", sizeClass)->
300+
GetCounter("generatedSubrequestBytes")->Val();
301+
}
302+
vdiskCounter = env->AggregateVDiskCountersWithHandleClass(env->StoragePoolName, groupSize, groupSize, groupId, pdiskLayout,
303+
"PutTabletLog", "requestBytes");
304+
if constexpr(VERBOSE) {
305+
for (ui32 i = 1; i <= groupSize; ++i) {
306+
Cerr << " ##################### Node " << i << " ##################### " << Endl;
307+
env->Runtime->GetNode(i)->AppData->Counters->OutputPlainText(Cerr);
308+
}
309+
}
310+
UNIT_ASSERT(dsproxyCounter != 0);
311+
UNIT_ASSERT_VALUES_EQUAL(dsproxyCounter, vdiskCounter);
312+
}
313+
314+
315+
Y_UNIT_TEST_SUITE(TestDSProxyAndVDiskEqualByteCounters) {
316+
Y_UNIT_TEST(MultiPut) {
317+
auto actor = new TInflightActorPut({10, 10}, 1000, 10);
318+
TestDSProxyAndVDiskEqualByteCounters(actor);
319+
}
320+
321+
Y_UNIT_TEST(SinglePut) {
322+
auto actor = new TInflightActorPut({1, 1}, 1000);
323+
TestDSProxyAndVDiskEqualByteCounters(actor);
324+
}
325+
}
326+
286327
#undef MAKE_BURST_TEST

ydb/core/blobstorage/ut_blobstorage/ut_helpers.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ class TInflightActor : public TActorBootstrapped<TInflightActor> {
9696

9797
class TInflightActorPut : public TInflightActor {
9898
public:
99-
TInflightActorPut(TSettings settings, ui32 dataSize = 1024)
99+
TInflightActorPut(TSettings settings, ui32 dataSize = 1024, ui32 putsInBatch = 1)
100100
: TInflightActor(settings)
101101
, DataSize(dataSize)
102+
, PutsInBatch(putsInBatch)
102103
{}
103104

104105
STRICT_STFUNC(StateWork,
@@ -116,10 +117,12 @@ class TInflightActorPut : public TInflightActor {
116117

117118
protected:
118119
void SendRequest() override {
119-
TString data = MakeData(DataSize);
120-
auto ev = new TEvBlobStorage::TEvPut(TLogoBlobID(1, 1, 1, 10, DataSize, Cookie++),
121-
data, TInstant::Max(), NKikimrBlobStorage::UserData);
122-
SendToBSProxy(SelfId(), GroupId, ev, 0);
120+
for (ui32 i = 0; i < PutsInBatch; ++i) {
121+
TString data = MakeData(DataSize);
122+
auto ev = new TEvBlobStorage::TEvPut(TLogoBlobID(1, 1, 1, 10, DataSize, Cookie++),
123+
data, TInstant::Max(), NKikimrBlobStorage::TabletLog);
124+
SendToBSProxy(SelfId(), GroupId, ev, 0);
125+
}
123126
}
124127

125128
void Handle(TEvBlobStorage::TEvPutResult::TPtr res) {
@@ -129,6 +132,7 @@ class TInflightActorPut : public TInflightActor {
129132
private:
130133
std::string Data;
131134
ui32 DataSize;
135+
ui32 PutsInBatch;
132136
};
133137

134138
/////////////////////////////////// TInflightActorGet ///////////////////////////////////

ydb/core/blobstorage/vdisk/skeleton/skeleton_vmultiput_actor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ namespace NKikimr {
8282
}
8383

8484
TInstant now = TAppData::TimeProvider->Now();
85+
auto handleClass = Event->Get()->Record.GetHandleClass();
86+
const NVDiskMon::TLtcHistoPtr &histoPtr = VCtx->Histograms.GetHistogram(handleClass);
8587
const ui64 bufferSizeBytes = Event->Get()->GetBufferBytes();
8688
auto vMultiPutResult = std::make_unique<TEvBlobStorage::TEvVMultiPutResult>(NKikimrProto::OK, vdisk, cookie,
8789
now, Event->Get()->GetCachedByteSize(), &vMultiPutRecord, SkeletonFrontIDPtr, MultiPutResMsgsPtr,
88-
nullptr, bufferSizeBytes, IncarnationGuid, TString());
90+
histoPtr, bufferSizeBytes, IncarnationGuid, TString());
8991

9092
for (ui64 idx = 0; idx < Items.size(); ++idx) {
9193
TItem &result = Items[idx];

0 commit comments

Comments
 (0)