Skip to content

Commit 4b2def6

Browse files
committed
Fixed unit tests 6
1 parent 2211bf4 commit 4b2def6

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

ydb/core/kqp/proxy_service/kqp_proxy_databases_cache.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,6 @@ TDatabasesCache::TDatabasesCache(TDuration idleTimeout)
194194
: IdleTimeout(idleTimeout)
195195
{}
196196

197-
const TString& TDatabasesCache::GetTenantName() {
198-
if (!TenantName) {
199-
TenantName = CanonizePath(AppData()->TenantName);
200-
}
201-
return TenantName;
202-
}
203-
204197
void TDatabasesCache::UpdateDatabaseInfo(TEvKqp::TEvUpdateDatabaseInfo::TPtr& event, TActorContext actorContext) {
205198
auto it = DatabasesCache.find(event->Get()->Database);
206199
if (it == DatabasesCache.end()) {

ydb/core/kqp/proxy_service/kqp_proxy_service_impl.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,10 @@ class TDatabasesCache {
659659

660660
template <typename TEvent>
661661
bool SetDatabaseIdOrDefer(TEvent& event, i32 requestType, TActorContext actorContext) {
662-
if (!event->Get()->GetDatabaseId().empty()) {
663-
return true;
664-
}
665-
666662
const auto& database = CanonizePath(event->Get()->GetDatabase());
667-
if (database.empty() || database == GetTenantName()) {
668-
event->Get()->SetDatabaseId(GetTenantName());
663+
const auto& tenantName = CanonizePath(AppData()->TenantName);
664+
if (database.empty() || database == tenantName) {
665+
event->Get()->SetDatabaseId(tenantName);
669666
return true;
670667
}
671668

@@ -689,7 +686,6 @@ class TDatabasesCache {
689686
void StopSubscriberActor(TActorContext actorContext) const;
690687

691688
private:
692-
const TString& GetTenantName();
693689
void SubscribeOnDatabase(const TString& database, TActorContext actorContext);
694690
void PingDatabaseSubscription(const TString& database, TActorContext actorContext) const;
695691

ydb/core/kqp/session_actor/kqp_session_actor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {
417417
<< " text: " << QueryState->GetQuery()
418418
<< " rpcActor: " << QueryState->RequestActorId
419419
<< " database: " << QueryState->GetDatabase()
420+
<< " databaseId: " << QueryState->UserRequestContext->DatabaseId
420421
<< " pool id: " << QueryState->UserRequestContext->PoolId
421422
);
422423

ydb/core/kqp/workload_service/kqp_workload_service.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ class TKqpWorkloadService : public TActorBootstrapped<TKqpWorkloadService> {
232232

233233
private:
234234
void Handle(TEvFetchDatabaseResponse::TPtr& ev) {
235+
if (ev->Get()->Status == Ydb::StatusIds::SUCCESS) {
236+
LOG_D("Successfully fetched database info, DatabaseId: " << ev->Get()->DatabaseId << ", Serverless: " << ev->Get()->Serverless);
237+
} else {
238+
LOG_D("Failed to fetch database info, DatabaseId: " << ev->Get()->DatabaseId << ", Status: " << ev->Get()->Status << ", Issues: " << ev->Get()->Issues.ToOneLineString());
239+
}
235240
GetOrCreateDatabaseState(ev->Get()->DatabaseId)->UpdateDatabaseInfo(ev);
236241
}
237242

@@ -549,6 +554,7 @@ class TKqpWorkloadService : public TActorBootstrapped<TKqpWorkloadService> {
549554
if (databaseIt != DatabaseToState.end()) {
550555
return &databaseIt->second;
551556
}
557+
LOG_I("Creating new database state for id " << databaseId);
552558
return &DatabaseToState.insert({databaseId, TDatabaseState{.ActorContext = ActorContext(), .EnabledResourcePoolsOnServerless = EnabledResourcePoolsOnServerless}}).first->second;
553559
}
554560

ydb/core/kqp/workload_service/kqp_workload_service_impl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <queue>
44

5+
#include <ydb/core/kqp/common/events/events.h>
56
#include <ydb/core/kqp/common/simple/services.h>
67
#include <ydb/core/kqp/workload_service/actors/actors.h>
78
#include <ydb/core/kqp/workload_service/common/cpu_quota_manager.h>
@@ -77,6 +78,10 @@ struct TDatabaseState {
7778
return;
7879
}
7980

81+
if (Serverless != ev->Get()->Serverless) {
82+
ActorContext.Send(MakeKqpProxyID(ActorContext.SelfID.NodeId()), new TEvKqp::TEvUpdateDatabaseInfo(ev->Get()->Database, ev->Get()->DatabaseId, ev->Get()->Serverless));
83+
}
84+
8085
LastUpdateTime = TInstant::Now();
8186
Serverless = ev->Get()->Serverless;
8287
StartPendingRequests();

0 commit comments

Comments
 (0)