Skip to content

YQ-4101 KqpRun fixed storage and tenants creation #14472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ydb/core/testlib/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,7 @@ namespace Tests {
return Server->DynamicNodes();
}

void TTenants::CreateTenant(Ydb::Cms::CreateDatabaseRequest request, ui32 nodes, TDuration timeout) {
void TTenants::CreateTenant(Ydb::Cms::CreateDatabaseRequest request, ui32 nodes, TDuration timeout, bool acceptAlreadyExist) {
const TString path = request.path();
const bool serverless = request.has_serverless_resources();

Expand All @@ -3232,7 +3232,7 @@ namespace Tests {
std::move(request), "", "", runtime.GetActorSystem(0), true
).ExtractValueSync();

if (result.operation().status() != Ydb::StatusIds::SUCCESS) {
if (result.operation().status() != Ydb::StatusIds::SUCCESS && (!acceptAlreadyExist || result.operation().status() != Ydb::StatusIds::ALREADY_EXISTS)) {
NYql::TIssues issues;
NYql::IssuesFromMessage(result.operation().issues(), issues);
ythrow yexception() << "Failed to create tenant " << path << ", " << result.operation().status() << ", reason:\n" << issues.ToString();
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/testlib/test_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ namespace Tests {
ui32 Availabe() const;
ui32 Capacity() const;

void CreateTenant(Ydb::Cms::CreateDatabaseRequest request, ui32 nodes = 1, TDuration timeout = TDuration::Seconds(30));
void CreateTenant(Ydb::Cms::CreateDatabaseRequest request, ui32 nodes = 1, TDuration timeout = TDuration::Seconds(30), bool acceptAlreadyExist = false);

private:
TVector<ui32>& Nodes(const TString &name);
Expand Down
1 change: 1 addition & 0 deletions ydb/tests/tools/kqprun/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace NKqpRun {

constexpr char YQL_TOKEN_VARIABLE[] = "YQL_TOKEN";
constexpr ui64 DEFAULT_STORAGE_SIZE = 32_GB;
constexpr TDuration TENANT_CREATION_TIMEOUT = TDuration::Seconds(30);

struct TAsyncQueriesSettings {
enum class EVerbose {
Expand Down
1 change: 1 addition & 0 deletions ydb/tests/tools/kqprun/src/proto/storage_meta.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ message TStorageMeta {
EType Type = 1;
uint32 NodesCount = 2;
string SharedTenant = 3; // Only for serverless tenants
bool CreationInProgress = 4;
}

uint64 StorageGeneration = 1;
Expand Down
15 changes: 12 additions & 3 deletions ydb/tests/tools/kqprun/src/ydb_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ class TYdbSetup::TImpl {
if (!google::protobuf::TextFormat::ParseFromString(TFileInput(StorageMetaPath_.GetPath()).ReadAll(), &StorageMeta_)) {
ythrow yexception() << "Storage meta is corrupted, please use --format-storage";
}
StorageMeta_.SetStorageGeneration(StorageMeta_.GetStorageGeneration() + 1);
formatDisk = false;
}

Expand Down Expand Up @@ -288,11 +287,17 @@ class TYdbSetup::TImpl {
void CreateTenant(Ydb::Cms::CreateDatabaseRequest&& request, const TString& relativePath, const TString& type, TStorageMeta::TTenant tenantInfo) {
const auto absolutePath = request.path();
const auto [it, inserted] = StorageMeta_.MutableTenants()->emplace(relativePath, tenantInfo);
if (inserted) {
if (inserted || it->second.GetCreationInProgress()) {
if (Settings_.VerboseLevel >= EVerbose::Info) {
Cout << CoutColors_.Yellow() << TInstant::Now().ToIsoStringLocal() << " Creating " << type << " tenant " << absolutePath << "..." << CoutColors_.Default() << Endl;
}
Tenants_->CreateTenant(std::move(request), tenantInfo.GetNodesCount());

it->second.SetCreationInProgress(true);
UpdateStorageMeta();

Tenants_->CreateTenant(std::move(request), tenantInfo.GetNodesCount(), TENANT_CREATION_TIMEOUT, true);

it->second.SetCreationInProgress(false);
UpdateStorageMeta();
} else {
if (it->second.GetType() != tenantInfo.GetType()) {
Expand Down Expand Up @@ -377,6 +382,10 @@ class TYdbSetup::TImpl {
NKikimr::Tests::TServerSettings serverSettings = GetServerSettings(grpcPort);

Server_ = MakeIntrusive<NKikimr::Tests::TServer>(serverSettings);

StorageMeta_.SetStorageGeneration(StorageMeta_.GetStorageGeneration() + 1);
UpdateStorageMeta();

Server_->GetRuntime()->SetDispatchTimeout(TDuration::Max());

if (Settings_.GrpcEnabled) {
Expand Down
Loading