Skip to content

Commit 8cf960f

Browse files
authored
Some BlobDepot hardening checks (#1692)
1 parent 8c72ada commit 8cf960f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ydb/core/blob_depot/given_id_range.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace NKikimr::NBlobDepot {
4343
Y_ABORT_UNLESS(it != Ranges.end());
4444
TChunk& chunk = it->second;
4545
const size_t offset = value % BitsPerChunk;
46+
Y_DEBUG_ABORT_UNLESS(chunk[offset]);
4647
chunk.Reset(offset);
4748
--NumAvailableItems;
4849
if (chunk.Empty()) {

ydb/core/blob_depot/op_commit_blob_seq.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace NKikimr::NBlobDepot {
1414
std::unique_ptr<IEventHandle> Response;
1515
std::vector<TBlobSeqId> BlobSeqIds;
1616
std::set<TBlobSeqId> FailedBlobSeqIds;
17+
std::set<TBlobSeqId> CanBeCollectedBlobSeqIds;
18+
std::set<TBlobSeqId> AllowedBlobSeqIds;
1719

1820
public:
1921
TTxType GetTxType() const override { return NKikimrBlobDepot::TXTYPE_COMMIT_BLOB_SEQ; }
@@ -35,8 +37,11 @@ namespace NKikimr::NBlobDepot {
3537
Y_VERIFY_S(blobSeqId.Generation < generation, "committing trimmed BlobSeqId"
3638
<< " BlobSeqId# " << blobSeqId.ToString()
3739
<< " Id# " << Self->GetLogId());
40+
CanBeCollectedBlobSeqIds.insert(blobSeqId);
3841
} else if (!Self->Data->BeginCommittingBlobSeqId(agent, blobSeqId)) {
3942
FailedBlobSeqIds.insert(blobSeqId);
43+
} else {
44+
AllowedBlobSeqIds.insert(blobSeqId);
4045
}
4146
BlobSeqIds.push_back(blobSeqId);
4247
}
@@ -102,6 +107,8 @@ namespace NKikimr::NBlobDepot {
102107
continue;
103108
}
104109

110+
Y_VERIFY_DEBUG_S(!CanBeCollectedBlobSeqIds.contains(blobSeqId), "BlobSeqId# " << blobSeqId);
111+
105112
TString error;
106113
if (!CheckKeyAgainstBarrier(key, &error)) {
107114
responseItem->SetStatus(NKikimrProto::ERROR);
@@ -121,6 +128,15 @@ namespace NKikimr::NBlobDepot {
121128
responseItem->SetStatus(NKikimrProto::RACE);
122129
}
123130
} else {
131+
Y_VERIFY_DEBUG_S(AllowedBlobSeqIds.contains(blobSeqId), "BlobSeqId# " << blobSeqId);
132+
Y_VERIFY_DEBUG_S(
133+
Self->Channels[blobSeqId.Channel].GetLeastExpectedBlobId(generation) <= blobSeqId,
134+
"BlobSeqId# " << blobSeqId
135+
<< " LeastExpectedBlobId# " << Self->Channels[blobSeqId.Channel].GetLeastExpectedBlobId(generation)
136+
<< " Generation# " << generation);
137+
Y_VERIFY_DEBUG_S(blobSeqId.Generation == generation, "BlobSeqId# " << blobSeqId << " Generation# " << generation);
138+
Y_VERIFY_DEBUG_S(Self->Channels[blobSeqId.Channel].SequenceNumbersInFlight.contains(blobSeqId.ToSequentialNumber()),
139+
"BlobSeqId# " << blobSeqId);
124140
Self->Data->UpdateKey(key, item, txc, this);
125141
}
126142
}

0 commit comments

Comments
 (0)