Skip to content

Commit

Permalink
fix resharding tests on race gc with sharing (#6654)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Jul 14, 2024
1 parent c63da82 commit 38a7ef2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ydb/core/tx/columnshard/blobs_action/abstract/blob_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ class TBlobsCategories {
void AddSharing(const TTabletId tabletId, const TUnifiedBlobId& id) {
AFL_VERIFY(Sharing.Add(tabletId, id));
}
void RemoveSharing(const TTabletId tabletId, const TUnifiedBlobId& id) {
Y_UNUSED(Sharing.Remove(tabletId, id));
[[nodiscard]] bool RemoveSharing(const TTabletId tabletId, const TUnifiedBlobId& id) {
return Sharing.Remove(tabletId, id);
}
void RemoveBorrowed(const TTabletId tabletId, const TUnifiedBlobId& id) {
Y_UNUSED(Borrowed.Remove(tabletId, id));
[[nodiscard]] bool RemoveBorrowed(const TTabletId tabletId, const TUnifiedBlobId& id) {
return Borrowed.Remove(tabletId, id);
}
TBlobsCategories(const TTabletId selfTabletId)
: SelfTabletId(selfTabletId)
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/blobs_action/abstract/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IBlobsGCAction: public ICommonBlobsAction {
virtual bool DoIsEmpty() const = 0;
public:
void AddSharedBlobToNextIteration(const TUnifiedBlobId& blobId, const TTabletId ownerTabletId) {
BlobsToRemove.RemoveSharing(ownerTabletId, blobId);
AFL_VERIFY(BlobsToRemove.RemoveBorrowed(ownerTabletId, blobId));
}

void OnExecuteTxAfterCleaning(NColumnShard::TColumnShard& self, TBlobManagerDb& dbBlobs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ class TTxRemoveSharedBlobs: public TTransactionBase<TColumnShard> {
for (auto it = categories.GetDirect().GetIterator(); it.IsValid(); ++it) {
RemoveAction->DeclareRemove(it.GetTabletId(), it.GetBlobId());
}
for (auto it = categories.GetBorrowed().GetIterator(); it.IsValid(); ++it) {
AFL_ERROR(NKikimrServices::TX_COLUMNSHARD_BLOBS)("problem", "borrowed_to_remove")("blob_id", it.GetBlobId())("tablet_id", it.GetTabletId());
}
AFL_VERIFY(categories.GetBorrowed().IsEmpty());
AFL_VERIFY(categories.GetSharing().GetSize() == SharingBlobIds.GetSize());
AFL_VERIFY(categories.GetSharing().GetSize() == SharingBlobIds.GetSize())("sharing_category", categories.GetSharing().GetSize())(
"sharing", SharingBlobIds.GetSize());
}

bool Execute(TTransactionContext& txc, const TActorContext& ctx) override;
Expand Down
10 changes: 7 additions & 3 deletions ydb/core/tx/columnshard/columnshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,9 +1072,13 @@ void TColumnShard::Handle(TAutoPtr<TEventHandle<NOlap::NBackground::TEvExecuteGe
void TColumnShard::Handle(NOlap::NBlobOperations::NEvents::TEvDeleteSharedBlobs::TPtr& ev, const TActorContext& ctx) {
if (SharingSessionsManager->IsSharingInProgress()) {
ctx.Send(NActors::ActorIdFromProto(ev->Get()->Record.GetSourceActorId()),
new NOlap::NBlobOperations::NEvents::TEvDeleteSharedBlobsFinished((NOlap::TTabletId)TabletID(),
NKikimrColumnShardBlobOperationsProto::TEvDeleteSharedBlobsFinished::DestinationCurrenlyLocked));
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("event", "sharing_in_progress");
new NOlap::NBlobOperations::NEvents::TEvDeleteSharedBlobsFinished(
(NOlap::TTabletId)TabletID(), NKikimrColumnShardBlobOperationsProto::TEvDeleteSharedBlobsFinished::DestinationCurrenlyLocked));
for (auto&& i : ev->Get()->Record.GetBlobIds()) {
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD_BLOBS)("event", "sharing_in_progress")("blob_id", i)(
"from_tablet", ev->Get()->Record.GetSourceTabletId());
}

return;
}

Expand Down
4 changes: 2 additions & 2 deletions ydb/core/tx/columnshard/hooks/testing/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ void TController::CheckInvariants(const ::NKikimr::NColumnShard::TColumnShard& s
const NOlap::TTabletsByBlob blobs = manager->GetBlobsToDelete();
for (auto b = blobs.GetIterator(); b.IsValid(); ++b) {
Cerr << shard.TabletID() << " SHARING_REMOVE_LOCAL:" << b.GetBlobId().ToStringNew() << " FROM " << b.GetTabletId() << Endl;
i.second.RemoveSharing(b.GetTabletId(), b.GetBlobId());
Y_UNUSED(i.second.RemoveSharing(b.GetTabletId(), b.GetBlobId()));
}
for (auto b = blobs.GetIterator(); b.IsValid(); ++b) {
Cerr << shard.TabletID() << " BORROWED_REMOVE_LOCAL:" << b.GetBlobId().ToStringNew() << " FROM " << b.GetTabletId() << Endl;
i.second.RemoveBorrowed(b.GetTabletId(), b.GetBlobId());
Y_UNUSED(i.second.RemoveBorrowed(b.GetTabletId(), b.GetBlobId()));
}
}
context.AddCategories(shard.TabletID(), std::move(shardBlobsCategories));
Expand Down

0 comments on commit 38a7ef2

Please sign in to comment.