Skip to content

Commit 357aebf

Browse files
authored
Fix Trash table loading (#30273)
1 parent 2e3f32c commit 357aebf

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

ydb/core/blob_depot/data.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ namespace NKikimr::NBlobDepot {
201201
Self->TabletCounters->Simple()[NKikimrBlobDepot::COUNTER_TOTAL_STORED_DATA_SIZE] = TotalStoredDataSize;
202202

203203
InFlightTrashBlobs.emplace(cookie, id);
204+
const bool inserted = AllInFlightTrashBlobs.insert(id).second;
205+
Y_ABORT_UNLESS(inserted);
204206
db.Table<Schema::Trash>().Key(id.AsBinaryString()).Update();
205207
return false; // keep this blob in deletion queue
206208
};
@@ -462,8 +464,13 @@ namespace NKikimr::NBlobDepot {
462464
}
463465

464466
void TData::AddTrashOnLoad(TLogoBlobID id) {
467+
if (AllInFlightTrashBlobs.contains(id)) {
468+
return; // we're trying to add just inserted item, ignore it
469+
}
465470
auto& record = GetRecordsPerChannelGroup(id);
466-
record.Trash.insert(id);
471+
if (const auto [it, inserted] = record.Trash.insert(id); !inserted) {
472+
return; // the same situation: this item has just been inserted into the set
473+
}
467474
AccountBlob(id, true);
468475
TotalStoredTrashSize += id.BlobSize();
469476
Self->TabletCounters->Simple()[NKikimrBlobDepot::COUNTER_TOTAL_STORED_TRASH_SIZE] = TotalStoredTrashSize;
@@ -646,7 +653,8 @@ namespace NKikimr::NBlobDepot {
646653
void TData::TRecordsPerChannelGroup::MoveToTrash(TData *self, TLogoBlobID id) {
647654
const auto usedIt = Used.find(id);
648655
Y_ABORT_UNLESS(usedIt != Used.end());
649-
Trash.insert(Used.extract(usedIt));
656+
const bool inserted = Trash.insert(Used.extract(usedIt)).inserted;
657+
Y_DEBUG_ABORT_UNLESS(inserted);
650658
self->TotalStoredTrashSize += id.BlobSize();
651659
self->Self->TabletCounters->Simple()[NKikimrBlobDepot::COUNTER_TOTAL_STORED_TRASH_SIZE] = self->TotalStoredTrashSize;
652660
}
@@ -784,6 +792,7 @@ namespace NKikimr::NBlobDepot {
784792
for (const auto& [cookie, id] : InFlightTrashBlobs) {
785793
const bool inserted = refcountBlobs.try_emplace(id).second;
786794
Y_ABORT_UNLESS(inserted);
795+
Y_ABORT_UNLESS(AllInFlightTrashBlobs.contains(id));
787796
}
788797

789798
for (const auto& [cookie, locator] : InFlightTrashS3) {

ydb/core/blob_depot/data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ namespace NKikimr::NBlobDepot {
479479

480480
THashMultiMap<void*, TLogoBlobID> InFlightTrashBlobs; // being committed, but not yet confirmed
481481
THashMultiMap<void*, TS3Locator> InFlightTrashS3; // being committed, but not yet confirmed
482+
THashSet<TLogoBlobID> AllInFlightTrashBlobs;
482483

483484
class TTxIssueGC;
484485
class TTxConfirmGC;

ydb/core/blob_depot/data_trash.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace NKikimr::NBlobDepot {
1313
record.MoveToTrash(this, it->second);
1414
records.insert(&record);
1515
InFlightTrashSize -= it->second.BlobSize();
16+
AllInFlightTrashBlobs.erase(it->second);
1617
}
1718
InFlightTrashBlobs.erase(first, last);
1819

0 commit comments

Comments
 (0)