@@ -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) {
0 commit comments