Skip to content

Commit 5c2ef6f

Browse files
committed
Improve text output of integrity check (#21787)
1 parent ea806b6 commit 5c2ef6f

File tree

4 files changed

+59
-20
lines changed

4 files changed

+59
-20
lines changed

ydb/core/base/blobstorage.h

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,17 +1322,20 @@ struct TEvBlobStorage {
13221322
TLogoBlobID Id;
13231323
TInstant Deadline;
13241324
NKikimrBlobStorage::EGetHandleClass GetHandleClass;
1325+
bool SingleLine; // Print DataInfo in single line
13251326

13261327
ui32 RestartCounter = 0;
13271328
std::shared_ptr<TExecutionRelay> ExecutionRelay;
13281329

13291330
TEvCheckIntegrity(
13301331
const TLogoBlobID& id,
13311332
TInstant deadline,
1332-
NKikimrBlobStorage::EGetHandleClass getHandleClass)
1333+
NKikimrBlobStorage::EGetHandleClass getHandleClass,
1334+
bool singleLine = false)
13331335
: Id(id)
13341336
, Deadline(deadline)
13351337
, GetHandleClass(getHandleClass)
1338+
, SingleLine(singleLine)
13361339
{}
13371340

13381341
TString Print(bool /*isFull*/) const {
@@ -1373,13 +1376,44 @@ struct TEvBlobStorage {
13731376
PS_BLOB_IS_RECOVERABLE = 4, // blob parts are definitely placed incorrectly or there are missing parts but blob may be recovered
13741377
PS_BLOB_IS_LOST = 5, // blob is lost/unrecoverable
13751378
};
1376-
EPlacementStatus PlacementStatus = PS_OK;
1379+
1380+
static TString PlacementStatusToString(EPlacementStatus status) {
1381+
switch (status) {
1382+
case PS_OK:
1383+
return "PS_OK";
1384+
case PS_REPLICATION_IN_PROGRESS:
1385+
return "PS_REPLICATION_IN_PROGRESS";
1386+
case PS_UNKNOWN:
1387+
return "PS_UNKNOWN";
1388+
case PS_BLOB_IS_RECOVERABLE:
1389+
return "PS_BLOB_IS_RECOVERABLE";
1390+
case PS_BLOB_IS_LOST:
1391+
return "PS_BLOB_IS_LOST";
1392+
default:
1393+
return "BAD_PLACEMENT_STATUS";
1394+
}
1395+
}
13771396

13781397
enum EDataStatus {
13791398
DS_OK = 1, // all data parts contain valid data
13801399
DS_UNKNOWN = 2, // status is unknown because of missing disks or network problems
13811400
DS_ERROR = 3, // some parts definitely contain invalid data
13821401
};
1402+
1403+
static TString DataStatusToString(EDataStatus status) {
1404+
switch (status) {
1405+
case DS_OK:
1406+
return "DS_OK";
1407+
case DS_UNKNOWN:
1408+
return "DS_UNKNOWN";
1409+
case DS_ERROR:
1410+
return "DS_ERROR";
1411+
default:
1412+
return "BAD_DATA_STATUS";
1413+
}
1414+
}
1415+
1416+
EPlacementStatus PlacementStatus = PS_OK;
13831417
EDataStatus DataStatus = DS_OK;
13841418
TString DataInfo; // textual info about checks in blob data
13851419

@@ -1395,8 +1429,8 @@ struct TEvBlobStorage {
13951429
<< " Id# " << Id
13961430
<< " Status# " << NKikimrProto::EReplyStatus_Name(Status)
13971431
<< " ErrorReason# " << ErrorReason
1398-
<< " PlacementStatus# " << (int)PlacementStatus
1399-
<< " DataStatus# " << (int)DataStatus
1432+
<< " PlacementStatus# " << PlacementStatusToString(PlacementStatus)
1433+
<< " DataStatus# " << DataStatusToString(DataStatus)
14001434
<< " DataInfo# " << DataInfo
14011435
<< " }";
14021436
return str.Str();

ydb/core/blobstorage/dsproxy/dsproxy_check_integrity_get.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class TBlobStorageGroupCheckIntegrityRequest
1414
const TLogoBlobID Id;
1515
const TInstant Deadline;
1616
const NKikimrBlobStorage::EGetHandleClass GetHandleClass;
17+
const bool SingleLine;
1718

1819
TGroupQuorumTracker QuorumTracker;
1920

@@ -162,8 +163,10 @@ class TBlobStorageGroupCheckIntegrityRequest
162163
}
163164
}
164165

166+
char separator = SingleLine ? ' ' : '\n';
167+
165168
const auto& dataChecker = Info->GetTopology().GetDataIntegrityChecker();
166-
auto partsState = dataChecker.GetDataState(Id, PartsData);
169+
auto partsState = dataChecker.GetDataState(Id, PartsData, separator);
167170

168171
if (partsState.IsOk) {
169172
PendingResult->DataStatus = (PendingResult->PlacementStatus == TEvCheckIntegrityResult::PS_UNKNOWN) ?
@@ -173,10 +176,10 @@ class TBlobStorageGroupCheckIntegrityRequest
173176
}
174177

175178
TStringStream str;
176-
str << "Disks:" << Endl;
179+
str << "Disks:" << separator;
177180
for (ui32 diskIdx = 0; diskIdx < Info->Type.BlobSubgroupSize(); ++diskIdx) {
178181
auto vDiskIdShort = Info->GetTopology().GetVDiskInSubgroup(diskIdx, Id.Hash());
179-
str << diskIdx << ": " << Info->CreateVDiskID(vDiskIdShort) << Endl;
182+
str << diskIdx << ": " << Info->CreateVDiskID(vDiskIdShort) << separator;
180183
}
181184

182185
PendingResult->DataInfo = str.Str();
@@ -199,6 +202,7 @@ class TBlobStorageGroupCheckIntegrityRequest
199202
, Id(params.Common.Event->Id)
200203
, Deadline(params.Common.Event->Deadline)
201204
, GetHandleClass(params.Common.Event->GetHandleClass)
205+
, SingleLine(params.Common.Event->SingleLine)
202206
, QuorumTracker(Info.Get())
203207
{}
204208

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class TBlobStorageGroupInfo : public TThrRefBase {
172172
TString DataInfo;
173173
};
174174

175-
virtual TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData) const = 0;
175+
virtual TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData, char separator) const = 0;
176176
};
177177

178178
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_data_check.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ class TDataIntegrityCheckerTrivial : public TDataIntegrityCheckerBase {
1616
public:
1717
using TDataIntegrityCheckerBase::TDataIntegrityCheckerBase;
1818

19-
TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData) const override {
19+
TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData, char separator) const override {
2020
Y_UNUSED(id);
2121
Y_UNUSED(partsData);
22+
Y_UNUSED(separator);
2223
return {};
2324
}
2425
};
@@ -27,7 +28,7 @@ class TDataIntegrityCheckerBlock42 : public TDataIntegrityCheckerBase {
2728
public:
2829
using TDataIntegrityCheckerBase::TDataIntegrityCheckerBase;
2930

30-
TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData) const override {
31+
TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData, char separator) const override {
3132
Y_ABORT_UNLESS(partsData.Parts.size() == 6);
3233

3334
TPartsState partsState;
@@ -58,7 +59,7 @@ class TDataIntegrityCheckerBlock42 : public TDataIntegrityCheckerBase {
5859

5960
// checking layout
6061
TStringStream layoutReport;
61-
layoutReport << "Layout info:" << Endl;
62+
layoutReport << "Layout info:" << separator;
6263

6364
TStringStream str;
6465
bool hasUnequalParts = false;
@@ -80,19 +81,19 @@ class TDataIntegrityCheckerBlock42 : public TDataIntegrityCheckerBase {
8081
str << "]";
8182
++ver;
8283
}
83-
str << Endl;
84+
str << separator;
8485
}
8586

8687
layoutReport << str.Str();
8788
if (hasUnequalParts) {
8889
partsState.IsOk = false;
89-
layoutReport << "ERROR: There are unequal parts" << Endl;
90+
layoutReport << "ERROR: There are unequal parts" << separator;
9091
}
9192
partsState.DataInfo = layoutReport.Str();
9293

9394
// checking erasure
9495
TStringStream erasureReport;
95-
erasureReport << "Erasure info:" << Endl;
96+
erasureReport << "Erasure info:" << separator;
9697

9798
std::vector<ui32> partIds;
9899
partIds.reserve(6);
@@ -144,7 +145,7 @@ class TDataIntegrityCheckerBlock42 : public TDataIntegrityCheckerBase {
144145
if (cmp) {
145146
erasureError = true;
146147
} else {
147-
str << "OK" << Endl;
148+
str << "OK" << separator;
148149
erasureReport << str.Str(); // report only succesful restore
149150
}
150151
}
@@ -199,7 +200,7 @@ class TDataIntegrityCheckerBlock42 : public TDataIntegrityCheckerBase {
199200

200201
if (erasureError) {
201202
partsState.IsOk = false;
202-
erasureReport << "ERROR: There are erasure restore fails" << Endl;
203+
erasureReport << "ERROR: There are erasure restore fails" << separator;
203204
}
204205

205206
partsState.DataInfo += erasureReport.Str();
@@ -214,7 +215,7 @@ class TDataIntegrityCheckerMirror : public TDataIntegrityCheckerBase {
214215
public:
215216
using TDataIntegrityCheckerBase::TDataIntegrityCheckerBase;
216217

217-
TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData) const override {
218+
TPartsState GetDataState(const TLogoBlobID& id, const TPartsData& partsData, char separator) const override {
218219
Y_UNUSED(id);
219220
Y_ABORT_UNLESS(partsData.Parts.size() == 3);
220221

@@ -244,7 +245,7 @@ class TDataIntegrityCheckerMirror : public TDataIntegrityCheckerBase {
244245
}
245246

246247
TStringStream layoutReport;
247-
layoutReport << "Layout info:" << Endl;
248+
layoutReport << "Layout info:" << separator;
248249

249250
TStringStream str;
250251
bool hasUnequalParts = (seenParts.size() > 1);
@@ -260,12 +261,12 @@ class TDataIntegrityCheckerMirror : public TDataIntegrityCheckerBase {
260261
str << "]";
261262
++ver;
262263
}
263-
str << Endl;
264+
str << separator;
264265
layoutReport << str.Str();
265266

266267
if (hasUnequalParts) {
267268
partsState.IsOk = false;
268-
layoutReport << "ERROR: There are unequal parts" << Endl;
269+
layoutReport << "ERROR: There are unequal parts" << separator;
269270
}
270271
partsState.DataInfo = layoutReport.Str();
271272

0 commit comments

Comments
 (0)