Skip to content

Commit 59764bd

Browse files
committed
Log improvements for TVolumeProxyActor
1 parent 7318875 commit 59764bd

File tree

8 files changed

+224
-144
lines changed

8 files changed

+224
-144
lines changed

cloud/blockstore/libs/storage/init/server/actorsystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class TStorageServicesInitializer final
171171

172172
auto volumeProxy = CreateVolumeProxy(
173173
Args.StorageConfig,
174-
Args.TraceSerializer);
174+
Args.TraceSerializer,
175+
Args.TemporaryServer);
175176

176177
setup->LocalServices.emplace_back(
177178
MakeVolumeProxyServiceId(),

cloud/blockstore/libs/storage/model/log_title.cpp

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ TLogTitle::TLogTitle(
6868
Rebuild();
6969
}
7070

71+
TLogTitle::TLogTitle(TString diskId, bool temporaryServer, ui64 startTime)
72+
: Type(EType::Proxy)
73+
, StartTime(startTime)
74+
, TemporaryServer(temporaryServer)
75+
, DiskId(std::move(diskId))
76+
{
77+
Rebuild();
78+
}
79+
7180
// static
7281
TString TLogTitle::GetPartitionPrefix(
7382
ui64 tabletId,
@@ -140,12 +149,6 @@ void TLogTitle::SetTabletId(ui64 tabletId)
140149
Rebuild();
141150
}
142151

143-
void TLogTitle::SetPipeGeneration(ui32 pipeGeneration)
144-
{
145-
PipeGeneration = pipeGeneration;
146-
Rebuild();
147-
}
148-
149152
void TLogTitle::Rebuild()
150153
{
151154
switch (Type) {
@@ -165,6 +168,10 @@ void TLogTitle::Rebuild()
165168
RebuildForClient();
166169
break;
167170
}
171+
case EType::Proxy: {
172+
RebuildForProxy();
173+
break;
174+
}
168175
}
169176
}
170177

@@ -249,12 +256,32 @@ void TLogTitle::RebuildForClient()
249256
builder << " c:" << ClientId;
250257

251258
builder << " pg:";
252-
if (PipeGeneration) {
253-
builder << PipeGeneration;
259+
if (Generation) {
260+
builder << Generation;
254261
} else {
255262
builder << "?";
256263
}
257264
CachedPrefix = builder;
258265
}
259266

267+
void TLogTitle::RebuildForProxy()
268+
{
269+
auto builder = TStringBuilder();
270+
271+
builder << "[";
272+
if (TemporaryServer) {
273+
builder << "~";
274+
}
275+
builder << "vp:";
276+
if (TabletId) {
277+
builder << TabletId;
278+
} else {
279+
builder << "?";
280+
}
281+
builder << " d:" << DiskId;
282+
builder << " pg:" << Generation;
283+
284+
CachedPrefix = builder;
285+
}
286+
260287
} // namespace NCloud::NBlockStore::NStorage

cloud/blockstore/libs/storage/model/log_title.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TLogTitle
2424
Partition,
2525
Session,
2626
Client,
27+
Proxy,
2728
};
2829

2930
private:
@@ -36,8 +37,7 @@ class TLogTitle
3637
const bool TemporaryServer = false;
3738

3839
ui64 TabletId = 0;
39-
ui64 Generation = 0;
40-
ui32 PipeGeneration = 0;
40+
ui32 Generation = 0;
4141
TString DiskId;
4242
TString CachedPrefix;
4343

@@ -70,6 +70,9 @@ class TLogTitle
7070
bool temporaryServer,
7171
ui64 startTime);
7272

73+
// Constructor for VolumeProxy
74+
TLogTitle(TString diskId, bool temporaryServer, ui64 startTime);
75+
7376
static TString
7477
GetPartitionPrefix(ui64 tabletId, ui32 partitionIndex, ui32 partitionCount);
7578

@@ -82,14 +85,14 @@ class TLogTitle
8285
void SetDiskId(TString diskId);
8386
void SetGeneration(ui32 generation);
8487
void SetTabletId(ui64 tabletId);
85-
void SetPipeGeneration(ui32 pipeGeneration);
8688

8789
private:
8890
void Rebuild();
8991
void RebuildForVolume();
9092
void RebuildForPartition();
9193
void RebuildForSession();
9294
void RebuildForClient();
95+
void RebuildForProxy();
9396
TString GetPartitionPrefix() const;
9497
};
9598

cloud/blockstore/libs/storage/model/log_title_ut.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TLogTitleTest)
146146
"[vc:12345 d:disk1 s:session-1 c:client-1 pg:?]",
147147
logTitle.Get(TLogTitle::EDetails::Brief));
148148

149-
logTitle.SetPipeGeneration(1);
149+
logTitle.SetGeneration(1);
150150
UNIT_ASSERT_STRINGS_EQUAL(
151151
"[vc:12345 d:disk1 s:session-1 c:client-1 pg:1]",
152152
logTitle.Get(TLogTitle::EDetails::Brief));
@@ -167,6 +167,30 @@ Y_UNIT_TEST_SUITE(TLogTitleTest)
167167
temporayLogTitle.Get(TLogTitle::EDetails::Brief));
168168
}
169169

170+
Y_UNIT_TEST(GetForProxy)
171+
{
172+
TLogTitle logTitle("disk1", false, GetCycleCount());
173+
174+
UNIT_ASSERT_STRINGS_EQUAL(
175+
"[vp:? d:disk1 pg:0]",
176+
logTitle.Get(TLogTitle::EDetails::Brief));
177+
178+
logTitle.SetTabletId(12345);
179+
UNIT_ASSERT_STRINGS_EQUAL(
180+
"[vp:12345 d:disk1 pg:0]",
181+
logTitle.Get(TLogTitle::EDetails::Brief));
182+
183+
logTitle.SetGeneration(5);
184+
UNIT_ASSERT_STRINGS_EQUAL(
185+
"[vp:12345 d:disk1 pg:5]",
186+
logTitle.Get(TLogTitle::EDetails::Brief));
187+
188+
TLogTitle temporayLogTitle("disk1", true, GetCycleCount());
189+
UNIT_ASSERT_STRINGS_EQUAL(
190+
"[~vp:? d:disk1 pg:0]",
191+
temporayLogTitle.Get(TLogTitle::EDetails::Brief));
192+
}
193+
170194
Y_UNIT_TEST(GetChildLogger)
171195
{
172196
const ui64 startTime =

cloud/blockstore/libs/storage/service/volume_client_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void TVolumeClientActor::HandleRequest(
291291
if (!PipeClient) {
292292
PipeClient = ctx.Register(CreateClient(SelfId(), TabletId, ClientConfig));
293293
++Generation;
294-
LogTitle.SetPipeGeneration(Generation);
294+
LogTitle.SetGeneration(Generation);
295295
}
296296

297297
LOG_TRACE(

cloud/blockstore/libs/storage/testlib/test_env.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ ui32 TTestEnv::CreateBlockStoreNode(
340340
drProxyId,
341341
nodeIdx);
342342

343-
auto volumeProxy = CreateVolumeProxy(storageConfig, TraceSerializer);
343+
auto volumeProxy = CreateVolumeProxy(storageConfig, TraceSerializer, false);
344344
auto volumeProxyId = Runtime.Register(
345345
volumeProxy.release(),
346346
nodeIdx,

0 commit comments

Comments
 (0)