Skip to content

Commit ed86088

Browse files
authored
Improve DS proxy GET logs at debug level (#10467)
1 parent b46ef3e commit ed86088

File tree

1 file changed

+62
-35
lines changed

1 file changed

+62
-35
lines changed

ydb/core/blobstorage/dsproxy/dsproxy_strategy_base.cpp

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,49 @@ void TStrategyBase::EvaluateCurrentLayout(TLogContext &logCtx, TBlobState &state
2525
ui32 lostDisks = 0;
2626
ui32 unknownDisks = 0;
2727

28+
TString parts;
29+
TStringOutput s(parts);
30+
2831
const ui32 totalPartCount = info.Type.TotalPartCount();
2932
for (ui32 diskIdx = 0; diskIdx < state.Disks.size(); ++diskIdx) {
33+
if (diskIdx) {
34+
s << ' ';
35+
}
36+
3037
TBlobState::TDisk &disk = state.Disks[diskIdx];
31-
bool isHandoff = (diskIdx >= totalPartCount);
32-
ui32 beginPartIdx = (isHandoff ? 0 : diskIdx);
33-
ui32 endPartIdx = (isHandoff ? totalPartCount : (diskIdx + 1));
38+
const bool isHandoff = diskIdx >= totalPartCount;
39+
const ui32 beginPartIdx = isHandoff ? 0 : diskIdx;
40+
const ui32 endPartIdx = isHandoff ? totalPartCount : (diskIdx + 1);
3441
EDiskEvaluation diskEvaluation = ((considerSlowAsError && disk.IsSlow) ? EDE_ERROR : EDE_UNKNOWN);
3542
for (ui32 partIdx = beginPartIdx; partIdx < endPartIdx; ++partIdx) {
36-
TBlobState::ESituation partSituation = disk.DiskParts[partIdx].Situation;
37-
if (partSituation == TBlobState::ESituation::Error) {
38-
DSP_LOG_DEBUG_SX(logCtx, "BPG41", "Id# " << state.Id.ToString()
39-
<< " Restore Disk# " << diskIdx << " Part# " << partIdx << " Error");
40-
diskEvaluation = EDE_ERROR;
41-
}
42-
if (partSituation == TBlobState::ESituation::Lost) {
43-
DSP_LOG_DEBUG_SX(logCtx, "BPG65", "Id# " << state.Id.ToString()
44-
<< " Restore Disk# " << diskIdx << " Part# " << partIdx << " Lost");
45-
if (diskEvaluation != EDE_ERROR) {
46-
diskEvaluation = EDE_LOST;
47-
}
43+
switch (disk.DiskParts[partIdx].Situation) {
44+
case TBlobState::ESituation::Unknown:
45+
s << '?';
46+
break;
47+
48+
case TBlobState::ESituation::Error:
49+
s << 'E';
50+
diskEvaluation = EDE_ERROR;
51+
break;
52+
53+
case TBlobState::ESituation::Absent:
54+
s << '-';
55+
break;
56+
57+
case TBlobState::ESituation::Lost:
58+
s << 'L';
59+
if (diskEvaluation != EDE_ERROR) {
60+
diskEvaluation = EDE_LOST;
61+
}
62+
break;
63+
64+
case TBlobState::ESituation::Present:
65+
s << '+';
66+
break;
67+
68+
case TBlobState::ESituation::Sent:
69+
s << 'S';
70+
break;
4871
}
4972
}
5073
if (diskEvaluation == EDE_ERROR) {
@@ -57,23 +80,25 @@ void TStrategyBase::EvaluateCurrentLayout(TLogContext &logCtx, TBlobState &state
5780
// If there are some error disks at the same moment, the group should be actually disintegrated.
5881
} else {
5982
for (ui32 partIdx = beginPartIdx; partIdx < endPartIdx; ++partIdx) {
60-
TBlobState::ESituation partSituation = disk.DiskParts[partIdx].Situation;
61-
if (partSituation == TBlobState::ESituation::Present) {
62-
DSP_LOG_DEBUG_SX(logCtx, "BPG42", "Request# "
63-
<< " Id# " << state.Id.ToString()
64-
<< " Disk# " << diskIdx << " Part# " << partIdx << " Present");
65-
presentLayout.AddItem(diskIdx, partIdx, info.Type);
66-
optimisticLayout.AddItem(diskIdx, partIdx, info.Type);
67-
altruisticLayout.AddItem(diskIdx, partIdx, info.Type);
68-
diskEvaluation = EDE_NORMAL;
69-
} else if (partSituation == TBlobState::ESituation::Unknown
70-
|| partSituation == TBlobState::ESituation::Sent) {
71-
DSP_LOG_DEBUG_SX(logCtx, "BPG43", "Id# " << state.Id.ToString()
72-
<< " Disk# " << diskIdx << " Part# " << partIdx << " Unknown");
73-
optimisticLayout.AddItem(diskIdx, partIdx, info.Type);
74-
altruisticLayout.AddItem(diskIdx, partIdx, info.Type);
75-
} else if (partSituation == TBlobState::ESituation::Absent) {
76-
diskEvaluation = EDE_NORMAL;
83+
switch (disk.DiskParts[partIdx].Situation) {
84+
case TBlobState::ESituation::Present:
85+
presentLayout.AddItem(diskIdx, partIdx, info.Type);
86+
optimisticLayout.AddItem(diskIdx, partIdx, info.Type);
87+
altruisticLayout.AddItem(diskIdx, partIdx, info.Type);
88+
[[fallthrough]];
89+
case TBlobState::ESituation::Absent:
90+
diskEvaluation = EDE_NORMAL;
91+
break;
92+
93+
case TBlobState::ESituation::Unknown:
94+
case TBlobState::ESituation::Sent:
95+
optimisticLayout.AddItem(diskIdx, partIdx, info.Type);
96+
altruisticLayout.AddItem(diskIdx, partIdx, info.Type);
97+
break;
98+
99+
case TBlobState::ESituation::Error:
100+
case TBlobState::ESituation::Lost:
101+
Y_ABORT("impossible case");
77102
}
78103
}
79104
}
@@ -100,12 +125,14 @@ void TStrategyBase::EvaluateCurrentLayout(TLogContext &logCtx, TBlobState &state
100125
*altruisticState = info.BlobState(altruisticReplicas, lostDisks);
101126

102127
DSP_LOG_DEBUG_SX(logCtx, "BPG44", "Id# " << state.Id.ToString()
128+
<< " considerSlowAsError# " << considerSlowAsError
129+
<< " Parts# {" << parts << '}'
103130
<< " pessimisticReplicas# " << pessimisticReplicas
104-
<< " altruisticState# " << TBlobStorageGroupInfo::BlobStateToString(*altruisticState)
131+
<< " p.State# " << TBlobStorageGroupInfo::BlobStateToString(*pessimisticState)
105132
<< " optimisticReplicas# " << optimisticReplicas
106-
<< " optimisticState# " << TBlobStorageGroupInfo::BlobStateToString(*optimisticState)
133+
<< " o.State# " << TBlobStorageGroupInfo::BlobStateToString(*optimisticState)
107134
<< " altruisticReplicas# " << altruisticReplicas
108-
<< " pessimisticState# " << TBlobStorageGroupInfo::BlobStateToString(*pessimisticState));
135+
<< " a.State# " << TBlobStorageGroupInfo::BlobStateToString(*altruisticState));
109136
}
110137

111138

0 commit comments

Comments
 (0)