22#include " kqp_proxy_service_impl.h"
33#include " kqp_script_executions.h"
44
5+ #include < ydb/core/actorlib_impl/long_timer.h>
56#include < ydb/core/base/appdata.h>
6- #include < ydb/core/base/path.h>
7- #include < ydb/core/base/location.h>
87#include < ydb/core/base/feature_flags.h>
8+ #include < ydb/core/base/location.h>
9+ #include < ydb/core/base/path.h>
910#include < ydb/core/base/statestorage.h>
1011#include < ydb/core/cms/console/configs_dispatcher.h>
1112#include < ydb/core/cms/console/console.h>
12- #include < ydb/core/kqp/counters/kqp_counters.h>
13+ #include < ydb/core/fq/libs/checkpoint_storage/storage_service.h>
14+ #include < ydb/core/fq/libs/row_dispatcher/events/data_plane.h>
15+ #include < ydb/core/fq/libs/row_dispatcher/row_dispatcher_service.h>
1316#include < ydb/core/kqp/common/events/script_executions.h>
1417#include < ydb/core/kqp/common/events/workload_service.h>
1518#include < ydb/core/kqp/common/kqp_lwtrace_probes.h>
1619#include < ydb/core/kqp/common/kqp_timeouts.h>
1720#include < ydb/core/kqp/compile_service/kqp_compile_service.h>
21+ #include < ydb/core/kqp/compute_actor/kqp_compute_actor.h>
22+ #include < ydb/core/kqp/counters/kqp_counters.h>
1823#include < ydb/core/kqp/executer_actor/kqp_executer.h>
19- #include < ydb/core/kqp/session_actor/kqp_worker_common .h>
24+ #include < ydb/core/kqp/gateway/behaviour/streaming_query/behaviour .h>
2025#include < ydb/core/kqp/node_service/kqp_node_service.h>
26+ #include < ydb/core/kqp/session_actor/kqp_worker_common.h>
2127#include < ydb/core/kqp/workload_service/kqp_workload_service.h>
22- #include < ydb/core/resource_pools/resource_pool_settings.h>
23- #include < ydb/core/tx/schemeshard/schemeshard.h>
24- #include < ydb/library/yql/dq/actors/compute/dq_checkpoints.h>
25- #include < ydb/library/yql/dq/actors/spilling/spilling_file.h>
26- #include < ydb/library/yql/dq/actors/spilling/spilling.h>
27- #include < ydb/core/actorlib_impl/long_timer.h>
28- #include < ydb/public/sdk/cpp/src/library/operation_id/protos/operation_id.pb.h>
29- #include < ydb/core/node_whiteboard/node_whiteboard.h>
30- #include < ydb/core/ydb_convert/ydb_convert.h>
31- #include < ydb/core/kqp/compute_actor/kqp_compute_actor.h>
3228#include < ydb/core/mon/mon.h>
33- #include < ydb/library/ydb_issue/issue_helpers .h>
29+ #include < ydb/core/node_whiteboard/node_whiteboard .h>
3430#include < ydb/core/protos/workload_manager_config.pb.h>
31+ #include < ydb/core/resource_pools/resource_pool_settings.h>
3532#include < ydb/core/sys_view/common/registry.h>
36- #include < ydb/core/fq/libs/checkpoint_storage/storage_service.h>
37- #include < ydb/core/fq/libs/row_dispatcher/events/data_plane.h>
38- #include < ydb/core/fq/libs/row_dispatcher/row_dispatcher_service.h>
39-
40- #include < ydb/library/yql/utils/actor_log/log.h>
41- #include < yql/essentials/core/services/mounts/yql_mounts.h>
42- #include < ydb/library/yql/providers/common/http_gateway/yql_http_gateway.h>
43-
33+ #include < ydb/core/tx/schemeshard/schemeshard.h>
34+ #include < ydb/core/ydb_convert/ydb_convert.h>
4435#include < ydb/library/actors/core/actor_bootstrapped.h>
4536#include < ydb/library/actors/core/interconnect.h>
4637#include < ydb/library/actors/core/hfunc.h>
4738#include < ydb/library/actors/core/log.h>
4839#include < ydb/library/actors/http/http.h>
4940#include < ydb/library/actors/interconnect/interconnect.h>
41+ #include < ydb/library/ydb_issue/issue_helpers.h>
42+ #include < ydb/library/yql/dq/actors/compute/dq_checkpoints.h>
43+ #include < ydb/library/yql/dq/actors/spilling/spilling_file.h>
44+ #include < ydb/library/yql/dq/actors/spilling/spilling.h>
45+ #include < ydb/library/yql/providers/common/http_gateway/yql_http_gateway.h>
46+ #include < ydb/library/yql/utils/actor_log/log.h>
47+ #include < ydb/public/sdk/cpp/src/library/operation_id/protos/operation_id.pb.h>
48+
49+ #include < yql/essentials/core/services/mounts/yql_mounts.h>
50+
5051#include < library/cpp/lwtrace/mon/mon_lwtrace.h>
5152#include < library/cpp/monlib/service/pages/templates.h>
5253#include < library/cpp/resource/resource.h>
@@ -174,6 +175,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
174175 GetScriptExecutionOperation,
175176 ListScriptExecutionOperations,
176177 CancelScriptExecutionOperation,
178+ GetScriptExecutionPhysicalGraph,
177179 };
178180
179181public:
@@ -447,7 +449,13 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
447449 LogConfig.Swap (event.MutableConfig ()->MutableLogConfig ());
448450 UpdateYqlLogLevels ();
449451
450- FeatureFlags.Swap (event.MutableConfig ()->MutableFeatureFlags ());
452+ auto * newFeatureFlags = event.MutableConfig ()->MutableFeatureFlags ();
453+ if (newFeatureFlags->GetEnableSecureScriptExecutions () != FeatureFlags.GetEnableSecureScriptExecutions ()) {
454+ ScriptExecutionsCreationStatus = EScriptExecutionsCreationStatus::NotStarted;
455+ Send (NMetadata::NProvider::MakeServiceId (SelfId ().NodeId ()), new NMetadata::NProvider::TEvResetManagerRegistration (TStreamingQueryBehaviour::GetInstance ()));
456+ }
457+
458+ FeatureFlags.Swap (newFeatureFlags);
451459 WorkloadManagerConfig.Swap (event.MutableConfig ()->MutableWorkloadManagerConfig ());
452460 ResourcePoolsCache.UpdateConfig (FeatureFlags, WorkloadManagerConfig, ActorContext ());
453461
@@ -1247,6 +1255,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
12471255 hFunc (NKqp::TEvGetScriptExecutionOperation, Handle);
12481256 hFunc (NKqp::TEvListScriptExecutionOperations, Handle);
12491257 hFunc (NKqp::TEvCancelScriptExecutionOperation, Handle);
1258+ hFunc (NKqp::TEvGetScriptExecutionPhysicalGraph, Handle);
12501259 hFunc (TEvInterconnect::TEvNodeConnected, Handle);
12511260 hFunc (TEvInterconnect::TEvNodeDisconnected, Handle);
12521261 hFunc (TEvKqp::TEvListSessionsRequest, Handle);
@@ -1549,6 +1558,10 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
15491558 case EDelayedRequestType::CancelScriptExecutionOperation:
15501559 HandleDelayedScriptRequestError<TEvCancelScriptExecutionOperationResponse>(std::move (requestEvent), status, std::move (issues));
15511560 break ;
1561+
1562+ case EDelayedRequestType::GetScriptExecutionPhysicalGraph:
1563+ HandleDelayedScriptRequestError<TEvGetScriptPhysicalGraphResponse>(std::move (requestEvent), status, std::move (issues));
1564+ break ;
15521565 }
15531566 }
15541567
@@ -1557,9 +1570,14 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
15571570 Send (requestEvent->Sender , new TResponse (status, std::move (issues)), 0 , requestEvent->Cookie );
15581571 }
15591572
1573+ void StartScriptExecutionsTablesCreation () {
1574+ ScriptExecutionsCreationStatus = EScriptExecutionsCreationStatus::Pending;
1575+ Register (CreateScriptExecutionsTablesCreator (FeatureFlags), TMailboxType::HTSwap, AppData ()->SystemPoolId );
1576+ }
1577+
15601578 template <typename TEvent>
15611579 bool CheckScriptExecutionsTablesReady (TEvent& ev, EDelayedRequestType requestType) {
1562- if (!AppData ()-> FeatureFlags .GetEnableScriptExecutionOperations ()) {
1580+ if (!FeatureFlags.GetEnableScriptExecutionOperations ()) {
15631581 NYql::TIssues issues;
15641582 issues.AddIssue (" ExecuteScript feature is not enabled" );
15651583 HandleDelayedRequestError (requestType, std::move (ev), Ydb::StatusIds::UNSUPPORTED, std::move (issues));
@@ -1574,8 +1592,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
15741592
15751593 switch (ScriptExecutionsCreationStatus) {
15761594 case EScriptExecutionsCreationStatus::NotStarted:
1577- ScriptExecutionsCreationStatus = EScriptExecutionsCreationStatus::Pending;
1578- Register (CreateScriptExecutionsTablesCreator (FeatureFlags), TMailboxType::HTSwap, AppData ()->SystemPoolId );
1595+ StartScriptExecutionsTablesCreation ();
15791596 [[fallthrough]];
15801597 case EScriptExecutionsCreationStatus::Pending:
15811598 if (DelayedEventsQueue.size () < 10000 ) {
@@ -1595,6 +1612,11 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
15951612 }
15961613
15971614 void Handle (TEvScriptExecutionsTablesCreationFinished::TPtr& ev) {
1615+ if (ScriptExecutionsCreationStatus == EScriptExecutionsCreationStatus::NotStarted) {
1616+ StartScriptExecutionsTablesCreation ();
1617+ return ;
1618+ }
1619+
15981620 ScriptExecutionsCreationStatus = EScriptExecutionsCreationStatus::Finished;
15991621
16001622 NYql::TIssue rootIssue;
@@ -1641,6 +1663,12 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
16411663 }
16421664 }
16431665
1666+ void Handle (TEvGetScriptExecutionPhysicalGraph::TPtr& ev) {
1667+ if (CheckScriptExecutionsTablesReady (ev, EDelayedRequestType::GetScriptExecutionPhysicalGraph)) {
1668+ Register (CreateGetScriptExecutionPhysicalGraphActor (ev->Sender , ev->Get ()->Database , ev->Get ()->ExecutionId ));
1669+ }
1670+ }
1671+
16441672 void Handle (TEvInterconnect::TEvNodeConnected::TPtr& ev) {
16451673 TNodeId nodeId = ev->Get ()->NodeId ;
16461674 auto sessions = LocalSessions->FindSessions (nodeId);
@@ -1867,7 +1895,7 @@ class TKqpProxyService : public TActorBootstrapped<TKqpProxyService> {
18671895 }
18681896};
18691897
1870- } // namespace
1898+ } // anonymous namespace
18711899
18721900IActor* CreateKqpProxyService (const NKikimrConfig::TLogConfig& logConfig,
18731901 const NKikimrConfig::TTableServiceConfig& tableServiceConfig,
0 commit comments