Skip to content

Commit

Permalink
fix storage init
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 committed Jan 23, 2025
1 parent 4e64227 commit 8cea5ca
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions ydb/core/tx/columnshard/blobs_action/tier/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,28 @@ void TOperator::DoStartGCAction(const std::shared_ptr<IBlobsGCAction>& action) c
}

void TOperator::InitNewExternalOperator(const NColumnShard::NTiers::TManager* tierManager) {
if (!tierManager || !tierManager->IsReady()) {
NWrappers::NExternalStorage::IExternalStorageOperator::TPtr extStorageOperator;
std::optional<NKikimrSchemeOp::TS3Settings> settings;

if (tierManager && tierManager->IsReady()) {
settings = tierManager->GetS3Settings();
{
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
if (CurrentS3Settings && CurrentS3Settings->SerializeAsString() == settings->SerializeAsString()) {
return;
}
}
auto extStorageConfig = NWrappers::NExternalStorage::IExternalStorageConfig::Construct(*settings);
AFL_VERIFY(extStorageConfig);
extStorageOperator = extStorageConfig->ConstructStorageOperator(false);
} else {
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
CurrentS3Settings.reset();
ExternalStorageOperator = std::make_shared<NWrappers::NExternalStorage::TUnavailableExternalStorageOperator>(
extStorageOperator = std::make_shared<NWrappers::NExternalStorage::TUnavailableExternalStorageOperator>(
NWrappers::NExternalStorage::TUnavailableExternalStorageOperator(
"tier_unavailable", TStringBuilder() << "Tier is not configured: " << GetStorageId()));
return;
}

NKikimrSchemeOp::TS3Settings settings = tierManager->GetS3Settings();
{
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
if (CurrentS3Settings && CurrentS3Settings->SerializeAsString() == settings.SerializeAsString()) {
return;
}
}
auto extStorageConfig = NWrappers::NExternalStorage::IExternalStorageConfig::Construct(settings);
AFL_VERIFY(extStorageConfig);
auto extStorageOperator = extStorageConfig->ConstructStorageOperator(false);
extStorageOperator->InitReplyAdapter(std::make_shared<NOlap::NBlobOperations::NTier::TRepliesAdapter>(GetStorageId()));
TGuard<TSpinLock> changeLock(ChangeOperatorLock);
CurrentS3Settings = settings;
Expand Down

0 comments on commit 8cea5ca

Please sign in to comment.