Skip to content

Commit

Permalink
lock for different client versions usage (ydb-platform#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Jan 12, 2024
1 parent a03a2bc commit 2c3d1e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
25 changes: 6 additions & 19 deletions ydb/core/tx/columnshard/blobs_action/tier/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
namespace NKikimr::NOlap::NBlobOperations::NTier {

NWrappers::NExternalStorage::IExternalStorageOperator::TPtr TOperator::GetCurrentOperator() const {
const ui32 idx = CurrentOperatorIdx.Val();
AFL_VERIFY(idx < ExternalStorageOperators.size())("idx", idx)("size", ExternalStorageOperators.size());
auto result = ExternalStorageOperators[idx];
Y_ABORT_UNLESS(result);
return result;
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
return ExternalStorageOperator;
}

std::shared_ptr<IBlobsDeclareRemovingAction> TOperator::DoStartDeclareRemovingAction() {
Expand Down Expand Up @@ -52,10 +49,8 @@ void TOperator::InitNewExternalOperator(const NColumnShard::NTiers::TManager* ti
AFL_VERIFY(extStorageConfig);
auto extStorageOperator = extStorageConfig->ConstructStorageOperator(false);
extStorageOperator->InitReplyAdapter(std::make_shared<NOlap::NBlobOperations::NTier::TRepliesAdapter>());
ExternalStorageOperators.emplace_back(extStorageOperator);
if (CurrentOperatorIdx.Val() + 1 < (i64)ExternalStorageOperators.size()) {
CurrentOperatorIdx.Inc();
}
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
ExternalStorageOperator = extStorageOperator;
}

TOperator::TOperator(const TString& storageId, const NColumnShard::TColumnShard& shard)
Expand All @@ -67,20 +62,12 @@ TOperator::TOperator(const TString& storageId, const NColumnShard::TColumnShard&
}

void TOperator::DoOnTieringModified(const std::shared_ptr<NColumnShard::TTiersManager>& tiers) {
AFL_VERIFY(ExternalStorageOperators.size());
auto* tierManager = tiers->GetManagerOptional(TBase::GetStorageId());
ui32 cleanCount = ExternalStorageOperators.size() - 1;
if (tierManager) {
InitNewExternalOperator(tierManager);
} else {
cleanCount = ExternalStorageOperators.size();
}
for (ui32 i = 0; i < cleanCount; ++i) {
if (ExternalStorageOperators[i].use_count() == 1) {
ExternalStorageOperators[i] = nullptr;
} else {
break;
}
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
ExternalStorageOperator = nullptr;
}
}

Expand Down
4 changes: 2 additions & 2 deletions ydb/core/tx/columnshard/blobs_action/tier/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class TOperator: public IBlobsStorageOperator {
using TBase = IBlobsStorageOperator;
const ui64 TabletId;
const NActors::TActorId TabletActorId;
TAtomicCounter CurrentOperatorIdx = 0;
std::deque<NWrappers::NExternalStorage::IExternalStorageOperator::TPtr> ExternalStorageOperators;
std::shared_ptr<TGCInfo> GCInfo = std::make_shared<TGCInfo>();

NWrappers::NExternalStorage::IExternalStorageConfig::TPtr ExternalStorageConfig;
TSpinLock ChangeOperatorLock;
NWrappers::NExternalStorage::IExternalStorageOperator::TPtr ExternalStorageOperator;

NWrappers::NExternalStorage::IExternalStorageOperator::TPtr GetCurrentOperator() const;
Expand Down

0 comments on commit 2c3d1e3

Please sign in to comment.