diff options
author | daredevil2002 <daredevil2002@yandex-team.ru> | 2022-02-10 16:52:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:52:23 +0300 |
commit | 9d979fefa685eaf1d8eef22bd420d76a34ed7fc2 (patch) | |
tree | 10a3eaed5112cac11146884059aaf0a6619864e3 | |
parent | 114b6f5165283c0d2ca8b3718ae9d84cf5d70eca (diff) | |
download | ydb-9d979fefa685eaf1d8eef22bd420d76a34ed7fc2.tar.gz |
Restoring authorship annotation for <daredevil2002@yandex-team.ru>. Commit 1 of 2.
45 files changed, 1091 insertions, 1091 deletions
diff --git a/ydb/core/grpc_services/base/base.h b/ydb/core/grpc_services/base/base.h index 44b25c4a5f..c11e351714 100644 --- a/ydb/core/grpc_services/base/base.h +++ b/ydb/core/grpc_services/base/base.h @@ -172,13 +172,13 @@ struct TRpcServices { EvYandexQueryCreateQuery, EvYandexQueryListQueries, EvYandexQueryDescribeQuery, - EvYandexQueryGetQueryStatus, + EvYandexQueryGetQueryStatus, EvYandexQueryModifyQuery, EvYandexQueryDeleteQuery, EvYandexQueryControlQuery, EvYandexQueryGetResultData, EvYandexQueryListJobs, - EvYandexQueryDescribeJob, + EvYandexQueryDescribeJob, EvYandexQueryCreateConnection, EvYandexQueryListConnections, EvYandexQueryDescribeConnection, diff --git a/ydb/core/grpc_services/rpc_yq.cpp b/ydb/core/grpc_services/rpc_yq.cpp index 6fe5f868d6..1249bb3f03 100644 --- a/ydb/core/grpc_services/rpc_yq.cpp +++ b/ydb/core/grpc_services/rpc_yq.cpp @@ -180,8 +180,8 @@ using TYandexQueryListQueriesRPC = TYandexQueryRequestRPC< void DoYandexQueryListQueriesRequest(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider&) { TActivationContext::AsActorContext().Register(new TYandexQueryListQueriesRPC(p.release())); -} - +} + using TYandexQueryDescribeQueryRPC = TYandexQueryRequestRPC< TGrpcYqRequestOperationCall<YandexQuery::DescribeQueryRequest, YandexQuery::DescribeQueryResponse>, NYq::TEvControlPlaneProxy::TEvDescribeQueryRequest, @@ -207,8 +207,8 @@ using TYandexQueryModifyQueryRPC = TYandexQueryRequestRPC< void DoYandexQueryModifyQueryRequest(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider&) { TActivationContext::AsActorContext().Register(new TYandexQueryModifyQueryRPC(p.release())); -} - +} + using TYandexQueryDeleteQueryRPC = TYandexQueryRequestRPC< TGrpcYqRequestOperationCall<YandexQuery::DeleteQueryRequest, YandexQuery::DeleteQueryResponse>, NYq::TEvControlPlaneProxy::TEvDeleteQueryRequest, @@ -306,8 +306,8 @@ using TYandexQueryTestConnectionRPC = TYandexQueryRequestRPC< void DoTestConnectionRequest(std::unique_ptr<IRequestOpCtx> p, const IFacilityProvider&) { TActivationContext::AsActorContext().Register(new TYandexQueryTestConnectionRPC(p.release())); -} - +} + using TYandexQueryCreateBindingRPC = TYandexQueryRequestRPC< TGrpcYqRequestOperationCall<YandexQuery::CreateBindingRequest, YandexQuery::CreateBindingResponse>, NYq::TEvControlPlaneProxy::TEvCreateBindingRequest, diff --git a/ydb/core/yq/libs/actors/pending_fetcher.cpp b/ydb/core/yq/libs/actors/pending_fetcher.cpp index 0095963c8f..1102f75c31 100644 --- a/ydb/core/yq/libs/actors/pending_fetcher.cpp +++ b/ydb/core/yq/libs/actors/pending_fetcher.cpp @@ -8,7 +8,7 @@ #include <library/cpp/actors/core/events.h> #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/actor_bootstrapped.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <ydb/core/protos/services.pb.h> #include <ydb/library/yql/ast/yql_expr.h> @@ -259,7 +259,7 @@ private: task.dq_graph_index(), VectorFromProto(task.created_topic_consumers()), task.automatic(), - task.query_name(), + task.query_name(), NProtoInterop::CastFromProto(task.deadline()), ClientCounters); diff --git a/ydb/core/yq/libs/actors/pinger.cpp b/ydb/core/yq/libs/actors/pinger.cpp index 55fc80d6a0..cd857a7bba 100644 --- a/ydb/core/yq/libs/actors/pinger.cpp +++ b/ydb/core/yq/libs/actors/pinger.cpp @@ -1,6 +1,6 @@ #include <ydb/core/yq/libs/config/protos/pinger.pb.h> #include "proxy.h" -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <ydb/core/yq/libs/control_plane_storage/control_plane_storage.h> #include <ydb/core/yq/libs/control_plane_storage/events/events.h> @@ -10,7 +10,7 @@ #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/events.h> #include <library/cpp/actors/core/log.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <util/generic/utility.h> @@ -148,8 +148,8 @@ public: const TString& ownerId, const TPrivateClient& client, const TActorId parent, - const NConfig::TPingerConfig& config, - const TInstant& deadline) + const NConfig::TPingerConfig& config, + const TInstant& deadline) : Config(config) , Scope(scope) , UserId(userId) @@ -157,7 +157,7 @@ public: , OwnerId(ownerId) , Client(client) , Parent(parent) - , Deadline(deadline) + , Deadline(deadline) { } @@ -382,7 +382,7 @@ private: request.set_scope(Scope.ToString()); request.set_owner_id(OwnerId); request.mutable_query_id()->set_value(Id); - *request.mutable_deadline() = NProtoInterop::CastToProto(Deadline); + *request.mutable_deadline() = NProtoInterop::CastToProto(Deadline); const auto* actorSystem = NActors::TActivationContext::ActorSystem(); const auto selfId = SelfId(); @@ -424,7 +424,7 @@ private: TInstant StartLeaseTime; TRetryState RetryState; const TActorId Parent; - const TInstant Deadline; + const TInstant Deadline; std::deque<TForwardPingReqInfo> ForwardRequests; bool Finishing = false; @@ -440,8 +440,8 @@ IActor* CreatePingerActor( const TString& ownerId, const TPrivateClient& client, const TActorId parent, - const NConfig::TPingerConfig& config, - const TInstant& deadline) + const NConfig::TPingerConfig& config, + const TInstant& deadline) { return new TPingerActor( scope, @@ -450,8 +450,8 @@ IActor* CreatePingerActor( ownerId, client, parent, - config, - deadline); + config, + deadline); } } /* NYq */ diff --git a/ydb/core/yq/libs/actors/proxy.h b/ydb/core/yq/libs/actors/proxy.h index 442d29ac44..46f9908cb4 100644 --- a/ydb/core/yq/libs/actors/proxy.h +++ b/ydb/core/yq/libs/actors/proxy.h @@ -1,7 +1,7 @@ #pragma once #include <ydb/core/yq/libs/config/protos/pinger.pb.h> #include "run_actor_params.h" -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <ydb/core/yq/libs/events/events.h> #include <ydb/core/yq/libs/private_client/private_client.h> @@ -71,7 +71,7 @@ NActors::IActor* CreateResultWriter( const NConfig::TPrivateApiConfig& privateApiConfig, const TResultId& resultId, const TVector<TString>& columns, - const TString& traceId, + const TString& traceId, const TInstant& deadline, const NMonitoring::TDynamicCounterPtr& clientCounters ); @@ -83,8 +83,8 @@ NActors::IActor* CreatePingerActor( const TString& owner, const NYq::TPrivateClient& client, const NActors::TActorId parent, - const NConfig::TPingerConfig& config, - const TInstant& deadline); + const NConfig::TPingerConfig& config, + const TInstant& deadline); TString MakeInternalError(const TString& text); diff --git a/ydb/core/yq/libs/actors/result_writer.cpp b/ydb/core/yq/libs/actors/result_writer.cpp index d51b8aae9f..3b7061639c 100644 --- a/ydb/core/yq/libs/actors/result_writer.cpp +++ b/ydb/core/yq/libs/actors/result_writer.cpp @@ -14,7 +14,7 @@ #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/actors/core/log.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <ydb/core/yq/libs/control_plane_storage/control_plane_storage.h> #include <ydb/core/yq/libs/control_plane_storage/events/events.h> @@ -42,14 +42,14 @@ public: const NConfig::TPrivateApiConfig& privateApiConfig, const TResultId& resultId, const TVector<TString>& columns, - const TString& traceId, + const TString& traceId, const TInstant& deadline, const NMonitoring::TDynamicCounterPtr& clientCounters) : ExecuterId(executerId) , ResultBuilder(MakeHolder<TProtoBuilder>(resultType, columns)) , ResultId({resultId}) , TraceId(traceId) - , Deadline(deadline) + , Deadline(deadline) , Client( driver, NYdb::TCommonClientSettings() @@ -60,7 +60,7 @@ public: static constexpr char ActorName[] = "YQ_RESULT_WRITER"; - void Bootstrap(const TActorContext&) { + void Bootstrap(const TActorContext&) { LOG_I("Bootstrap"); Become(&TResultWriter::StateFunc); } @@ -184,7 +184,7 @@ private: protoReq.set_offset(startRowIndex); protoReq.set_result_set_id(ResultId.SetId); protoReq.set_request_id(Cookie); - *protoReq.mutable_deadline() = NProtoInterop::CastToProto(Deadline); + *protoReq.mutable_deadline() = NProtoInterop::CastToProto(Deadline); return protoReq; } @@ -334,7 +334,7 @@ private: THolder<TProtoBuilder> ResultBuilder; const TResultId ResultId; const TString TraceId; - TInstant Deadline; + TInstant Deadline; TPrivateClient Client; const TInstant StartTime = TInstant::Now(); @@ -361,7 +361,7 @@ NActors::IActor* CreateResultWriter( const NConfig::TPrivateApiConfig& privateApiConfig, const TResultId& resultId, const TVector<TString>& columns, - const TString& traceId, + const TString& traceId, const TInstant& deadline, const NMonitoring::TDynamicCounterPtr& clientCounters) { diff --git a/ydb/core/yq/libs/actors/run_actor.cpp b/ydb/core/yq/libs/actors/run_actor.cpp index 5549f8f254..2cfb1edb54 100644 --- a/ydb/core/yq/libs/actors/run_actor.cpp +++ b/ydb/core/yq/libs/actors/run_actor.cpp @@ -156,8 +156,8 @@ public: .Database(Params.PrivateApiConfig.GetTaskServiceDatabase() ? Params.PrivateApiConfig.GetTaskServiceDatabase() : TMaybe<TString>()), Params.ClientCounters), SelfId(), - Params.PingerConfig, - Params.Deadline + Params.PingerConfig, + Params.Deadline )); Become(&TRunActor::StateFuncWrapper<&TRunActor::StateFunc>); try { diff --git a/ydb/core/yq/libs/actors/run_actor_params.cpp b/ydb/core/yq/libs/actors/run_actor_params.cpp index 1446cae1bb..55b5410d51 100644 --- a/ydb/core/yq/libs/actors/run_actor_params.cpp +++ b/ydb/core/yq/libs/actors/run_actor_params.cpp @@ -42,7 +42,7 @@ TRunActorParams::TRunActorParams( int32_t dqGraphIndex, TVector<Yq::Private::TopicConsumer> createdTopicConsumers, bool automatic, - const TString& queryName, + const TString& queryName, const TInstant& deadline, const NMonitoring::TDynamicCounterPtr& clientCounters ) @@ -84,7 +84,7 @@ TRunActorParams::TRunActorParams( , CreatedTopicConsumers(std::move(createdTopicConsumers)) , Automatic(automatic) , QueryName(queryName) - , Deadline(deadline) + , Deadline(deadline) , ClientCounters(clientCounters) { } diff --git a/ydb/core/yq/libs/actors/run_actor_params.h b/ydb/core/yq/libs/actors/run_actor_params.h index bad5c3c32b..2f58785a74 100644 --- a/ydb/core/yq/libs/actors/run_actor_params.h +++ b/ydb/core/yq/libs/actors/run_actor_params.h @@ -56,7 +56,7 @@ struct TRunActorParams { // TODO2 : Change name int32_t dqGraphIndex, TVector<Yq::Private::TopicConsumer> createdTopicConsumers, bool automatic, - const TString& queryName, + const TString& queryName, const TInstant& deadline, const NMonitoring::TDynamicCounterPtr& clientCounters ); @@ -104,7 +104,7 @@ struct TRunActorParams { // TODO2 : Change name bool Automatic = false; TString QueryName; - TInstant Deadline; + TInstant Deadline; const NMonitoring::TDynamicCounterPtr ClientCounters; }; diff --git a/ydb/core/yq/libs/actors/task_get.cpp b/ydb/core/yq/libs/actors/task_get.cpp index d31517aa9f..07faf683ab 100644 --- a/ydb/core/yq/libs/actors/task_get.cpp +++ b/ydb/core/yq/libs/actors/task_get.cpp @@ -10,7 +10,7 @@ #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/actors/core/log.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <ydb/core/yq/libs/common/entity_id.h> diff --git a/ydb/core/yq/libs/actors/task_ping.cpp b/ydb/core/yq/libs/actors/task_ping.cpp index 29410dccd1..33e6a78982 100644 --- a/ydb/core/yq/libs/actors/task_ping.cpp +++ b/ydb/core/yq/libs/actors/task_ping.cpp @@ -1,5 +1,5 @@ #include "proxy_private.h" -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <ydb/core/protos/services.pb.h> #include <ydb/library/yql/public/issue/yql_issue_message.h> @@ -9,7 +9,7 @@ #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/actors/core/log.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <ydb/core/yq/libs/control_plane_storage/control_plane_storage.h> #include <ydb/core/yq/libs/control_plane_storage/events/events.h> @@ -79,7 +79,7 @@ public: OperationId = req.query_id().value(); OwnerId = req.owner_id(); Scope = req.scope(); - Deadline = NProtoInterop::CastFromProto(req.deadline()); + Deadline = NProtoInterop::CastFromProto(req.deadline()); LOG_D("Request CP::PingTask with size: " << req.ByteSize() << " bytes"); RequestedMBytes->Collect(req.ByteSize() / 1024 / 1024); try { @@ -100,7 +100,7 @@ private: ) std::unique_ptr<NYq::TEvControlPlaneStorage::TEvPingTaskRequest> CreateControlPlaneEvent() { - auto event = std::make_unique<NYq::TEvControlPlaneStorage::TEvPingTaskRequest>(Scope, OperationId, OwnerId, Deadline); + auto event = std::make_unique<NYq::TEvControlPlaneStorage::TEvPingTaskRequest>(Scope, OperationId, OwnerId, Deadline); const auto& req = Ev->Record; ui64 issuesByteSize = 0; ui64 transientIssuesByteSize = 0; @@ -225,7 +225,7 @@ private: TString OperationId; TString OwnerId; TString Scope; - TInstant Deadline; + TInstant Deadline; NYql::TIssues Issues; }; diff --git a/ydb/core/yq/libs/actors/task_result_write.cpp b/ydb/core/yq/libs/actors/task_result_write.cpp index 5919ddbaab..c05eed72c0 100644 --- a/ydb/core/yq/libs/actors/task_result_write.cpp +++ b/ydb/core/yq/libs/actors/task_result_write.cpp @@ -9,7 +9,7 @@ #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/actors/core/log.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <ydb/core/yq/libs/control_plane_storage/events/events.h> #include <ydb/core/yq/libs/control_plane_storage/control_plane_storage.h> @@ -71,11 +71,11 @@ public: PassAway(); } - void Bootstrap(const TActorContext&) { + void Bootstrap(const TActorContext&) { Become(&TWriteTaskRequestActor::StateFunc); const auto& req = Ev->Record; - Deadline = NProtoInterop::CastFromProto(req.deadline()); + Deadline = NProtoInterop::CastFromProto(req.deadline()); const auto& resultSet = req.result_set(); ResultId = req.result_id().value(); diff --git a/ydb/core/yq/libs/config/protos/control_plane_storage.proto b/ydb/core/yq/libs/config/protos/control_plane_storage.proto index ebced909c5..762aa9b303 100644 --- a/ydb/core/yq/libs/config/protos/control_plane_storage.proto +++ b/ydb/core/yq/libs/config/protos/control_plane_storage.proto @@ -32,5 +32,5 @@ message TControlPlaneStorageConfig { string TaskLeaseTtl = 21; repeated string AvailableConnection = 22; repeated string AvailableBinding = 23; - string ResultSetsTtl = 24; + string ResultSetsTtl = 24; } diff --git a/ydb/core/yq/libs/config/protos/issue_id.proto b/ydb/core/yq/libs/config/protos/issue_id.proto index e4090be506..742b421a5a 100644 --- a/ydb/core/yq/libs/config/protos/issue_id.proto +++ b/ydb/core/yq/libs/config/protos/issue_id.proto @@ -14,7 +14,7 @@ message TIssuesIds { INTERNAL_ERROR = 1001; TIMEOUT = 1002; BAD_REQUEST = 1003; - EXPIRED = 1004; + EXPIRED = 1004; UNSUPPORTED = 1005; } -} +} diff --git a/ydb/core/yq/libs/control_plane_proxy/control_plane_proxy.cpp b/ydb/core/yq/libs/control_plane_proxy/control_plane_proxy.cpp index 53838351b4..884c50ebaa 100644 --- a/ydb/core/yq/libs/control_plane_proxy/control_plane_proxy.cpp +++ b/ydb/core/yq/libs/control_plane_proxy/control_plane_proxy.cpp @@ -262,13 +262,13 @@ class TControlPlaneProxyActor : public NActors::TActorBootstrapped<TControlPlane RT_CREATE_QUERY, RT_LIST_QUERIES, RT_DESCRIBE_QUERY, - RT_GET_QUERY_STATUS, + RT_GET_QUERY_STATUS, RT_MODIFY_QUERY, RT_DELETE_QUERY, RT_CONTROL_QUERY, RT_GET_RESULT_DATA, RT_LIST_JOBS, - RT_DESCRIBE_JOB, + RT_DESCRIBE_JOB, RT_CREATE_CONNECTION, RT_LIST_CONNECTIONS, RT_DESCRIBE_CONNECTION, @@ -289,13 +289,13 @@ class TControlPlaneProxyActor : public NActors::TActorBootstrapped<TControlPlane { MakeIntrusive<TRequestCounters>("CreateQuery") }, { MakeIntrusive<TRequestCounters>("ListQueries") }, { MakeIntrusive<TRequestCounters>("DescribeQuery") }, - { MakeIntrusive<TRequestCounters>("GetQueryStatus") }, + { MakeIntrusive<TRequestCounters>("GetQueryStatus") }, { MakeIntrusive<TRequestCounters>("ModifyQuery") }, { MakeIntrusive<TRequestCounters>("DeleteQuery") }, { MakeIntrusive<TRequestCounters>("ControlQuery") }, { MakeIntrusive<TRequestCounters>("GetResultData") }, { MakeIntrusive<TRequestCounters>("ListJobs") }, - { MakeIntrusive<TRequestCounters>("DescribeJob") }, + { MakeIntrusive<TRequestCounters>("DescribeJob") }, { MakeIntrusive<TRequestCounters>("CreateConnection") }, { MakeIntrusive<TRequestCounters>("ListConnections") }, { MakeIntrusive<TRequestCounters>("DescribeConnection") }, @@ -353,13 +353,13 @@ private: hFunc(TEvControlPlaneProxy::TEvCreateQueryRequest, Handle); hFunc(TEvControlPlaneProxy::TEvListQueriesRequest, Handle); hFunc(TEvControlPlaneProxy::TEvDescribeQueryRequest, Handle); - hFunc(TEvControlPlaneProxy::TEvGetQueryStatusRequest, Handle); + hFunc(TEvControlPlaneProxy::TEvGetQueryStatusRequest, Handle); hFunc(TEvControlPlaneProxy::TEvModifyQueryRequest, Handle); hFunc(TEvControlPlaneProxy::TEvDeleteQueryRequest, Handle); hFunc(TEvControlPlaneProxy::TEvControlQueryRequest, Handle); hFunc(TEvControlPlaneProxy::TEvGetResultDataRequest, Handle); hFunc(TEvControlPlaneProxy::TEvListJobsRequest, Handle); - hFunc(TEvControlPlaneProxy::TEvDescribeJobRequest, Handle); + hFunc(TEvControlPlaneProxy::TEvDescribeJobRequest, Handle); hFunc(TEvControlPlaneProxy::TEvCreateConnectionRequest, Handle); hFunc(TEvControlPlaneProxy::TEvListConnectionsRequest, Handle); hFunc(TEvControlPlaneProxy::TEvDescribeConnectionRequest, Handle); @@ -413,7 +413,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvCreateQueryRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::CreateQueryRequest request = std::move(ev->Get()->Request); CPP_LOG_T("CreateQueryRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_CREATE_QUERY]; @@ -433,7 +433,7 @@ private: CPS_LOG_E("CreateQueryRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvCreateQueryResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -451,7 +451,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvListQueriesRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ListQueriesRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ListQueriesRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_LIST_QUERIES]; @@ -471,7 +471,7 @@ private: CPS_LOG_E("ListQueriesRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvListQueriesResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -489,7 +489,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvDescribeQueryRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::DescribeQueryRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DescribeQueryRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_QUERY]; @@ -510,7 +510,7 @@ private: CPS_LOG_E("DescribeQueryRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvDescribeQueryResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -527,47 +527,47 @@ private: ExtractPermissions(ev))); } - void Handle(TEvControlPlaneProxy::TEvGetQueryStatusRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); - YandexQuery::GetQueryStatusRequest request = std::move(ev->Get()->Request); - CPP_LOG_T("GetStatusRequest: " << request.DebugString()); - TRequestCountersPtr requestCounters = Counters.Requests[RT_GET_QUERY_STATUS]; - - const TString folderId = ev->Get()->FolderId; - const TString scope = "yandexcloud://" + folderId; - TString user = std::move(ev->Get()->User); - TString token = std::move(ev->Get()->Token); - const TString queryId = request.query_id(); - const int byteSize = request.ByteSize(); - - auto probe = [=](const TDuration& delta, bool isSuccess, bool isTimeout) { - LWPROBE(GetQueryStatusRequest, scope, user, queryId, delta, byteSize, isSuccess, isTimeout); - }; - - NYql::TIssues issues = ValidatePermissions(ev, {"yq.queries.getStatus@as"}); - if (issues) { - CPS_LOG_E("GetQueryStatusRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); - Send(ev->Sender, new TEvControlPlaneProxy::TEvGetQueryStatusResponse(issues), 0, ev->Cookie); - requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; - requestCounters->LatencyMs->Collect(delta.MilliSeconds()); - probe(delta, false, false); - return; - } - - Register(new TRequestActor<YandexQuery::GetQueryStatusRequest, - TEvControlPlaneStorage::TEvGetQueryStatusRequest, - TEvControlPlaneStorage::TEvGetQueryStatusResponse, - TEvControlPlaneProxy::TEvGetQueryStatusResponse>(Config, ev->Sender, ev->Cookie, scope, folderId, - std::move(request), std::move(user), std::move(token), - ControlPlaneStorageServiceActorId(), - requestCounters, - probe, - ExtractPermissions(ev))); - } - + void Handle(TEvControlPlaneProxy::TEvGetQueryStatusRequest::TPtr& ev) { + TInstant startTime = TInstant::Now(); + YandexQuery::GetQueryStatusRequest request = std::move(ev->Get()->Request); + CPP_LOG_T("GetStatusRequest: " << request.DebugString()); + TRequestCountersPtr requestCounters = Counters.Requests[RT_GET_QUERY_STATUS]; + + const TString folderId = ev->Get()->FolderId; + const TString scope = "yandexcloud://" + folderId; + TString user = std::move(ev->Get()->User); + TString token = std::move(ev->Get()->Token); + const TString queryId = request.query_id(); + const int byteSize = request.ByteSize(); + + auto probe = [=](const TDuration& delta, bool isSuccess, bool isTimeout) { + LWPROBE(GetQueryStatusRequest, scope, user, queryId, delta, byteSize, isSuccess, isTimeout); + }; + + NYql::TIssues issues = ValidatePermissions(ev, {"yq.queries.getStatus@as"}); + if (issues) { + CPS_LOG_E("GetQueryStatusRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); + Send(ev->Sender, new TEvControlPlaneProxy::TEvGetQueryStatusResponse(issues), 0, ev->Cookie); + requestCounters->Error->Inc(); + TDuration delta = TInstant::Now() - startTime; + requestCounters->LatencyMs->Collect(delta.MilliSeconds()); + probe(delta, false, false); + return; + } + + Register(new TRequestActor<YandexQuery::GetQueryStatusRequest, + TEvControlPlaneStorage::TEvGetQueryStatusRequest, + TEvControlPlaneStorage::TEvGetQueryStatusResponse, + TEvControlPlaneProxy::TEvGetQueryStatusResponse>(Config, ev->Sender, ev->Cookie, scope, folderId, + std::move(request), std::move(user), std::move(token), + ControlPlaneStorageServiceActorId(), + requestCounters, + probe, + ExtractPermissions(ev))); + } + void Handle(TEvControlPlaneProxy::TEvModifyQueryRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ModifyQueryRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ModifyQueryRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_MODIFY_QUERY]; @@ -588,7 +588,7 @@ private: CPS_LOG_E("ModifyQueryRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvModifyQueryResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -606,7 +606,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvDeleteQueryRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::DeleteQueryRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DeleteQueryRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_DELETE_QUERY]; @@ -627,7 +627,7 @@ private: CPS_LOG_E("DeleteQueryRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvDeleteQueryResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -645,7 +645,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvControlQueryRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ControlQueryRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ControlQueryRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_CONTROL_QUERY]; @@ -666,7 +666,7 @@ private: CPS_LOG_E("ControlQueryRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvControlQueryResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -684,7 +684,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvGetResultDataRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::GetResultDataRequest request = std::move(ev->Get()->Request); CPP_LOG_T("GetResultDataRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_GET_RESULT_DATA]; @@ -708,7 +708,7 @@ private: CPS_LOG_E("GetResultDataRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvGetResultDataResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -726,7 +726,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvListJobsRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ListJobsRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ListJobsRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_LIST_JOBS]; @@ -747,7 +747,7 @@ private: CPS_LOG_E("ListJobsRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvListJobsResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -764,47 +764,47 @@ private: ExtractPermissions(ev))); } - void Handle(TEvControlPlaneProxy::TEvDescribeJobRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); - YandexQuery::DescribeJobRequest request = std::move(ev->Get()->Request); + void Handle(TEvControlPlaneProxy::TEvDescribeJobRequest::TPtr& ev) { + TInstant startTime = TInstant::Now(); + YandexQuery::DescribeJobRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DescribeJobRequest: " << request.DebugString()); - TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_JOB]; - - const TString folderId = ev->Get()->FolderId; - const TString scope = "yandexcloud://" + folderId; - TString user = std::move(ev->Get()->User); - TString token = std::move(ev->Get()->Token); - const TString jobId = request.job_id(); - const int byteSize = request.ByteSize(); - - auto probe = [=](const TDuration& delta, bool isSuccess, bool isTimeout) { - LWPROBE(DescribeJobRequest, scope, user, jobId, delta, byteSize, isSuccess, isTimeout); - }; - + TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_JOB]; + + const TString folderId = ev->Get()->FolderId; + const TString scope = "yandexcloud://" + folderId; + TString user = std::move(ev->Get()->User); + TString token = std::move(ev->Get()->Token); + const TString jobId = request.job_id(); + const int byteSize = request.ByteSize(); + + auto probe = [=](const TDuration& delta, bool isSuccess, bool isTimeout) { + LWPROBE(DescribeJobRequest, scope, user, jobId, delta, byteSize, isSuccess, isTimeout); + }; + NYql::TIssues issues = ValidatePermissions(ev, {"yq.jobs.get@as"}); - if (issues) { - CPS_LOG_E("DescribeJobRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); - Send(ev->Sender, new TEvControlPlaneProxy::TEvDescribeJobResponse(issues), 0, ev->Cookie); - requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; - requestCounters->LatencyMs->Collect(delta.MilliSeconds()); - probe(delta, false, false); - return; - } - - Register(new TRequestActor<YandexQuery::DescribeJobRequest, - TEvControlPlaneStorage::TEvDescribeJobRequest, - TEvControlPlaneStorage::TEvDescribeJobResponse, - TEvControlPlaneProxy::TEvDescribeJobResponse>(Config, ev->Sender, ev->Cookie, scope, folderId, - std::move(request), std::move(user), std::move(token), - ControlPlaneStorageServiceActorId(), - requestCounters, + if (issues) { + CPS_LOG_E("DescribeJobRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); + Send(ev->Sender, new TEvControlPlaneProxy::TEvDescribeJobResponse(issues), 0, ev->Cookie); + requestCounters->Error->Inc(); + TDuration delta = TInstant::Now() - startTime; + requestCounters->LatencyMs->Collect(delta.MilliSeconds()); + probe(delta, false, false); + return; + } + + Register(new TRequestActor<YandexQuery::DescribeJobRequest, + TEvControlPlaneStorage::TEvDescribeJobRequest, + TEvControlPlaneStorage::TEvDescribeJobResponse, + TEvControlPlaneProxy::TEvDescribeJobResponse>(Config, ev->Sender, ev->Cookie, scope, folderId, + std::move(request), std::move(user), std::move(token), + ControlPlaneStorageServiceActorId(), + requestCounters, probe, ExtractPermissions(ev))); - } - + } + void Handle(TEvControlPlaneProxy::TEvCreateConnectionRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::CreateConnectionRequest request = std::move(ev->Get()->Request); CPP_LOG_T("CreateConnectionRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_CREATE_CONNECTION]; @@ -829,7 +829,7 @@ private: CPS_LOG_E("CreateConnectionRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvCreateConnectionResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -847,7 +847,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvListConnectionsRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ListConnectionsRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ListConnectionsRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_LIST_CONNECTIONS]; @@ -867,7 +867,7 @@ private: CPS_LOG_E("ListConnectionsRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvListConnectionsResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -885,7 +885,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvDescribeConnectionRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::DescribeConnectionRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DescribeConnectionRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_CONNECTION]; @@ -906,7 +906,7 @@ private: CPS_LOG_E("DescribeConnectionRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvDescribeConnectionResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -924,7 +924,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvModifyConnectionRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ModifyConnectionRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ModifyConnectionRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_MODIFY_CONNECTION]; @@ -950,7 +950,7 @@ private: CPS_LOG_E("ModifyConnectionRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvModifyConnectionResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -968,7 +968,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvDeleteConnectionRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::DeleteConnectionRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DeleteConnectionRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_DELETE_CONNECTION]; @@ -989,7 +989,7 @@ private: CPS_LOG_E("DeleteConnectionRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvDeleteConnectionResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -1050,7 +1050,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvCreateBindingRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::CreateBindingRequest request = std::move(ev->Get()->Request); CPP_LOG_T("CreateBindingRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_CREATE_BINDING]; @@ -1070,7 +1070,7 @@ private: CPS_LOG_E("CreateBindingRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvCreateBindingResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -1088,7 +1088,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvListBindingsRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ListBindingsRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ListBindingsRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_LIST_BINDINGS]; @@ -1108,7 +1108,7 @@ private: CPS_LOG_E("ListBindingsRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvListBindingsResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -1126,7 +1126,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvDescribeBindingRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::DescribeBindingRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DescribeBindingRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_BINDING]; @@ -1147,7 +1147,7 @@ private: CPS_LOG_E("DescribeBindingRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvDescribeBindingResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -1165,7 +1165,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvModifyBindingRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::ModifyBindingRequest request = std::move(ev->Get()->Request); CPP_LOG_T("ModifyBindingRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_MODIFY_BINDING]; @@ -1186,7 +1186,7 @@ private: CPS_LOG_E("ModifyBindingRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvModifyBindingResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; @@ -1204,7 +1204,7 @@ private: } void Handle(TEvControlPlaneProxy::TEvDeleteBindingRequest::TPtr& ev) { - TInstant startTime = TInstant::Now(); + TInstant startTime = TInstant::Now(); YandexQuery::DeleteBindingRequest request = std::move(ev->Get()->Request); CPP_LOG_T("DeleteBindingRequest: " << request.DebugString()); TRequestCountersPtr requestCounters = Counters.Requests[RT_DELETE_BINDING]; @@ -1225,7 +1225,7 @@ private: CPS_LOG_E("DeleteBindingRequest, validation failed: " << scope << " " << user << " " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); Send(ev->Sender, new TEvControlPlaneProxy::TEvDeleteBindingResponse(issues), 0, ev->Cookie); requestCounters->Error->Inc(); - TDuration delta = TInstant::Now() - startTime; + TDuration delta = TInstant::Now() - startTime; requestCounters->LatencyMs->Collect(delta.MilliSeconds()); probe(delta, false, false); return; diff --git a/ydb/core/yq/libs/control_plane_proxy/events/events.h b/ydb/core/yq/libs/control_plane_proxy/events/events.h index aeb922e784..c335a897ab 100644 --- a/ydb/core/yq/libs/control_plane_proxy/events/events.h +++ b/ydb/core/yq/libs/control_plane_proxy/events/events.h @@ -21,8 +21,8 @@ struct TEvControlPlaneProxy { EvListQueriesResponse, EvDescribeQueryRequest, EvDescribeQueryResponse, - EvGetQueryStatusRequest, - EvGetQueryStatusResponse, + EvGetQueryStatusRequest, + EvGetQueryStatusResponse, EvModifyQueryRequest, EvModifyQueryResponse, EvDeleteQueryRequest, @@ -33,8 +33,8 @@ struct TEvControlPlaneProxy { EvGetResultDataResponse, EvListJobsRequest, EvListJobsResponse, - EvDescribeJobRequest, - EvDescribeJobResponse, + EvDescribeJobRequest, + EvDescribeJobResponse, EvCreateConnectionRequest, EvCreateConnectionResponse, EvListConnectionsRequest, @@ -173,42 +173,42 @@ struct TEvControlPlaneProxy { NYql::TIssues Issues; }; - struct TEvGetQueryStatusRequest : NActors::TEventLocal<TEvGetQueryStatusRequest, EvGetQueryStatusRequest> { - explicit TEvGetQueryStatusRequest(const TString& folderId, - const YandexQuery::GetQueryStatusRequest& request, - const TString& user, - const TString& token, - const TVector<TString>& permissions) - : FolderId(folderId) - , Request(request) - , User(user) - , Token(token) - , Permissions(permissions) - { - } - - TString FolderId; - YandexQuery::GetQueryStatusRequest Request; - TString User; - TString Token; - TVector<TString> Permissions; - }; - - struct TEvGetQueryStatusResponse : NActors::TEventLocal<TEvGetQueryStatusResponse, EvGetQueryStatusResponse> { - explicit TEvGetQueryStatusResponse(const YandexQuery::GetQueryStatusResult& result) - : Result(result) - { - } - - explicit TEvGetQueryStatusResponse(const NYql::TIssues& issues) - : Issues(issues) - { - } - - YandexQuery::GetQueryStatusResult Result; - NYql::TIssues Issues; - }; - + struct TEvGetQueryStatusRequest : NActors::TEventLocal<TEvGetQueryStatusRequest, EvGetQueryStatusRequest> { + explicit TEvGetQueryStatusRequest(const TString& folderId, + const YandexQuery::GetQueryStatusRequest& request, + const TString& user, + const TString& token, + const TVector<TString>& permissions) + : FolderId(folderId) + , Request(request) + , User(user) + , Token(token) + , Permissions(permissions) + { + } + + TString FolderId; + YandexQuery::GetQueryStatusRequest Request; + TString User; + TString Token; + TVector<TString> Permissions; + }; + + struct TEvGetQueryStatusResponse : NActors::TEventLocal<TEvGetQueryStatusResponse, EvGetQueryStatusResponse> { + explicit TEvGetQueryStatusResponse(const YandexQuery::GetQueryStatusResult& result) + : Result(result) + { + } + + explicit TEvGetQueryStatusResponse(const NYql::TIssues& issues) + : Issues(issues) + { + } + + YandexQuery::GetQueryStatusResult Result; + NYql::TIssues Issues; + }; + struct TEvModifyQueryRequest : NActors::TEventLocal<TEvModifyQueryRequest, EvModifyQueryRequest> { explicit TEvModifyQueryRequest(const TString& folderId, const YandexQuery::ModifyQueryRequest& request, @@ -398,42 +398,42 @@ struct TEvControlPlaneProxy { NYql::TIssues Issues; }; - struct TEvDescribeJobRequest : NActors::TEventLocal<TEvDescribeJobRequest, EvDescribeJobRequest> { - explicit TEvDescribeJobRequest(const TString& folderId, - const YandexQuery::DescribeJobRequest& request, - const TString& user, - const TString& token, - const TVector<TString>& permissions) - : FolderId(folderId) - , Request(request) - , User(user) - , Token(token) - , Permissions(permissions) - { - } - - TString FolderId; - YandexQuery::DescribeJobRequest Request; - TString User; - TString Token; - TVector<TString> Permissions; - }; - - struct TEvDescribeJobResponse : NActors::TEventLocal<TEvDescribeJobResponse, EvDescribeJobResponse> { - explicit TEvDescribeJobResponse(const YandexQuery::DescribeJobResult& result) - : Result(result) - { - } - - explicit TEvDescribeJobResponse(const NYql::TIssues& issues) - : Issues(issues) - { - } - - YandexQuery::DescribeJobResult Result; - NYql::TIssues Issues; - }; - + struct TEvDescribeJobRequest : NActors::TEventLocal<TEvDescribeJobRequest, EvDescribeJobRequest> { + explicit TEvDescribeJobRequest(const TString& folderId, + const YandexQuery::DescribeJobRequest& request, + const TString& user, + const TString& token, + const TVector<TString>& permissions) + : FolderId(folderId) + , Request(request) + , User(user) + , Token(token) + , Permissions(permissions) + { + } + + TString FolderId; + YandexQuery::DescribeJobRequest Request; + TString User; + TString Token; + TVector<TString> Permissions; + }; + + struct TEvDescribeJobResponse : NActors::TEventLocal<TEvDescribeJobResponse, EvDescribeJobResponse> { + explicit TEvDescribeJobResponse(const YandexQuery::DescribeJobResult& result) + : Result(result) + { + } + + explicit TEvDescribeJobResponse(const NYql::TIssues& issues) + : Issues(issues) + { + } + + YandexQuery::DescribeJobResult Result; + NYql::TIssues Issues; + }; + struct TEvCreateConnectionRequest : NActors::TEventLocal<TEvCreateConnectionRequest, EvCreateConnectionRequest> { explicit TEvCreateConnectionRequest(const TString& folderId, const YandexQuery::CreateConnectionRequest& request, diff --git a/ydb/core/yq/libs/control_plane_proxy/probes.h b/ydb/core/yq/libs/control_plane_proxy/probes.h index 1d790f6f93..2785a4bf2c 100644 --- a/ydb/core/yq/libs/control_plane_proxy/probes.h +++ b/ydb/core/yq/libs/control_plane_proxy/probes.h @@ -15,10 +15,10 @@ GROUPS(), \ TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ NAMES("scope", "user", "queryId", "latencyMs", "size", "success", "timeout")) \ - PROBE(GetQueryStatusRequest, \ - GROUPS(), \ - TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ - NAMES("scope", "user", "queryId", "latencyMs", "size", "success", "timeout")) \ + PROBE(GetQueryStatusRequest, \ + GROUPS(), \ + TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ + NAMES("scope", "user", "queryId", "latencyMs", "size", "success", "timeout")) \ PROBE(ModifyQueryRequest, \ GROUPS(), \ TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ @@ -39,10 +39,10 @@ GROUPS(), \ TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ NAMES("scope", "user", "queryId", "latencyMs", "size", "success", "timeout")) \ - PROBE(DescribeJobRequest, \ - GROUPS(), \ - TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ - NAMES("scope", "user", "jobId", "latencyMs", "size", "success", "timeout")) \ + PROBE(DescribeJobRequest, \ + GROUPS(), \ + TYPES(TString, TString, TString, TDuration, i64, bool, bool), \ + NAMES("scope", "user", "jobId", "latencyMs", "size", "success", "timeout")) \ PROBE(CreateConnectionRequest, \ GROUPS(), \ TYPES(TString, TString, TDuration, i64, bool, bool), \ diff --git a/ydb/core/yq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp b/ydb/core/yq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp index 3d0c5bb70b..a86952c8a3 100644 --- a/ydb/core/yq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp +++ b/ydb/core/yq/libs/control_plane_proxy/ut/control_plane_proxy_ut.cpp @@ -132,16 +132,16 @@ struct TTestBootstrap { Runtime->DispatchEvents({}, TDuration::Zero()); } - void SendGetQueryStatusRequest(const TVector<TString>& permissions = {}) - { - TActorId sender = Runtime->AllocateEdgeActor(); - YandexQuery::GetQueryStatusRequest proto; - - auto request = std::make_unique<TEvControlPlaneProxy::TEvGetQueryStatusRequest>("my_folder", proto, "test_user@staff", "", permissions); - Runtime->Send(new IEventHandle(ControlPlaneProxyActorId(), sender, request.release())); - Runtime->DispatchEvents({}, TDuration::Zero()); - } - + void SendGetQueryStatusRequest(const TVector<TString>& permissions = {}) + { + TActorId sender = Runtime->AllocateEdgeActor(); + YandexQuery::GetQueryStatusRequest proto; + + auto request = std::make_unique<TEvControlPlaneProxy::TEvGetQueryStatusRequest>("my_folder", proto, "test_user@staff", "", permissions); + Runtime->Send(new IEventHandle(ControlPlaneProxyActorId(), sender, request.release())); + Runtime->DispatchEvents({}, TDuration::Zero()); + } + void SendModifyQueryRequest(const TVector<TString>& permissions = {}) { TActorId sender = Runtime->AllocateEdgeActor(); @@ -193,16 +193,16 @@ struct TTestBootstrap { Runtime->DispatchEvents({}, TDuration::Zero()); } - void SendDescribeJobRequest(const TVector<TString>& permissions = {}) - { - TActorId sender = Runtime->AllocateEdgeActor(); - YandexQuery::DescribeJobRequest proto; - - auto request = std::make_unique<TEvControlPlaneProxy::TEvDescribeJobRequest>("my_folder", proto, "test_user@staff", "", permissions); - Runtime->Send(new IEventHandle(ControlPlaneProxyActorId(), sender, request.release())); - Runtime->DispatchEvents({}, TDuration::Zero()); - } - + void SendDescribeJobRequest(const TVector<TString>& permissions = {}) + { + TActorId sender = Runtime->AllocateEdgeActor(); + YandexQuery::DescribeJobRequest proto; + + auto request = std::make_unique<TEvControlPlaneProxy::TEvDescribeJobRequest>("my_folder", proto, "test_user@staff", "", permissions); + Runtime->Send(new IEventHandle(ControlPlaneProxyActorId(), sender, request.release())); + Runtime->DispatchEvents({}, TDuration::Zero()); + } + void SendCreateConnectionRequest(const TVector<TString>& permissions = {}, const TString& serviceAccountId = {}) { TActorId sender = Runtime->AllocateEdgeActor(); @@ -415,15 +415,15 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyTest) { UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); } - Y_UNIT_TEST(ShouldSendGetQueryStatus) - { - TTestBootstrap bootstrap; - bootstrap.SendGetQueryStatusRequest(); - auto request = bootstrap.MetaStorageGrab->GetRequest(); - auto event = request->Get<TEvControlPlaneStorage::TEvGetQueryStatusRequest>(); - UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); - } - + Y_UNIT_TEST(ShouldSendGetQueryStatus) + { + TTestBootstrap bootstrap; + bootstrap.SendGetQueryStatusRequest(); + auto request = bootstrap.MetaStorageGrab->GetRequest(); + auto event = request->Get<TEvControlPlaneStorage::TEvGetQueryStatusRequest>(); + UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); + } + Y_UNIT_TEST(ShouldSendModifyQuery) { TTestBootstrap bootstrap; @@ -469,15 +469,15 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyTest) { UNIT_ASSERT_VALUES_EQUAL(event->Request.query_id(), "my_query_id"); } - Y_UNIT_TEST(ShouldSendDescribeJob) - { - TTestBootstrap bootstrap; - bootstrap.SendDescribeJobRequest(); - auto request = bootstrap.MetaStorageGrab->GetRequest(); - auto event = request->Get<TEvControlPlaneStorage::TEvDescribeJobRequest>(); - UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); - } - + Y_UNIT_TEST(ShouldSendDescribeJob) + { + TTestBootstrap bootstrap; + bootstrap.SendDescribeJobRequest(); + auto request = bootstrap.MetaStorageGrab->GetRequest(); + auto event = request->Get<TEvControlPlaneStorage::TEvDescribeJobRequest>(); + UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); + } + Y_UNIT_TEST(ShouldSendCreateConnection) { TTestBootstrap bootstrap; @@ -585,8 +585,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendCreateQueryRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvCreateQueryResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvCreateQueryResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendListQueries) @@ -595,8 +595,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendListQueriesRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListQueriesResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListQueriesResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendDescribeQuery) @@ -605,28 +605,28 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendDescribeQueryRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeQueryResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); - } - - Y_UNIT_TEST(ShouldSendGetQueryStatus) - { - NConfig::TControlPlaneProxyConfig config; - config.SetEnablePermissions(true); - TTestBootstrap bootstrap(config); - bootstrap.SendGetQueryStatusRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvGetQueryStatusResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); - } - + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeQueryResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + } + + Y_UNIT_TEST(ShouldSendGetQueryStatus) + { + NConfig::TControlPlaneProxyConfig config; + config.SetEnablePermissions(true); + TTestBootstrap bootstrap(config); + bootstrap.SendGetQueryStatusRequest(); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvGetQueryStatusResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + } + Y_UNIT_TEST(ShouldSendModifyQuery) { NConfig::TControlPlaneProxyConfig config; config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendModifyQueryRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvModifyQueryResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvModifyQueryResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendDeleteQuery) @@ -635,8 +635,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendDeleteQueryRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDeleteQueryResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDeleteQueryResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendControlQuery) @@ -645,8 +645,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendControlQueryRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvControlQueryResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvControlQueryResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendGetResultData) @@ -655,8 +655,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendGetResultDataRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvGetResultDataResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvGetResultDataResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendListJobs) @@ -665,28 +665,28 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendListJobsRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListJobsResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListJobsResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } - Y_UNIT_TEST(ShouldSendDescribeJob) - { + Y_UNIT_TEST(ShouldSendDescribeJob) + { NConfig::TControlPlaneProxyConfig config; - config.SetEnablePermissions(true); - TTestBootstrap bootstrap(config); - bootstrap.SendDescribeJobRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeJobResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); - } - + config.SetEnablePermissions(true); + TTestBootstrap bootstrap(config); + bootstrap.SendDescribeJobRequest(); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeJobResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + } + Y_UNIT_TEST(ShouldSendCreateConnection) { NConfig::TControlPlaneProxyConfig config; config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendCreateConnectionRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvCreateConnectionResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvCreateConnectionResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendCreateConnectionWithServiceAccount) @@ -705,8 +705,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendListConnectionsRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListConnectionsResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListConnectionsResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendDescribeConnection) @@ -715,8 +715,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendDescribeConnectionRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeConnectionResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeConnectionResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendModifyConnection) @@ -725,8 +725,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendModifyConnectionRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvModifyConnectionResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvModifyConnectionResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendModifyConnectionWithServiceAccount) @@ -745,8 +745,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendDeleteConnectionRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDeleteConnectionResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDeleteConnectionResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendTestConnection) @@ -775,8 +775,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendCreateBindingRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvCreateBindingResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvCreateBindingResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendListBindings) @@ -785,8 +785,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendListBindingsRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListBindingsResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvListBindingsResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendDescribeBinding) @@ -795,8 +795,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendDescribeBindingRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeBindingResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDescribeBindingResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendModifyBinding) @@ -805,8 +805,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendModifyBindingRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvModifyBindingResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvModifyBindingResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } Y_UNIT_TEST(ShouldSendDeleteBinding) @@ -815,8 +815,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsFailed) { config.SetEnablePermissions(true); TTestBootstrap bootstrap(config); bootstrap.SendDeleteBindingRequest(); - const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDeleteBindingResponse>(); - UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); + const auto [_, response] = bootstrap.Grab<TEvControlPlaneProxy::TEvDeleteBindingResponse>(); + UNIT_ASSERT_STRING_CONTAINS(response->Issues.ToString(), "Error: No permission"); } }; @@ -881,26 +881,26 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsSuccess) { UNIT_ASSERT(!permissions.Check(TPermissions::QUERY_INVOKE)); } - Y_UNIT_TEST(ShouldSendGetQueryStatus) - { - NConfig::TControlPlaneProxyConfig config; - config.SetEnablePermissions(true); - TTestBootstrap bootstrap(config); - bootstrap.SendGetQueryStatusRequest({"yq.queries.getStatus@as"}); - auto request = bootstrap.MetaStorageGrab->GetRequest(); - auto event = request->Get<TEvControlPlaneStorage::TEvGetQueryStatusRequest>(); - auto permissions = event->Permissions; - UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); - UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_PUBLIC)); - UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_PRIVATE)); - UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_AST)); - UNIT_ASSERT(!permissions.Check(TPermissions::MANAGE_PUBLIC)); - UNIT_ASSERT(!permissions.Check(TPermissions::MANAGE_PRIVATE)); - UNIT_ASSERT(!permissions.Check(TPermissions::CONNECTIONS_USE)); - UNIT_ASSERT(!permissions.Check(TPermissions::BINDINGS_USE)); - UNIT_ASSERT(!permissions.Check(TPermissions::QUERY_INVOKE)); - } - + Y_UNIT_TEST(ShouldSendGetQueryStatus) + { + NConfig::TControlPlaneProxyConfig config; + config.SetEnablePermissions(true); + TTestBootstrap bootstrap(config); + bootstrap.SendGetQueryStatusRequest({"yq.queries.getStatus@as"}); + auto request = bootstrap.MetaStorageGrab->GetRequest(); + auto event = request->Get<TEvControlPlaneStorage::TEvGetQueryStatusRequest>(); + auto permissions = event->Permissions; + UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); + UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_PUBLIC)); + UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_PRIVATE)); + UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_AST)); + UNIT_ASSERT(!permissions.Check(TPermissions::MANAGE_PUBLIC)); + UNIT_ASSERT(!permissions.Check(TPermissions::MANAGE_PRIVATE)); + UNIT_ASSERT(!permissions.Check(TPermissions::CONNECTIONS_USE)); + UNIT_ASSERT(!permissions.Check(TPermissions::BINDINGS_USE)); + UNIT_ASSERT(!permissions.Check(TPermissions::QUERY_INVOKE)); + } + Y_UNIT_TEST(ShouldSendModifyQuery) { NConfig::TControlPlaneProxyConfig config; @@ -1001,16 +1001,16 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsSuccess) { UNIT_ASSERT(!permissions.Check(TPermissions::QUERY_INVOKE)); } - Y_UNIT_TEST(ShouldSendDescribeJob) - { + Y_UNIT_TEST(ShouldSendDescribeJob) + { NConfig::TControlPlaneProxyConfig config; - config.SetEnablePermissions(true); - TTestBootstrap bootstrap(config); - bootstrap.SendDescribeJobRequest({"yq.jobs.get@as"}); - auto request = bootstrap.MetaStorageGrab->GetRequest(); - auto event = request->Get<TEvControlPlaneStorage::TEvDescribeJobRequest>(); + config.SetEnablePermissions(true); + TTestBootstrap bootstrap(config); + bootstrap.SendDescribeJobRequest({"yq.jobs.get@as"}); + auto request = bootstrap.MetaStorageGrab->GetRequest(); + auto event = request->Get<TEvControlPlaneStorage::TEvDescribeJobRequest>(); auto permissions = event->Permissions; - UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); + UNIT_ASSERT_VALUES_EQUAL(event->Scope, "yandexcloud://my_folder"); UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_PUBLIC)); UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_PRIVATE)); UNIT_ASSERT(!permissions.Check(TPermissions::VIEW_AST)); @@ -1019,8 +1019,8 @@ Y_UNIT_TEST_SUITE(TControlPlaneProxyCheckPermissionsSuccess) { UNIT_ASSERT(!permissions.Check(TPermissions::CONNECTIONS_USE)); UNIT_ASSERT(!permissions.Check(TPermissions::BINDINGS_USE)); UNIT_ASSERT(!permissions.Check(TPermissions::QUERY_INVOKE)); - } - + } + Y_UNIT_TEST(ShouldSendCreateConnection) { NConfig::TControlPlaneProxyConfig config; diff --git a/ydb/core/yq/libs/control_plane_storage/events/events.h b/ydb/core/yq/libs/control_plane_storage/events/events.h index 8c98e790d7..b187fef754 100644 --- a/ydb/core/yq/libs/control_plane_storage/events/events.h +++ b/ydb/core/yq/libs/control_plane_storage/events/events.h @@ -1,6 +1,6 @@ #pragma once -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <util/generic/map.h> #include <util/generic/maybe.h> @@ -101,8 +101,8 @@ struct TEvControlPlaneStorage { EvListQueriesResponse, EvDescribeQueryRequest, EvDescribeQueryResponse, - EvGetQueryStatusRequest, - EvGetQueryStatusResponse, + EvGetQueryStatusRequest, + EvGetQueryStatusResponse, EvModifyQueryRequest, EvModifyQueryResponse, EvDeleteQueryRequest, @@ -113,8 +113,8 @@ struct TEvControlPlaneStorage { EvGetResultDataResponse, EvListJobsRequest, EvListJobsResponse, - EvDescribeJobRequest, - EvDescribeJobResponse, + EvDescribeJobRequest, + EvDescribeJobResponse, EvCreateConnectionRequest, EvCreateConnectionResponse, EvListConnectionsRequest, @@ -267,43 +267,43 @@ struct TEvControlPlaneStorage { TDebugInfoPtr DebugInfo; }; - struct TEvGetQueryStatusRequest : NActors::TEventLocal<TEvGetQueryStatusRequest, EvGetQueryStatusRequest> { - explicit TEvGetQueryStatusRequest(const TString& scope, - const YandexQuery::GetQueryStatusRequest& request, - const TString& user, - const TString& token, - TPermissions permissions) - : Scope(scope) - , Request(request) - , User(user) - , Token(token) - , Permissions(permissions) - { - } - - TString Scope; - YandexQuery::GetQueryStatusRequest Request; - TString User; - TString Token; - TPermissions Permissions; - }; - - struct TEvGetQueryStatusResponse : NActors::TEventLocal<TEvGetQueryStatusResponse, EvGetQueryStatusResponse> { - explicit TEvGetQueryStatusResponse(const YandexQuery::GetQueryStatusResult& result) - : Result(result) - { - } - - explicit TEvGetQueryStatusResponse(const NYql::TIssues& issues) - : Issues(issues) - { - } - - YandexQuery::GetQueryStatusResult Result; - NYql::TIssues Issues; - TDebugInfoPtr DebugInfo; - }; - + struct TEvGetQueryStatusRequest : NActors::TEventLocal<TEvGetQueryStatusRequest, EvGetQueryStatusRequest> { + explicit TEvGetQueryStatusRequest(const TString& scope, + const YandexQuery::GetQueryStatusRequest& request, + const TString& user, + const TString& token, + TPermissions permissions) + : Scope(scope) + , Request(request) + , User(user) + , Token(token) + , Permissions(permissions) + { + } + + TString Scope; + YandexQuery::GetQueryStatusRequest Request; + TString User; + TString Token; + TPermissions Permissions; + }; + + struct TEvGetQueryStatusResponse : NActors::TEventLocal<TEvGetQueryStatusResponse, EvGetQueryStatusResponse> { + explicit TEvGetQueryStatusResponse(const YandexQuery::GetQueryStatusResult& result) + : Result(result) + { + } + + explicit TEvGetQueryStatusResponse(const NYql::TIssues& issues) + : Issues(issues) + { + } + + YandexQuery::GetQueryStatusResult Result; + NYql::TIssues Issues; + TDebugInfoPtr DebugInfo; + }; + struct TEvModifyQueryRequest : NActors::TEventLocal<TEvModifyQueryRequest, EvModifyQueryRequest> { explicit TEvModifyQueryRequest(const TString& scope, const YandexQuery::ModifyQueryRequest& request, @@ -498,43 +498,43 @@ struct TEvControlPlaneStorage { TDebugInfoPtr DebugInfo; }; - struct TEvDescribeJobRequest : NActors::TEventLocal<TEvDescribeJobRequest, EvDescribeJobRequest> { - explicit TEvDescribeJobRequest(const TString& scope, - const YandexQuery::DescribeJobRequest& request, - const TString& user, + struct TEvDescribeJobRequest : NActors::TEventLocal<TEvDescribeJobRequest, EvDescribeJobRequest> { + explicit TEvDescribeJobRequest(const TString& scope, + const YandexQuery::DescribeJobRequest& request, + const TString& user, const TString& token, TPermissions permissions) - : Scope(scope) - , Request(request) - , User(user) - , Token(token) + : Scope(scope) + , Request(request) + , User(user) + , Token(token) , Permissions(permissions) - { - } - - TString Scope; - YandexQuery::DescribeJobRequest Request; - TString User; - TString Token; + { + } + + TString Scope; + YandexQuery::DescribeJobRequest Request; + TString User; + TString Token; TPermissions Permissions; - }; - - struct TEvDescribeJobResponse : NActors::TEventLocal<TEvDescribeJobResponse, EvDescribeJobResponse> { - explicit TEvDescribeJobResponse(const YandexQuery::DescribeJobResult& result) - : Result(result) - { - } - - explicit TEvDescribeJobResponse(const NYql::TIssues& issues) - : Issues(issues) - { - } - - YandexQuery::DescribeJobResult Result; - NYql::TIssues Issues; + }; + + struct TEvDescribeJobResponse : NActors::TEventLocal<TEvDescribeJobResponse, EvDescribeJobResponse> { + explicit TEvDescribeJobResponse(const YandexQuery::DescribeJobResult& result) + : Result(result) + { + } + + explicit TEvDescribeJobResponse(const NYql::TIssues& issues) + : Issues(issues) + { + } + + YandexQuery::DescribeJobResult Result; + NYql::TIssues Issues; TDebugInfoPtr DebugInfo; - }; - + }; + struct TEvCreateConnectionRequest : NActors::TEventLocal<TEvCreateConnectionRequest, EvCreateConnectionRequest> { explicit TEvCreateConnectionRequest(const TString& scope, const YandexQuery::CreateConnectionRequest& request, @@ -989,7 +989,7 @@ struct TEvControlPlaneStorage { YandexQuery::Query Query; YandexQuery::Internal::QueryInternal Internal; ui64 Generation = 0; - TInstant Deadline; + TInstant Deadline; }; struct TEvGetTaskResponse : NActors::TEventLocal<TEvGetTaskResponse, EvGetTaskResponse> { @@ -1023,11 +1023,11 @@ struct TEvControlPlaneStorage { }; struct TEvPingTaskRequest : NActors::TEventLocal<TEvPingTaskRequest, EvPingTaskRequest> { - explicit TEvPingTaskRequest(const TString& scope, const TString& queryId, const TString& owner, const TInstant& deadline, const TString& resultId = "") + explicit TEvPingTaskRequest(const TString& scope, const TString& queryId, const TString& owner, const TInstant& deadline, const TString& resultId = "") : Scope(scope) , QueryId(queryId) , Owner(owner) - , Deadline(deadline) + , Deadline(deadline) , ResultId(resultId) { } @@ -1035,7 +1035,7 @@ struct TEvControlPlaneStorage { const TString Scope; const TString QueryId; const TString Owner; - const TInstant Deadline; + const TInstant Deadline; TString ResultId; TMaybe<YandexQuery::QueryMeta::ComputeStatus> Status; TMaybe<NYql::TIssues> Issues; diff --git a/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp b/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp index 783b924238..b9af47011b 100644 --- a/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp +++ b/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp @@ -4,8 +4,8 @@ #include <util/generic/guid.h> #include <util/generic/set.h> -#include <library/cpp/protobuf/interop/cast.h> - +#include <library/cpp/protobuf/interop/cast.h> + #include <ydb/core/yq/libs/config/yq_issue.h> #include <ydb/core/yq/libs/control_plane_storage/events/events.h> @@ -26,7 +26,7 @@ class TInMemoryControlPlaneStorageActor : public NActors::TActor<TInMemoryContro NConfig::TControlPlaneStorageConfig Proto; TDuration IdempotencyKeyTtl; TDuration AutomaticQueriesTtl; - TDuration ResultSetsTtl; + TDuration ResultSetsTtl; TDuration AnalyticsRetryCounterUpdateTime; TDuration StreamingRetryCounterUpdateTime; TDuration TaskLeaseTtl; @@ -35,7 +35,7 @@ class TInMemoryControlPlaneStorageActor : public NActors::TActor<TInMemoryContro : Proto(FillDefaultParameters(config)) , IdempotencyKeyTtl(GetDuration(Proto.GetIdempotencyKeysTtl(), TDuration::Minutes(10))) , AutomaticQueriesTtl(GetDuration(Proto.GetAutomaticQueriesTtl(), TDuration::Days(1))) - , ResultSetsTtl(GetDuration(Proto.GetResultSetsTtl(), TDuration::Days(1))) + , ResultSetsTtl(GetDuration(Proto.GetResultSetsTtl(), TDuration::Days(1))) , AnalyticsRetryCounterUpdateTime(GetDuration(Proto.GetAnalyticsRetryCounterUpdateTime(), TDuration::Days(1))) , StreamingRetryCounterUpdateTime(GetDuration(Proto.GetAnalyticsRetryCounterUpdateTime(), TDuration::Days(1))) , TaskLeaseTtl(GetDuration(Proto.GetTaskLeaseTtl(), TDuration::Seconds(30))) @@ -120,7 +120,7 @@ private: YandexQuery::CommonMeta& common = *meta.mutable_common(); common.set_id(queryId); common.set_created_by(user); - auto timestamp = NProtoInterop::CastToProto(now); + auto timestamp = NProtoInterop::CastToProto(now); *common.mutable_created_at() = timestamp; common.set_revision(InitialRevision); diff --git a/ydb/core/yq/libs/control_plane_storage/internal/task_get.cpp b/ydb/core/yq/libs/control_plane_storage/internal/task_get.cpp index 42b3c1a1ac..48f992a386 100644 --- a/ydb/core/yq/libs/control_plane_storage/internal/task_get.cpp +++ b/ydb/core/yq/libs/control_plane_storage/internal/task_get.cpp @@ -20,7 +20,7 @@ struct TTaskInternal { TString Owner; TString HostName; TMaybe<YandexQuery::Job> Job; - TInstant Deadline; + TInstant Deadline; }; std::pair<TString, NYdb::TParams> MakeSql(const TTaskInternal& taskInternal) { @@ -66,7 +66,7 @@ std::tuple<TString, NYdb::TParams, std::function<std::pair<TString, NYdb::TParam const TTaskInternal& taskInternal, const std::shared_ptr<TResponseTasks>& responseTasks, const TInstant& taskLeaseTimestamp, - bool disableCurrentIam, + bool disableCurrentIam, const TDuration& automaticQueriesTtl, const TDuration& resultSetsTtl) { @@ -104,7 +104,7 @@ std::tuple<TString, NYdb::TParams, std::function<std::pair<TString, NYdb::TParam throw TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support"; } const TInstant deadline = TInstant::Now() + (task.Query.content().automatic() ? std::min(automaticQueriesTtl, resultSetsTtl) : resultSetsTtl); - task.Deadline = deadline; + task.Deadline = deadline; if (!task.Internal.ParseFromString(*parser.ColumnParser(INTERNAL_COLUMN_NAME).GetOptionalString())) { throw TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support"; } diff --git a/ydb/core/yq/libs/control_plane_storage/internal/task_ping.cpp b/ydb/core/yq/libs/control_plane_storage/internal/task_ping.cpp index 834d40c0f7..b3176d638c 100644 --- a/ydb/core/yq/libs/control_plane_storage/internal/task_ping.cpp +++ b/ydb/core/yq/libs/control_plane_storage/internal/task_ping.cpp @@ -19,7 +19,7 @@ bool IsFinishedStatus(YandexQuery::QueryMeta::ComputeStatus status) { std::tuple<TString, TParams, const std::function<std::pair<TString, NYdb::TParams>(const TVector<NYdb::TResultSet>&)>> ConstructHardPingTask( const TEvControlPlaneStorage::TEvPingTaskRequest* request, std::shared_ptr<YandexQuery::QueryAction> response, - const TString& tablePathPrefix, const TDuration& automaticQueriesTtl) { + const TString& tablePathPrefix, const TDuration& automaticQueriesTtl) { TSqlQueryBuilder readQueryBuilder(tablePathPrefix, "HardPingTask(read)"); readQueryBuilder.AddString("scope", request->Scope); @@ -127,30 +127,30 @@ std::tuple<TString, TParams, const std::function<std::pair<TString, NYdb::TParam } if (request->StartedAt) { - *query.mutable_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->StartedAt); - *job.mutable_query_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->StartedAt); + *query.mutable_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->StartedAt); + *job.mutable_query_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->StartedAt); } if (request->FinishedAt) { - *query.mutable_meta()->mutable_finished_at() = NProtoInterop::CastToProto(*request->FinishedAt); - *job.mutable_query_meta()->mutable_finished_at() = NProtoInterop::CastToProto(*request->FinishedAt); + *query.mutable_meta()->mutable_finished_at() = NProtoInterop::CastToProto(*request->FinishedAt); + *job.mutable_query_meta()->mutable_finished_at() = NProtoInterop::CastToProto(*request->FinishedAt); if (!query.meta().has_started_at()) { - *query.mutable_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->FinishedAt); - *job.mutable_query_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->FinishedAt); + *query.mutable_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->FinishedAt); + *job.mutable_query_meta()->mutable_started_at() = NProtoInterop::CastToProto(*request->FinishedAt); } } - TInstant expireAt = TInstant::Now() + automaticQueriesTtl; - if (IsTerminalStatus(query.meta().status()) && query.content().automatic()) { - *query.mutable_meta()->mutable_expire_at() = NProtoInterop::CastToProto(expireAt); - *job.mutable_query_meta()->mutable_expire_at() = NProtoInterop::CastToProto(expireAt); - *job.mutable_expire_at() = NProtoInterop::CastToProto(expireAt); - } - - if (query.meta().status() == YandexQuery::QueryMeta::COMPLETED) { - *query.mutable_meta()->mutable_result_expire_at() = NProtoInterop::CastToProto(request->Deadline); - } - + TInstant expireAt = TInstant::Now() + automaticQueriesTtl; + if (IsTerminalStatus(query.meta().status()) && query.content().automatic()) { + *query.mutable_meta()->mutable_expire_at() = NProtoInterop::CastToProto(expireAt); + *job.mutable_query_meta()->mutable_expire_at() = NProtoInterop::CastToProto(expireAt); + *job.mutable_expire_at() = NProtoInterop::CastToProto(expireAt); + } + + if (query.meta().status() == YandexQuery::QueryMeta::COMPLETED) { + *query.mutable_meta()->mutable_result_expire_at() = NProtoInterop::CastToProto(request->Deadline); + } + if (request->StateLoadMode) { internal.set_state_load_mode(request->StateLoadMode); if (request->StateLoadMode == YandexQuery::FROM_LAST_CHECKPOINT) { // Saved checkpoint @@ -258,10 +258,10 @@ std::tuple<TString, TParams, const std::function<std::pair<TString, NYdb::TParam } else { updateQueryTtl = "`" EXPIRE_AT_COLUMN_NAME "` = NULL"; } - + writeQueryBuilder.AddText( "UPSERT INTO `" JOBS_TABLE_NAME "` (`" SCOPE_COLUMN_NAME "`, `" QUERY_ID_COLUMN_NAME "`, `" JOB_ID_COLUMN_NAME "`, `" JOB_COLUMN_NAME "`) VALUES($scope, $query_id, $job_id, $job);\n" - "UPDATE `" QUERIES_TABLE_NAME "` SET `" QUERY_COLUMN_NAME "` = $query, `" STATUS_COLUMN_NAME "` = $status, `" INTERNAL_COLUMN_NAME "` = $internal, `" RESULT_ID_COLUMN_NAME "` = $result_id, " + updateResultSetsExpire + ", " + updateQueryTtl + ", `" META_REVISION_COLUMN_NAME "` = `" META_REVISION_COLUMN_NAME "` + 1\n" + "UPDATE `" QUERIES_TABLE_NAME "` SET `" QUERY_COLUMN_NAME "` = $query, `" STATUS_COLUMN_NAME "` = $status, `" INTERNAL_COLUMN_NAME "` = $internal, `" RESULT_ID_COLUMN_NAME "` = $result_id, " + updateResultSetsExpire + ", " + updateQueryTtl + ", `" META_REVISION_COLUMN_NAME "` = `" META_REVISION_COLUMN_NAME "` + 1\n" "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id;\n" ); @@ -344,15 +344,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvPingTaskReq const TString scope = request->Scope; const TString queryId = request->QueryId; const TString owner = request->Owner; - const TInstant deadline = request->Deadline; + const TInstant deadline = request->Deadline; CPS_LOG_T("PingTaskRequest: " << scope << " " << queryId << " " << owner << " " << deadline << " " << (request->Status ? YandexQuery::QueryMeta_ComputeStatus_Name(*request->Status) : "no status")); - NYql::TIssues issues = ValidatePingTask(scope, queryId, owner, deadline, Config.ResultSetsTtl); + NYql::TIssues issues = ValidatePingTask(scope, queryId, owner, deadline, Config.ResultSetsTtl); if (issues) { - CPS_LOG_D("PingTaskRequest, validation failed: " << scope << " " << queryId << " " << owner << " " << deadline << issues.ToString()); + CPS_LOG_D("PingTaskRequest, validation failed: " << scope << " " << queryId << " " << owner << " " << deadline << issues.ToString()); const TDuration delta = TInstant::Now() - startTime; SendResponseIssues<TEvControlPlaneStorage::TEvPingTaskResponse>(ev->Sender, issues, ev->Cookie, delta, requestCounters); LWPROBE(PingTaskRequest, queryId, delta, false); diff --git a/ydb/core/yq/libs/control_plane_storage/internal/task_result_write.cpp b/ydb/core/yq/libs/control_plane_storage/internal/task_result_write.cpp index db945dcca9..faed66be14 100644 --- a/ydb/core/yq/libs/control_plane_storage/internal/task_result_write.cpp +++ b/ydb/core/yq/libs/control_plane_storage/internal/task_result_write.cpp @@ -16,11 +16,11 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvWriteResult const Ydb::ResultSet& resultSet = request.ResultSet; const int byteSize = resultSet.ByteSize(); - CPS_LOG_T("WriteResultDataRequest: " << resultId << " " << resultSetId << " " << startRowId << " " << resultSet.ByteSize() << " " << deadline); + CPS_LOG_T("WriteResultDataRequest: " << resultId << " " << resultSetId << " " << startRowId << " " << resultSet.ByteSize() << " " << deadline); - NYql::TIssues issues = ValidateWriteResultData(resultId, resultSet, deadline, Config.ResultSetsTtl); + NYql::TIssues issues = ValidateWriteResultData(resultId, resultSet, deadline, Config.ResultSetsTtl); if (issues) { - CPS_LOG_D("WriteResultDataRequest, validation failed: " << resultId << " " << resultSetId << " " << startRowId << " " << resultSet.DebugString() << " " << deadline << " error: " << issues.ToString()); + CPS_LOG_D("WriteResultDataRequest, validation failed: " << resultId << " " << resultSetId << " " << startRowId << " " << resultSet.DebugString() << " " << deadline << " error: " << issues.ToString()); const TDuration delta = TInstant::Now() - startTime; SendResponseIssues<TEvControlPlaneStorage::TEvWriteResultDataResponse>(ev->Sender, issues, ev->Cookie, delta, requestCounters); LWPROBE(WriteResultDataRequest, resultId, resultSetId, startRowId, resultSet.rows().size(), delta, deadline, byteSize, false); diff --git a/ydb/core/yq/libs/control_plane_storage/internal/utils.cpp b/ydb/core/yq/libs/control_plane_storage/internal/utils.cpp index bca91f1cfb..dfddf87d5e 100644 --- a/ydb/core/yq/libs/control_plane_storage/internal/utils.cpp +++ b/ydb/core/yq/libs/control_plane_storage/internal/utils.cpp @@ -2,7 +2,7 @@ namespace NYq { -NYql::TIssues ValidateWriteResultData(const TString& resultId, const Ydb::ResultSet& resultSet, const TInstant& deadline, const TDuration& ttl) +NYql::TIssues ValidateWriteResultData(const TString& resultId, const Ydb::ResultSet& resultSet, const TInstant& deadline, const TDuration& ttl) { NYql::TIssues issues; if (!resultId) { @@ -13,11 +13,11 @@ NYql::TIssues ValidateWriteResultData(const TString& resultId, const Ydb::Result issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "result set rows count is empty")); } - const auto hardLimit = TInstant::Now() + ttl; - if (deadline > hardLimit) { - issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "deadline " + deadline.ToString() + " must be less than " + hardLimit.ToString())); - } - + const auto hardLimit = TInstant::Now() + ttl; + if (deadline > hardLimit) { + issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "deadline " + deadline.ToString() + " must be less than " + hardLimit.ToString())); + } + return issues; } @@ -35,7 +35,7 @@ NYql::TIssues ValidateGetTask(const TString& owner, const TString& hostName) return issues; } -NYql::TIssues ValidatePingTask(const TString& scope, const TString& queryId, const TString& owner, const TInstant& deadline, const TDuration& ttl) +NYql::TIssues ValidatePingTask(const TString& scope, const TString& queryId, const TString& owner, const TInstant& deadline, const TDuration& ttl) { NYql::TIssues issues; if (!scope) { @@ -50,11 +50,11 @@ NYql::TIssues ValidatePingTask(const TString& scope, const TString& queryId, con issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "owner is not specified")); } - const auto hardLimit = TInstant::Now() + ttl; - if (deadline > hardLimit) { - issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "deadline " + deadline.ToString() + " must be less than " + hardLimit.ToString())); - } - + const auto hardLimit = TInstant::Now() + ttl; + if (deadline > hardLimit) { + issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "deadline " + deadline.ToString() + " must be less than " + hardLimit.ToString())); + } + return issues; } diff --git a/ydb/core/yq/libs/control_plane_storage/internal/utils.h b/ydb/core/yq/libs/control_plane_storage/internal/utils.h index 2fd0f708d1..5d7d799a87 100644 --- a/ydb/core/yq/libs/control_plane_storage/internal/utils.h +++ b/ydb/core/yq/libs/control_plane_storage/internal/utils.h @@ -18,11 +18,11 @@ struct TTopicConsumerLess { } }; -NYql::TIssues ValidateWriteResultData(const TString& resultId, const Ydb::ResultSet& resultSet, const TInstant& deadline, const TDuration& ttl); +NYql::TIssues ValidateWriteResultData(const TString& resultId, const Ydb::ResultSet& resultSet, const TInstant& deadline, const TDuration& ttl); NYql::TIssues ValidateGetTask(const TString& owner, const TString& hostName); -NYql::TIssues ValidatePingTask(const TString& scope, const TString& queryId, const TString& owner, const TInstant& deadline, const TDuration& ttl); +NYql::TIssues ValidatePingTask(const TString& scope, const TString& queryId, const TString& owner, const TInstant& deadline, const TDuration& ttl); NYql::TIssues ValidateNodesHealthCheck( const TString& tenant, diff --git a/ydb/core/yq/libs/control_plane_storage/message_builders.h b/ydb/core/yq/libs/control_plane_storage/message_builders.h index 75ee6f1f9f..34f20c7c3d 100644 --- a/ydb/core/yq/libs/control_plane_storage/message_builders.h +++ b/ydb/core/yq/libs/control_plane_storage/message_builders.h @@ -1,6 +1,6 @@ #pragma once -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <ydb/public/api/protos/yq.pb.h> @@ -126,22 +126,22 @@ public: } }; -class TGetQueryStatusBuilder { - YandexQuery::GetQueryStatusRequest Request; - -public: - TGetQueryStatusBuilder& SetQueryId(const TString& queryId) - { - Request.set_query_id(queryId); - return *this; - } - - const YandexQuery::GetQueryStatusRequest& Build() - { - return Request; - } -}; - +class TGetQueryStatusBuilder { + YandexQuery::GetQueryStatusRequest Request; + +public: + TGetQueryStatusBuilder& SetQueryId(const TString& queryId) + { + Request.set_query_id(queryId); + return *this; + } + + const YandexQuery::GetQueryStatusRequest& Build() + { + return Request; + } +}; + class TDeleteQueryBuilder { YandexQuery::DeleteQueryRequest Request; @@ -207,12 +207,12 @@ public: return *this; } - TModifyQueryBuilder& SetAutomatic(bool automatic) - { - Request.mutable_content()->set_automatic(automatic); - return *this; - } - + TModifyQueryBuilder& SetAutomatic(bool automatic) + { + Request.mutable_content()->set_automatic(automatic); + return *this; + } + TModifyQueryBuilder& SetText(const TString& content) { Request.mutable_content()->set_text(content); @@ -376,22 +376,22 @@ public: } }; -class TDescribeJobBuilder { - YandexQuery::DescribeJobRequest Request; - -public: - TDescribeJobBuilder& SetJobId(const TString& jobId) - { - Request.set_job_id(jobId); - return *this; - } - - const YandexQuery::DescribeJobRequest& Build() - { - return Request; - } -}; - +class TDescribeJobBuilder { + YandexQuery::DescribeJobRequest Request; + +public: + TDescribeJobBuilder& SetJobId(const TString& jobId) + { + Request.set_job_id(jobId); + return *this; + } + + const YandexQuery::DescribeJobRequest& Build() + { + return Request; + } +}; + // Connections class TCreateConnectionBuilder { @@ -993,7 +993,7 @@ class TPingTaskBuilder { TString QueryId; TString ResultId; TString Owner; - TInstant Deadline; + TInstant Deadline; TMaybe<YandexQuery::QueryMeta::ComputeStatus> Status; TMaybe<NYql::TIssues> Issues; TMaybe<NYql::TIssues> TransientIssues; @@ -1010,9 +1010,9 @@ class TPingTaskBuilder { public: TPingTaskBuilder() - { - SetDeadline(TInstant::Now() + TDuration::Minutes(5)); - } + { + SetDeadline(TInstant::Now() + TDuration::Minutes(5)); + } TPingTaskBuilder& SetScope(const TString& scope) { @@ -1038,12 +1038,12 @@ public: return *this; } - TPingTaskBuilder& SetDeadline(const TInstant& deadline) - { - Deadline = deadline; - return *this; - } - + TPingTaskBuilder& SetDeadline(const TInstant& deadline) + { + Deadline = deadline; + return *this; + } + TPingTaskBuilder& SetStatus(const YandexQuery::QueryMeta::ComputeStatus& status) { Status = status; @@ -1124,7 +1124,7 @@ public: std::unique_ptr<TEvControlPlaneStorage::TEvPingTaskRequest> Build() { - auto request = std::make_unique<TEvControlPlaneStorage::TEvPingTaskRequest>(Scope, QueryId, Owner, Deadline, ResultId); + auto request = std::make_unique<TEvControlPlaneStorage::TEvPingTaskRequest>(Scope, QueryId, Owner, Deadline, ResultId); request->Status = Status; request->Issues = Issues; request->TransientIssues = TransientIssues; diff --git a/ydb/core/yq/libs/control_plane_storage/probes.h b/ydb/core/yq/libs/control_plane_storage/probes.h index c82c68e5ef..205a42171e 100644 --- a/ydb/core/yq/libs/control_plane_storage/probes.h +++ b/ydb/core/yq/libs/control_plane_storage/probes.h @@ -15,10 +15,10 @@ GROUPS(), \ TYPES(TString, TString, TString, TDuration, i64, bool), \ NAMES("scope", "user", "queryId", "latencyMs", "size", "success")) \ - PROBE(GetQueryStatusRequest, \ - GROUPS(), \ - TYPES(TString, TString, TString, TDuration, i64, bool), \ - NAMES("scope", "user", "queryId", "latencyMs", "size", "success")) \ + PROBE(GetQueryStatusRequest, \ + GROUPS(), \ + TYPES(TString, TString, TString, TDuration, i64, bool), \ + NAMES("scope", "user", "queryId", "latencyMs", "size", "success")) \ PROBE(ModifyQueryRequest, \ GROUPS(), \ TYPES(TString, TString, TString, TDuration, i64, bool), \ @@ -39,10 +39,10 @@ GROUPS(), \ TYPES(TString, TString, TString, TDuration, i64, bool), \ NAMES("scope", "user", "queryId", "latencyMs", "size", "success")) \ - PROBE(DescribeJobRequest, \ - GROUPS(), \ - TYPES(TString, TString, TString, TDuration, i64, bool), \ - NAMES("scope", "user", "jobId", "latencyMs", "size", "success")) \ + PROBE(DescribeJobRequest, \ + GROUPS(), \ + TYPES(TString, TString, TString, TDuration, i64, bool), \ + NAMES("scope", "user", "jobId", "latencyMs", "size", "success")) \ PROBE(CreateConnectionRequest, \ GROUPS(), \ TYPES(TString, TString, TDuration, i64, bool), \ diff --git a/ydb/core/yq/libs/control_plane_storage/schema.h b/ydb/core/yq/libs/control_plane_storage/schema.h index 613eb7bcc1..c9051aba94 100644 --- a/ydb/core/yq/libs/control_plane_storage/schema.h +++ b/ydb/core/yq/libs/control_plane_storage/schema.h @@ -15,10 +15,10 @@ namespace NYq { // columns #define SCOPE_COLUMN_NAME "scope" #define VISIBILITY_COLUMN_NAME "visibility" -#define AUTOMATIC_COLUMN_NAME "automatic" +#define AUTOMATIC_COLUMN_NAME "automatic" #define USER_COLUMN_NAME "user" #define REVISION_COLUMN_NAME "revision" -#define META_REVISION_COLUMN_NAME "meta_revision" +#define META_REVISION_COLUMN_NAME "meta_revision" #define INTERNAL_COLUMN_NAME "internal" #define GENERATION_COLUMN_NAME "generation" #define RETRY_COUNTER_COLUMN_NAME "retry_counter" @@ -29,14 +29,14 @@ namespace NYq { #define QUERY_TYPE_COLUMN_NAME "query_type" #define EXECUTE_MODE_COLUMN_NAME "execute_mode" #define LAST_JOB_ID_COLUMN_NAME "last_job_id" -#define RESULT_SETS_EXPIRE_AT_COLUMN_NAME "result_sets_expire_at" +#define RESULT_SETS_EXPIRE_AT_COLUMN_NAME "result_sets_expire_at" #define QUERY_ID_COLUMN_NAME "query_id" #define QUERY_COLUMN_NAME "query" -#define CONNECTION_ID_COLUMN_NAME "connection_id" +#define CONNECTION_ID_COLUMN_NAME "connection_id" #define CONNECTION_COLUMN_NAME "connection" -#define CONNECTION_TYPE_COLUMN_NAME "connection_type" +#define CONNECTION_TYPE_COLUMN_NAME "connection_type" #define NAME_COLUMN_NAME "name" #define BINDING_ID_COLUMN_NAME "binding_id" diff --git a/ydb/core/yq/libs/control_plane_storage/util.cpp b/ydb/core/yq/libs/control_plane_storage/util.cpp index 288f25a1cb..752da5153d 100644 --- a/ydb/core/yq/libs/control_plane_storage/util.cpp +++ b/ydb/core/yq/libs/control_plane_storage/util.cpp @@ -5,12 +5,12 @@ namespace NYq { -bool IsTerminalStatus(YandexQuery::QueryMeta::ComputeStatus status) -{ - return IsIn({ YandexQuery::QueryMeta::ABORTED_BY_USER, YandexQuery::QueryMeta::ABORTED_BY_SYSTEM, - YandexQuery::QueryMeta::COMPLETED, YandexQuery::QueryMeta::FAILED }, status); -} - +bool IsTerminalStatus(YandexQuery::QueryMeta::ComputeStatus status) +{ + return IsIn({ YandexQuery::QueryMeta::ABORTED_BY_USER, YandexQuery::QueryMeta::ABORTED_BY_SYSTEM, + YandexQuery::QueryMeta::COMPLETED, YandexQuery::QueryMeta::FAILED }, status); +} + TDuration GetDuration(const TString& value, const TDuration& defaultValue) { TDuration result = defaultValue; @@ -72,9 +72,9 @@ NConfig::TControlPlaneStorageConfig FillDefaultParameters(NConfig::TControlPlane config.SetStreamingRetryCounterUpdateTime("1d"); } - if (!config.GetAutomaticQueriesTtl()) { - config.SetAutomaticQueriesTtl("1d"); - } + if (!config.GetAutomaticQueriesTtl()) { + config.SetAutomaticQueriesTtl("1d"); + } if (!config.GetTaskLeaseTtl()) { config.SetTaskLeaseTtl("30s"); @@ -84,9 +84,9 @@ NConfig::TControlPlaneStorageConfig FillDefaultParameters(NConfig::TControlPlane config.MutableStorage()->SetToken(StripString(TFileInput(config.GetStorage().GetOAuthFile()).ReadAll())); } - if (!config.GetResultSetsTtl()) { - config.SetResultSetsTtl("1d"); - } + if (!config.GetResultSetsTtl()) { + config.SetResultSetsTtl("1d"); + } return config; } diff --git a/ydb/core/yq/libs/control_plane_storage/util.h b/ydb/core/yq/libs/control_plane_storage/util.h index 8deddc25ca..f297e21c0b 100644 --- a/ydb/core/yq/libs/control_plane_storage/util.h +++ b/ydb/core/yq/libs/control_plane_storage/util.h @@ -10,8 +10,8 @@ namespace NYq { -bool IsTerminalStatus(YandexQuery::QueryMeta::ComputeStatus status); - +bool IsTerminalStatus(YandexQuery::QueryMeta::ComputeStatus status); + TDuration GetDuration(const TString& value, const TDuration& defaultValue); NConfig::TControlPlaneStorageConfig FillDefaultParameters(NConfig::TControlPlaneStorageConfig config); diff --git a/ydb/core/yq/libs/control_plane_storage/validators.cpp b/ydb/core/yq/libs/control_plane_storage/validators.cpp index 946ecfc3bd..f0ae793409 100644 --- a/ydb/core/yq/libs/control_plane_storage/validators.cpp +++ b/ydb/core/yq/libs/control_plane_storage/validators.cpp @@ -328,36 +328,36 @@ TValidationQuery CreateConnectionExistsValidator(const TString& scope, return {query.Sql, query.Params, validator}; } -TValidationQuery CreateTtlValidator(const TString& tableName, - const TString& columnName, - const TString& scope, - const TString& id, - const TString& error, - const TString& tablePathPrefix) { +TValidationQuery CreateTtlValidator(const TString& tableName, + const TString& columnName, + const TString& scope, + const TString& id, + const TString& error, + const TString& tablePathPrefix) { TSqlQueryBuilder queryBuilder(tablePathPrefix); queryBuilder.AddString("scope", scope); queryBuilder.AddString("id", id); queryBuilder.AddTimestamp("now", TInstant::Now()); queryBuilder.AddText( - "SELECT `" EXPIRE_AT_COLUMN_NAME "`\n" + "SELECT `" EXPIRE_AT_COLUMN_NAME "`\n" "FROM `" + tableName + "` WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" + columnName + "` = $id AND (`" EXPIRE_AT_COLUMN_NAME "` is NULL OR `" EXPIRE_AT_COLUMN_NAME "` > $now);\n" ); - - auto validator = [error](NYdb::NTable::TDataQueryResult result) { - const auto& resultSets = result.GetResultSets(); - if (resultSets.size() != 1) { - ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets.size() << ". Please contact internal support"; - } - - TResultSetParser parser(resultSets.front()); - if (!parser.TryNextRow()) { - ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << error; - } - - return false; - }; + + auto validator = [error](NYdb::NTable::TDataQueryResult result) { + const auto& resultSets = result.GetResultSets(); + if (resultSets.size() != 1) { + ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets.size() << ". Please contact internal support"; + } + + TResultSetParser parser(resultSets.front()); + if (!parser.TryNextRow()) { + ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << error; + } + + return false; + }; const auto query = queryBuilder.Build(); return {query.Sql, query.Params, validator}; -} - +} + } // namespace NYq diff --git a/ydb/core/yq/libs/control_plane_storage/validators.h b/ydb/core/yq/libs/control_plane_storage/validators.h index 0b1fc32741..7eaf944e05 100644 --- a/ydb/core/yq/libs/control_plane_storage/validators.h +++ b/ydb/core/yq/libs/control_plane_storage/validators.h @@ -87,13 +87,13 @@ TValidationQuery CreateConnectionExistsValidator(const TString& scope, const TString& user, const TString& tablePathPrefix); -TValidationQuery CreateTtlValidator(const TString& tableName, - const TString& columnName, - const TString& scope, - const TString& id, - const TString& error, - const TString& tablePathPrefix); - +TValidationQuery CreateTtlValidator(const TString& tableName, + const TString& columnName, + const TString& scope, + const TString& id, + const TString& error, + const TString& tablePathPrefix); + template<typename T> TValidationQuery CreateIdempotencyKeyValidator(const TString& scope, const TString& idempotencyKey, diff --git a/ydb/core/yq/libs/control_plane_storage/ya.make b/ydb/core/yq/libs/control_plane_storage/ya.make index 8304e50db5..fd063d6c73 100644 --- a/ydb/core/yq/libs/control_plane_storage/ya.make +++ b/ydb/core/yq/libs/control_plane_storage/ya.make @@ -17,7 +17,7 @@ SRCS( PEERDIR( library/cpp/lwtrace - library/cpp/protobuf/interop + library/cpp/protobuf/interop ydb/core/base ydb/core/mon ydb/core/yq/libs/actors/logging diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage.cpp b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage.cpp index 222ebb6e8e..a40bdbeeb4 100644 --- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage.cpp +++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage.cpp @@ -57,7 +57,7 @@ TYdbControlPlaneStorageActor::TConfig::TConfig(const NConfig::TControlPlaneStora , IdsPrefix(common.GetIdsPrefix()) , IdempotencyKeyTtl(GetDuration(Proto.GetIdempotencyKeysTtl(), TDuration::Minutes(10))) , AutomaticQueriesTtl(GetDuration(Proto.GetAutomaticQueriesTtl(), TDuration::Days(1))) - , ResultSetsTtl(GetDuration(Proto.GetResultSetsTtl(), TDuration::Days(1))) + , ResultSetsTtl(GetDuration(Proto.GetResultSetsTtl(), TDuration::Days(1))) , AnalyticsRetryCounterUpdateTime(GetDuration(Proto.GetAnalyticsRetryCounterUpdateTime(), TDuration::Days(1))) , StreamingRetryCounterUpdateTime(GetDuration(Proto.GetAnalyticsRetryCounterUpdateTime(), TDuration::Days(1))) , TaskLeaseTtl(GetDuration(Proto.GetTaskLeaseTtl(), TDuration::Seconds(30))) @@ -86,7 +86,7 @@ TAsyncStatus TYdbControlPlaneStorageActor::CreateQueriesTable(TActorSystem* as) .AddNullableColumn(NAME_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(USER_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(VISIBILITY_COLUMN_NAME, EPrimitiveType::Int64) - .AddNullableColumn(AUTOMATIC_COLUMN_NAME, EPrimitiveType::Bool) + .AddNullableColumn(AUTOMATIC_COLUMN_NAME, EPrimitiveType::Bool) .AddNullableColumn(STATUS_COLUMN_NAME, EPrimitiveType::Int64) .AddNullableColumn(QUERY_TYPE_COLUMN_NAME, EPrimitiveType::Int64) .AddNullableColumn(EXECUTE_MODE_COLUMN_NAME, EPrimitiveType::Int64) @@ -94,11 +94,11 @@ TAsyncStatus TYdbControlPlaneStorageActor::CreateQueriesTable(TActorSystem* as) .AddNullableColumn(REVISION_COLUMN_NAME, EPrimitiveType::Int64) .AddNullableColumn(INTERNAL_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(LAST_JOB_ID_COLUMN_NAME, EPrimitiveType::String) - .AddNullableColumn(EXPIRE_AT_COLUMN_NAME, EPrimitiveType::Timestamp) - .AddNullableColumn(RESULT_SETS_EXPIRE_AT_COLUMN_NAME, EPrimitiveType::Timestamp) - .AddNullableColumn(META_REVISION_COLUMN_NAME, EPrimitiveType::Int64) + .AddNullableColumn(EXPIRE_AT_COLUMN_NAME, EPrimitiveType::Timestamp) + .AddNullableColumn(RESULT_SETS_EXPIRE_AT_COLUMN_NAME, EPrimitiveType::Timestamp) + .AddNullableColumn(META_REVISION_COLUMN_NAME, EPrimitiveType::Int64) .SetPrimaryKeyColumns({SCOPE_COLUMN_NAME, QUERY_ID_COLUMN_NAME}) - .SetTtlSettings(EXPIRE_AT_COLUMN_NAME) + .SetTtlSettings(EXPIRE_AT_COLUMN_NAME) .Build(); return YdbConnection->Client.RetryOperation( @@ -154,7 +154,7 @@ TAsyncStatus TYdbControlPlaneStorageActor::CreateConnectionsTable(TActorSystem* .AddNullableColumn(SCOPE_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(CONNECTION_ID_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(NAME_COLUMN_NAME, EPrimitiveType::String) - .AddNullableColumn(CONNECTION_TYPE_COLUMN_NAME, EPrimitiveType::Int64) + .AddNullableColumn(CONNECTION_TYPE_COLUMN_NAME, EPrimitiveType::Int64) .AddNullableColumn(USER_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(VISIBILITY_COLUMN_NAME, EPrimitiveType::Int64) .AddNullableColumn(CONNECTION_COLUMN_NAME, EPrimitiveType::String) @@ -201,9 +201,9 @@ TAsyncStatus TYdbControlPlaneStorageActor::CreateJobsTable(TActorSystem* as) .AddNullableColumn(JOB_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(USER_COLUMN_NAME, EPrimitiveType::String) .AddNullableColumn(VISIBILITY_COLUMN_NAME, EPrimitiveType::Int64) - .AddNullableColumn(EXPIRE_AT_COLUMN_NAME, EPrimitiveType::Timestamp) + .AddNullableColumn(EXPIRE_AT_COLUMN_NAME, EPrimitiveType::Timestamp) .SetPrimaryKeyColumns({SCOPE_COLUMN_NAME, QUERY_ID_COLUMN_NAME, JOB_ID_COLUMN_NAME}) - .SetTtlSettings(EXPIRE_AT_COLUMN_NAME) + .SetTtlSettings(EXPIRE_AT_COLUMN_NAME) .Build(); return YdbConnection->Client.RetryOperation( diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_bindings.cpp b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_bindings.cpp index fc617fe5f0..3149a3b106 100644 --- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_bindings.cpp +++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_bindings.cpp @@ -200,7 +200,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListBinding filters.push_back("`" USER_COLUMN_NAME "` = $user"); } - filter = JoinSeq(" AND ", filters); + filter = JoinSeq(" AND ", filters); } PrepareViewAccessCondition(queryBuilder, permissions, user); @@ -427,7 +427,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyBindi auto& meta = *binding.mutable_meta(); meta.set_revision(meta.revision() + 1); meta.set_modified_by(user); - *meta.mutable_modified_at() = NProtoInterop::CastToProto(TInstant::Now()); + *meta.mutable_modified_at() = NProtoInterop::CastToProto(TInstant::Now()); auto& content = *binding.mutable_content(); diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_connections.cpp b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_connections.cpp index ddb15b16c4..f73061906d 100644 --- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_connections.cpp +++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_connections.cpp @@ -79,7 +79,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateConne InsertIdempotencyKey(queryBuilder, scope, idempotencyKey, response->first.SerializeAsString(), startTime + Config.IdempotencyKeyTtl); queryBuilder.AddText( - "INSERT INTO `" CONNECTIONS_TABLE_NAME "` (`" SCOPE_COLUMN_NAME "`, `" CONNECTION_ID_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" NAME_COLUMN_NAME "`, `" CONNECTION_TYPE_COLUMN_NAME "`, `" CONNECTION_COLUMN_NAME "`, `" REVISION_COLUMN_NAME "`, `" INTERNAL_COLUMN_NAME "`) VALUES\n" + "INSERT INTO `" CONNECTIONS_TABLE_NAME "` (`" SCOPE_COLUMN_NAME "`, `" CONNECTION_ID_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" NAME_COLUMN_NAME "`, `" CONNECTION_TYPE_COLUMN_NAME "`, `" CONNECTION_COLUMN_NAME "`, `" REVISION_COLUMN_NAME "`, `" INTERNAL_COLUMN_NAME "`) VALUES\n" " ($scope, $connection_id, $user, $visibility, $name, $connection_type, $connection, $revision, $internal);" ); @@ -187,12 +187,12 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListConnect filters.push_back("`" USER_COLUMN_NAME "` = $user"); } - if (request.filter().connection_type() != YandexQuery::ConnectionSetting::CONNECTION_TYPE_UNSPECIFIED) { + if (request.filter().connection_type() != YandexQuery::ConnectionSetting::CONNECTION_TYPE_UNSPECIFIED) { queryBuilder.AddInt64("connection_type", request.filter().connection_type()); filters.push_back("`" CONNECTION_TYPE_COLUMN_NAME "` = $connection_type"); - } - - filter = JoinSeq(" AND ", filters); + } + + filter = JoinSeq(" AND ", filters); } PrepareViewAccessCondition(queryBuilder, permissions, user); @@ -411,7 +411,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyConne auto& meta = *connection.mutable_meta(); meta.set_revision(meta.revision() + 1); meta.set_modified_by(user); - *meta.mutable_modified_at() = NProtoInterop::CastToProto(TInstant::Now()); + *meta.mutable_modified_at() = NProtoInterop::CastToProto(TInstant::Now()); auto& content = *connection.mutable_content(); diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h index 1c8cda7ee7..f6817b3e14 100644 --- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h +++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h @@ -15,7 +15,7 @@ #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/lwtrace/mon/mon_lwtrace.h> #include <library/cpp/monlib/service/pages/templates.h> -#include <library/cpp/protobuf/interop/cast.h> +#include <library/cpp/protobuf/interop/cast.h> #include <ydb/public/api/protos/yq.pb.h> #include <ydb/public/sdk/cpp/client/ydb_scheme/scheme.h> @@ -93,13 +93,13 @@ class TYdbControlPlaneStorageActor : public NActors::TActorBootstrapped<TYdbCont RT_CREATE_QUERY, RT_LIST_QUERIES, RT_DESCRIBE_QUERY, - RT_GET_QUERY_STATUS, + RT_GET_QUERY_STATUS, RT_MODIFY_QUERY, RT_DELETE_QUERY, RT_CONTROL_QUERY, RT_GET_RESULT_DATA, RT_LIST_JOBS_DATA, - RT_DESCRIBE_JOB, + RT_DESCRIBE_JOB, RT_CREATE_CONNECTION, RT_LIST_CONNECTIONS, RT_DESCRIBE_CONNECTION, @@ -122,13 +122,13 @@ class TYdbControlPlaneStorageActor : public NActors::TActorBootstrapped<TYdbCont { MakeIntrusive<TRequestCounters>("CreateQuery") }, { MakeIntrusive<TRequestCounters>("ListQueries") }, { MakeIntrusive<TRequestCounters>("DescribeQuery") }, - { MakeIntrusive<TRequestCounters>("GetQueryStatus") }, + { MakeIntrusive<TRequestCounters>("GetQueryStatus") }, { MakeIntrusive<TRequestCounters>("ModifyQuery") }, { MakeIntrusive<TRequestCounters>("DeleteQuery") }, { MakeIntrusive<TRequestCounters>("ControlQuery") }, { MakeIntrusive<TRequestCounters>("GetResultData") }, { MakeIntrusive<TRequestCounters>("ListJobs") }, - { MakeIntrusive<TRequestCounters>("DescribeJob") }, + { MakeIntrusive<TRequestCounters>("DescribeJob") }, { MakeIntrusive<TRequestCounters>("CreateConnection") }, { MakeIntrusive<TRequestCounters>("ListConnections") }, { MakeIntrusive<TRequestCounters>("DescribeConnection") }, @@ -161,7 +161,7 @@ class TYdbControlPlaneStorageActor : public NActors::TActorBootstrapped<TYdbCont TString IdsPrefix; TDuration IdempotencyKeyTtl; TDuration AutomaticQueriesTtl; - TDuration ResultSetsTtl; + TDuration ResultSetsTtl; TDuration AnalyticsRetryCounterUpdateTime; TDuration StreamingRetryCounterUpdateTime; TDuration TaskLeaseTtl; @@ -208,13 +208,13 @@ public: hFunc(TEvControlPlaneStorage::TEvCreateQueryRequest, Handle); hFunc(TEvControlPlaneStorage::TEvListQueriesRequest, Handle); hFunc(TEvControlPlaneStorage::TEvDescribeQueryRequest, Handle); - hFunc(TEvControlPlaneStorage::TEvGetQueryStatusRequest, Handle); + hFunc(TEvControlPlaneStorage::TEvGetQueryStatusRequest, Handle); hFunc(TEvControlPlaneStorage::TEvModifyQueryRequest, Handle); hFunc(TEvControlPlaneStorage::TEvDeleteQueryRequest, Handle); hFunc(TEvControlPlaneStorage::TEvControlQueryRequest, Handle); hFunc(TEvControlPlaneStorage::TEvGetResultDataRequest, Handle); hFunc(TEvControlPlaneStorage::TEvListJobsRequest, Handle); - hFunc(TEvControlPlaneStorage::TEvDescribeJobRequest, Handle); + hFunc(TEvControlPlaneStorage::TEvDescribeJobRequest, Handle); hFunc(TEvControlPlaneStorage::TEvCreateConnectionRequest, Handle); hFunc(TEvControlPlaneStorage::TEvListConnectionsRequest, Handle); hFunc(TEvControlPlaneStorage::TEvDescribeConnectionRequest, Handle); @@ -235,13 +235,13 @@ public: void Handle(TEvControlPlaneStorage::TEvCreateQueryRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvListQueriesRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvDescribeQueryRequest::TPtr& ev); - void Handle(TEvControlPlaneStorage::TEvGetQueryStatusRequest::TPtr& ev); + void Handle(TEvControlPlaneStorage::TEvGetQueryStatusRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvModifyQueryRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvDeleteQueryRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvControlQueryRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvGetResultDataRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvListJobsRequest::TPtr& ev); - void Handle(TEvControlPlaneStorage::TEvDescribeJobRequest::TPtr& ev); + void Handle(TEvControlPlaneStorage::TEvDescribeJobRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvCreateConnectionRequest::TPtr& ev); void Handle(TEvControlPlaneStorage::TEvListConnectionsRequest::TPtr& ev); @@ -276,10 +276,10 @@ public: issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "content.acl.visibility field is not specified")); } - if (content.name() != to_lower(content.name())) { - issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "Incorrect connection name: " + content.name() + ". Please use only lower case")); - } - + if (content.name() != to_lower(content.name())) { + issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "Incorrect connection name: " + content.name() + ". Please use only lower case")); + } + if (!content.has_setting()) { issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "content.setting field is not specified")); } @@ -398,10 +398,10 @@ public: issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "binding.acl.visibility field is not specified")); } - if (content.name() != to_lower(content.name())) { - issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "Incorrect binding name: " + content.name() + ". Please use only lower case")); - } - + if (content.name() != to_lower(content.name())) { + issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "Incorrect binding name: " + content.name() + ". Please use only lower case")); + } + if (!content.has_setting()) { issues.AddIssue(MakeErrorIssue(TIssuesIds::BAD_REQUEST, "binding.setting field is not specified")); } @@ -811,7 +811,7 @@ private: common.set_id(id); common.set_created_by(user); common.set_modified_by(user); - auto now = NProtoInterop::CastToProto(startTime); + auto now = NProtoInterop::CastToProto(startTime); *common.mutable_created_at() = now; *common.mutable_modified_at() = now; common.set_revision(revision); diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp index 398725f7f4..6b3c316313 100644 --- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp +++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp @@ -101,15 +101,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery if (request.execute_mode() != YandexQuery::SAVE) { meta.set_last_job_query_revision(InitialRevision); meta.set_last_job_id(jobId); - meta.set_started_by(user); + meta.set_started_by(user); *job.mutable_meta() = common; job.mutable_meta()->set_id(jobId); job.set_text(content.text()); *job.mutable_query_meta() = meta; - job.set_query_name(query.mutable_content()->name()); - *job.mutable_acl() = content.acl(); - job.set_automatic(content.automatic()); + job.set_query_name(query.mutable_content()->name()); + *job.mutable_acl() = content.acl(); + job.set_automatic(content.automatic()); } std::shared_ptr<std::pair<YandexQuery::CreateQueryResult, TAuditDetails<YandexQuery::Query>>> response = std::make_shared<std::pair<YandexQuery::CreateQueryResult, TAuditDetails<YandexQuery::Query>>>(); @@ -245,10 +245,10 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery writeQueryBuilder.AddText( "INSERT INTO `" QUERIES_TABLE_NAME "` (`" SCOPE_COLUMN_NAME "`, `" QUERY_ID_COLUMN_NAME "`, `" NAME_COLUMN_NAME "`, `" STATUS_COLUMN_NAME "`, `" QUERY_TYPE_COLUMN_NAME "`, " "`" EXECUTE_MODE_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" AUTOMATIC_COLUMN_NAME "`, " - "`" REVISION_COLUMN_NAME "`, `" QUERY_COLUMN_NAME "`, `" INTERNAL_COLUMN_NAME "`, `" LAST_JOB_ID_COLUMN_NAME "`, `" GENERATION_COLUMN_NAME "`, `" META_REVISION_COLUMN_NAME "`)\n" + "`" REVISION_COLUMN_NAME "`, `" QUERY_COLUMN_NAME "`, `" INTERNAL_COLUMN_NAME "`, `" LAST_JOB_ID_COLUMN_NAME "`, `" GENERATION_COLUMN_NAME "`, `" META_REVISION_COLUMN_NAME "`)\n" "VALUES ($scope, $query_id, $name, $status, $query_type, " "$execute_mode, $user, $visibility, $automatic, " - "$revision, $query, $internal, $job_id, 0, 0);" + "$revision, $query, $internal, $job_id, 0, 0);" ); const auto write = writeQueryBuilder.Build(); @@ -366,23 +366,23 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListQueries filters.push_back("`" USER_COLUMN_NAME "` = $user"); } - if (request.filter().visibility() != YandexQuery::Acl::VISIBILITY_UNSPECIFIED) { + if (request.filter().visibility() != YandexQuery::Acl::VISIBILITY_UNSPECIFIED) { queryBuilder.AddInt64("filter_visibility", request.filter().visibility()); filters.push_back("`" VISIBILITY_COLUMN_NAME "` = $filter_visibility"); - } - - switch (request.filter().automatic()) { - case YandexQuery::AUTOMATIC: - filters.push_back("`" AUTOMATIC_COLUMN_NAME "` = true"); - break; - case YandexQuery::NOT_AUTOMATIC: - filters.push_back("`" AUTOMATIC_COLUMN_NAME "` = false"); - break; - default: - break; - } - - filter = JoinSeq(" AND ", filters); + } + + switch (request.filter().automatic()) { + case YandexQuery::AUTOMATIC: + filters.push_back("`" AUTOMATIC_COLUMN_NAME "` = true"); + break; + case YandexQuery::NOT_AUTOMATIC: + filters.push_back("`" AUTOMATIC_COLUMN_NAME "` = false"); + break; + default: + break; + } + + filter = JoinSeq(" AND ", filters); } PrepareViewAccessCondition(queryBuilder, permissions, user); @@ -541,95 +541,95 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeQue }); } -void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetQueryStatusRequest::TPtr& ev) -{ - TInstant startTime = TInstant::Now(); - TRequestCountersPtr requestCounters = Counters.Requests[RT_GET_QUERY_STATUS]; - requestCounters->InFly->Inc(); - - const YandexQuery::GetQueryStatusRequest& request = ev->Get()->Request; - const TString scope = ev->Get()->Scope; - const TString user = ev->Get()->User; - const TString token = ev->Get()->Token; +void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetQueryStatusRequest::TPtr& ev) +{ + TInstant startTime = TInstant::Now(); + TRequestCountersPtr requestCounters = Counters.Requests[RT_GET_QUERY_STATUS]; + requestCounters->InFly->Inc(); + + const YandexQuery::GetQueryStatusRequest& request = ev->Get()->Request; + const TString scope = ev->Get()->Scope; + const TString user = ev->Get()->User; + const TString token = ev->Get()->Token; TPermissions permissions = Config.Proto.GetEnablePermissions() - ? ev->Get()->Permissions - : TPermissions{TPermissions::VIEW_PUBLIC | TPermissions::VIEW_AST}; - if (IsSuperUser(user)) { - permissions.SetAll(); - } - const TString queryId = request.query_id(); - const int byteSize = request.ByteSize(); - CPS_LOG_T(MakeLogPrefix(scope, user, queryId) - << "GetQueryStatusRequest: " - << NKikimr::MaskTicket(token) << " " - << request.DebugString()); - - NYql::TIssues issues = ValidateEvent(ev); - if (issues) { - CPS_LOG_D(MakeLogPrefix(scope, user, queryId) - << "GetQueryStatusRequest, validation failed: " - << NKikimr::MaskTicket(token) << " " << request.DebugString() - << " error: " << issues.ToString()); - const TDuration delta = TInstant::Now() - startTime; - SendResponseIssues<TEvControlPlaneStorage::TEvGetQueryStatusResponse>(ev->Sender, issues, ev->Cookie, delta, requestCounters); - LWPROBE(GetQueryStatusRequest, scope, user, queryId, delta, byteSize, false); - return; - } - + ? ev->Get()->Permissions + : TPermissions{TPermissions::VIEW_PUBLIC | TPermissions::VIEW_AST}; + if (IsSuperUser(user)) { + permissions.SetAll(); + } + const TString queryId = request.query_id(); + const int byteSize = request.ByteSize(); + CPS_LOG_T(MakeLogPrefix(scope, user, queryId) + << "GetQueryStatusRequest: " + << NKikimr::MaskTicket(token) << " " + << request.DebugString()); + + NYql::TIssues issues = ValidateEvent(ev); + if (issues) { + CPS_LOG_D(MakeLogPrefix(scope, user, queryId) + << "GetQueryStatusRequest, validation failed: " + << NKikimr::MaskTicket(token) << " " << request.DebugString() + << " error: " << issues.ToString()); + const TDuration delta = TInstant::Now() - startTime; + SendResponseIssues<TEvControlPlaneStorage::TEvGetQueryStatusResponse>(ev->Sender, issues, ev->Cookie, delta, requestCounters); + LWPROBE(GetQueryStatusRequest, scope, user, queryId, delta, byteSize, false); + return; + } + TSqlQueryBuilder queryBuilder(YdbConnection->TablePathPrefix, "GetQueryStatus"); queryBuilder.AddString("scope", scope); queryBuilder.AddString("query_id", queryId); queryBuilder.AddTimestamp("now", TInstant::Now()); - + queryBuilder.AddText( - "SELECT `" STATUS_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" META_REVISION_COLUMN_NAME "` FROM `" QUERIES_TABLE_NAME "`\n" + "SELECT `" STATUS_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" META_REVISION_COLUMN_NAME "` FROM `" QUERIES_TABLE_NAME "`\n" "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id AND (`" EXPIRE_AT_COLUMN_NAME "` is NULL OR `" EXPIRE_AT_COLUMN_NAME "` > $now);" ); - + const auto read = queryBuilder.Build(); auto debugInfo = Config.Proto.GetEnableDebugMode() ? std::make_shared<TDebugInfo>() : TDebugInfoPtr{}; auto [result, resultSets] = Read(read.Sql, read.Params, requestCounters, debugInfo); - auto prepare = [resultSets=resultSets, user,permissions] { - if (resultSets->size() != 1) { - ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support"; - } - - TResultSetParser parser(resultSets->front()); - if (!parser.TryNextRow()) { - ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id query or your access rights"; - } - - YandexQuery::GetQueryStatusResult result; - result.set_status(static_cast<YandexQuery::QueryMeta_ComputeStatus>(*parser.ColumnParser(STATUS_COLUMN_NAME).GetOptionalInt64())); - result.set_meta_revision(parser.ColumnParser(META_REVISION_COLUMN_NAME).GetOptionalInt64().GetOrElse(0)); - - const auto queryVisibility = static_cast<YandexQuery::Acl::Visibility>(*parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64()); - const auto queryUser = *parser.ColumnParser(USER_COLUMN_NAME).GetOptionalString(); - const bool hasViewAccess = HasViewAccess(permissions, queryVisibility, queryUser, user); - if (!hasViewAccess) { - ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id query or your access rights"; - } - - return result; - }; - - auto success = SendResponse<TEvControlPlaneStorage::TEvGetQueryStatusResponse, YandexQuery::GetQueryStatusResult>( - MakeLogPrefix(scope, user, queryId) + "GetQueryStatusRequest", - NActors::TActivationContext::ActorSystem(), - result, - SelfId(), - ev, - startTime, - requestCounters, - prepare, - debugInfo); - - success.Apply([=](const auto& future) { - TDuration delta = TInstant::Now() - startTime; - LWPROBE(DescribeQueryRequest, scope, user, queryId, delta, byteSize, future.GetValue()); - }); -} - + auto prepare = [resultSets=resultSets, user,permissions] { + if (resultSets->size() != 1) { + ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support"; + } + + TResultSetParser parser(resultSets->front()); + if (!parser.TryNextRow()) { + ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id query or your access rights"; + } + + YandexQuery::GetQueryStatusResult result; + result.set_status(static_cast<YandexQuery::QueryMeta_ComputeStatus>(*parser.ColumnParser(STATUS_COLUMN_NAME).GetOptionalInt64())); + result.set_meta_revision(parser.ColumnParser(META_REVISION_COLUMN_NAME).GetOptionalInt64().GetOrElse(0)); + + const auto queryVisibility = static_cast<YandexQuery::Acl::Visibility>(*parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64()); + const auto queryUser = *parser.ColumnParser(USER_COLUMN_NAME).GetOptionalString(); + const bool hasViewAccess = HasViewAccess(permissions, queryVisibility, queryUser, user); + if (!hasViewAccess) { + ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id query or your access rights"; + } + + return result; + }; + + auto success = SendResponse<TEvControlPlaneStorage::TEvGetQueryStatusResponse, YandexQuery::GetQueryStatusResult>( + MakeLogPrefix(scope, user, queryId) + "GetQueryStatusRequest", + NActors::TActivationContext::ActorSystem(), + result, + SelfId(), + ev, + startTime, + requestCounters, + prepare, + debugInfo); + + success.Apply([=](const auto& future) { + TDuration delta = TInstant::Now() - startTime; + LWPROBE(DescribeQueryRequest, scope, user, queryId, delta, byteSize, future.GetValue()); + }); +} + void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQueryRequest::TPtr& ev) { TInstant startTime = TInstant::Now(); @@ -759,7 +759,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery auto& common = *query.mutable_meta()->mutable_common(); common.set_revision(common.revision() + 1); common.set_modified_by(user); - *common.mutable_modified_at() = NProtoInterop::CastToProto(now); + *common.mutable_modified_at() = NProtoInterop::CastToProto(now); *query.mutable_content() = request.content(); query.mutable_meta()->set_execute_mode(request.execute_mode()); @@ -830,7 +830,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery internal.clear_action(); query.clear_result_set_meta(); query.clear_plan(); - query.clear_ast(); + query.clear_ast(); query.clear_issue(); query.clear_transient_issue(); query.clear_statistics(); @@ -839,24 +839,24 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery query.mutable_meta()->set_last_job_query_revision(common.revision()); query.mutable_meta()->set_last_job_id(jobId); query.mutable_meta()->set_status(YandexQuery::QueryMeta::STARTING); - query.mutable_meta()->clear_expire_at(); - query.mutable_meta()->clear_result_expire_at(); - query.mutable_meta()->set_started_by(user); - query.mutable_meta()->clear_action(); + query.mutable_meta()->clear_expire_at(); + query.mutable_meta()->clear_result_expire_at(); + query.mutable_meta()->set_started_by(user); + query.mutable_meta()->clear_action(); auto& jobMeta = *job.mutable_meta(); jobMeta.set_id(jobId); jobMeta.set_created_by(user); jobMeta.set_modified_by(user); - *jobMeta.mutable_modified_at() = NProtoInterop::CastToProto(now); - *jobMeta.mutable_created_at() = NProtoInterop::CastToProto(now); + *jobMeta.mutable_modified_at() = NProtoInterop::CastToProto(now); + *jobMeta.mutable_created_at() = NProtoInterop::CastToProto(now); jobMeta.set_revision(InitialRevision); job.set_text(request.content().text()); *job.mutable_query_meta() = query.meta(); - job.set_query_name(query.mutable_content()->name()); - *job.mutable_acl() = request.content().acl(); - job.set_automatic(request.content().automatic()); + job.set_query_name(query.mutable_content()->name()); + *job.mutable_acl() = request.content().acl(); + job.set_automatic(request.content().automatic()); } response->second.After.ConstructInPlace().CopyFrom(query); @@ -956,15 +956,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery YdbConnection->TablePathPrefix); validators.push_back(accessValidator); - auto ttlValidator = CreateTtlValidator( - QUERIES_TABLE_NAME, - QUERY_ID_COLUMN_NAME, - scope, - queryId, - "Query does not exist or permission denied. Please check the id query or your access rights", - YdbConnection->TablePathPrefix); - validators.push_back(ttlValidator); - + auto ttlValidator = CreateTtlValidator( + QUERIES_TABLE_NAME, + QUERY_ID_COLUMN_NAME, + scope, + queryId, + "Query does not exist or permission denied. Please check the id query or your access rights", + YdbConnection->TablePathPrefix); + validators.push_back(ttlValidator); + if (previousRevision > 0) { auto revisionValidator = CreateRevisionValidator( QUERIES_TABLE_NAME, @@ -1212,7 +1212,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer auto& commonQuery = *metaQuery.mutable_common(); commonQuery.set_revision(commonQuery.revision() + 1); commonQuery.set_modified_by(user); - *commonQuery.mutable_modified_at() = NProtoInterop::CastToProto(now); + *commonQuery.mutable_modified_at() = NProtoInterop::CastToProto(now); if (action == YandexQuery::ABORT || action == YandexQuery::ABORT_GRACEFULLY) { const bool isValidStatusForAbort = IsIn({ @@ -1224,7 +1224,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer if (isValidStatusForAbort) { metaQuery.set_status(YandexQuery::QueryMeta::ABORTING_BY_USER); - metaQuery.set_aborted_by(user); + metaQuery.set_aborted_by(user); } else { ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Conversion from status " << YandexQuery::QueryMeta::ComputeStatus_Name(metaQuery.status()) << " to " << YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::ABORTING_BY_USER) << " is not possible. Please wait for the previous operation to be completed"; } @@ -1238,7 +1238,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer if (isValidStatusForPause) { metaQuery.set_status(YandexQuery::QueryMeta::PAUSING); - metaQuery.set_paused_by(user); + metaQuery.set_paused_by(user); } else { ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Conversion from status " << YandexQuery::QueryMeta::ComputeStatus_Name(metaQuery.status()) << " to " << YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::PAUSING) << " is not possible. Please wait for the previous operation to be completed"; } @@ -1256,7 +1256,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer job.mutable_query_meta()->CopyFrom(metaQuery); job.mutable_meta()->set_revision(job.meta().revision() + 1); job.mutable_meta()->set_modified_by(user); - *job.mutable_meta()->mutable_modified_at() = NProtoInterop::CastToProto(now); + *job.mutable_meta()->mutable_modified_at() = NProtoInterop::CastToProto(now); response->second.After.ConstructInPlace().CopyFrom(query); response->second.CloudId = queryInternal.cloud_id(); @@ -1275,7 +1275,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer writeQueryBuilder.AddText( "UPDATE `" JOBS_TABLE_NAME "` SET `" JOB_COLUMN_NAME "` = $job\n" "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id AND `" JOB_ID_COLUMN_NAME "` = $job_id;\n" - "UPDATE `" QUERIES_TABLE_NAME "` SET `" QUERY_COLUMN_NAME "` = $query, `" REVISION_COLUMN_NAME "` = $revision, `" STATUS_COLUMN_NAME "` = $status, `" INTERNAL_COLUMN_NAME "` = $internal, `" META_REVISION_COLUMN_NAME "` = `" META_REVISION_COLUMN_NAME "` + 1\n" + "UPDATE `" QUERIES_TABLE_NAME "` SET `" QUERY_COLUMN_NAME "` = $query, `" REVISION_COLUMN_NAME "` = $revision, `" STATUS_COLUMN_NAME "` = $status, `" INTERNAL_COLUMN_NAME "` = $internal, `" META_REVISION_COLUMN_NAME "` = `" META_REVISION_COLUMN_NAME "` + 1\n" "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id;\n" "UPDATE `" PENDING_SMALL_TABLE_NAME "` SET `" HOST_NAME_COLUMN_NAME "` = \"\"\n" "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id;" @@ -1382,15 +1382,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetResultDa queryBuilder.AddUint64("limit", limit); queryBuilder.AddText( - "$query_info = SELECT `" RESULT_ID_COLUMN_NAME "`, `" RESULT_SETS_EXPIRE_AT_COLUMN_NAME "`, `" QUERY_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" STATUS_COLUMN_NAME "` FROM `" QUERIES_TABLE_NAME "`\n" - "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id AND (`" EXPIRE_AT_COLUMN_NAME "` is NULL OR `" EXPIRE_AT_COLUMN_NAME "` > $now);\n" - "SELECT `" QUERY_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" STATUS_COLUMN_NAME "`, `" RESULT_SETS_EXPIRE_AT_COLUMN_NAME "` FROM $query_info;\n" - "$result_id = SELECT `" RESULT_ID_COLUMN_NAME "` FROM $query_info\n" - "WHERE `" RESULT_SETS_EXPIRE_AT_COLUMN_NAME "` >= $now;\n" + "$query_info = SELECT `" RESULT_ID_COLUMN_NAME "`, `" RESULT_SETS_EXPIRE_AT_COLUMN_NAME "`, `" QUERY_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" STATUS_COLUMN_NAME "` FROM `" QUERIES_TABLE_NAME "`\n" + "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id AND (`" EXPIRE_AT_COLUMN_NAME "` is NULL OR `" EXPIRE_AT_COLUMN_NAME "` > $now);\n" + "SELECT `" QUERY_COLUMN_NAME "`, `" USER_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "`, `" STATUS_COLUMN_NAME "`, `" RESULT_SETS_EXPIRE_AT_COLUMN_NAME "` FROM $query_info;\n" + "$result_id = SELECT `" RESULT_ID_COLUMN_NAME "` FROM $query_info\n" + "WHERE `" RESULT_SETS_EXPIRE_AT_COLUMN_NAME "` >= $now;\n" "SELECT `" RESULT_SET_ID_COLUMN_NAME "`, `" RESULT_SET_COLUMN_NAME "`, `" ROW_ID_COLUMN_NAME "` FROM `" RESULT_SETS_TABLE_NAME "`\n" "WHERE `" RESULT_ID_COLUMN_NAME "` = $result_id AND `" RESULT_SET_ID_COLUMN_NAME "` = $result_set_index AND `" ROW_ID_COLUMN_NAME "` >= $offset\n" "ORDER BY `" ROW_ID_COLUMN_NAME "`\n" - "LIMIT $limit;\n" + "LIMIT $limit;\n" ); const auto query = queryBuilder.Build(); @@ -1427,19 +1427,19 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetResultDa ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Result set index out of bound: " << resultSetIndex << " >= " << query.result_set_meta_size(); } - if (YandexQuery::QueryMeta::ComputeStatus(*parser.ColumnParser(STATUS_COLUMN_NAME).GetOptionalInt64()) != YandexQuery::QueryMeta::COMPLETED) { - ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Result doesn't exist"; - } - - auto resultSetsExpireAtParser = parser.ColumnParser(RESULT_SETS_EXPIRE_AT_COLUMN_NAME).GetOptionalTimestamp(); - if (!resultSetsExpireAtParser) { - ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Result doesn't exist"; - } - - if (*resultSetsExpireAtParser < TInstant::Now()) { - ythrow TControlPlaneStorageException(TIssuesIds::EXPIRED) << "Result removed by TTL"; - } - + if (YandexQuery::QueryMeta::ComputeStatus(*parser.ColumnParser(STATUS_COLUMN_NAME).GetOptionalInt64()) != YandexQuery::QueryMeta::COMPLETED) { + ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Result doesn't exist"; + } + + auto resultSetsExpireAtParser = parser.ColumnParser(RESULT_SETS_EXPIRE_AT_COLUMN_NAME).GetOptionalTimestamp(); + if (!resultSetsExpireAtParser) { + ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Result doesn't exist"; + } + + if (*resultSetsExpireAtParser < TInstant::Now()) { + ythrow TControlPlaneStorageException(TIssuesIds::EXPIRED) << "Result removed by TTL"; + } + resultSetProto.mutable_columns()->CopyFrom(query.result_set_meta(resultSetIndex).column()); } @@ -1542,7 +1542,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListJobsReq filters.push_back("`" USER_COLUMN_NAME "` = $user"); } - filter = JoinSeq(" AND ", filters); + filter = JoinSeq(" AND ", filters); } PrepareViewAccessCondition(queryBuilder, permissions, user); @@ -1580,7 +1580,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListJobsReq briefJob.set_query_name(job.query_name()); briefJob.set_visibility(job.acl().visibility()); briefJob.set_automatic(job.automatic()); - *briefJob.mutable_expire_at() = job.expire_at(); + *briefJob.mutable_expire_at() = job.expire_at(); *result.add_job() = briefJob; } @@ -1609,22 +1609,22 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListJobsReq }); } -void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeJobRequest::TPtr& ev) -{ - TInstant startTime = TInstant::Now(); - TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_JOB]; - requestCounters->InFly->Inc(); - - const YandexQuery::DescribeJobRequest& request = ev->Get()->Request; - const TString scope = ev->Get()->Scope; - const TString user = ev->Get()->User; +void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeJobRequest::TPtr& ev) +{ + TInstant startTime = TInstant::Now(); + TRequestCountersPtr requestCounters = Counters.Requests[RT_DESCRIBE_JOB]; + requestCounters->InFly->Inc(); + + const YandexQuery::DescribeJobRequest& request = ev->Get()->Request; + const TString scope = ev->Get()->Scope; + const TString user = ev->Get()->User; auto splittedId = SplitId(request.job_id()); const auto jobId = std::move(splittedId.first); const auto queryId = std::move(splittedId.second); - const int byteSize = ev->Get()->Request.ByteSize(); - const TString token = ev->Get()->Token; + const int byteSize = ev->Get()->Request.ByteSize(); + const TString token = ev->Get()->Token; TPermissions permissions = Config.Proto.GetEnablePermissions() ? ev->Get()->Permissions : TPermissions{TPermissions::VIEW_PUBLIC}; @@ -1635,73 +1635,73 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeJob << "DescribeJobRequest: " << NKikimr::MaskTicket(token) << " " << request.DebugString()); - - NYql::TIssues issues = ValidateEvent(ev); - if (issues) { + + NYql::TIssues issues = ValidateEvent(ev); + if (issues) { CPS_LOG_D(MakeLogPrefix(scope, user, jobId) << "DescribeJobRequest, validation failed: " << NKikimr::MaskTicket(token) << " " << request.DebugString() << " error: " << issues.ToString()); const TDuration delta = TInstant::Now() - startTime; SendResponseIssues<TEvControlPlaneStorage::TEvDescribeJobResponse>(ev->Sender, issues, ev->Cookie, delta, requestCounters); - LWPROBE(DescribeJobRequest, scope, user, jobId, delta, byteSize, false); - return; - } - + LWPROBE(DescribeJobRequest, scope, user, jobId, delta, byteSize, false); + return; + } + TSqlQueryBuilder queryBuilder(YdbConnection->TablePathPrefix, "DescribeJob"); queryBuilder.AddString("scope", scope); queryBuilder.AddString("job_id", jobId); queryBuilder.AddString("query_id", queryId); queryBuilder.AddTimestamp("now", TInstant::Now()); - + queryBuilder.AddText( "SELECT `" JOB_COLUMN_NAME "`, `" VISIBILITY_COLUMN_NAME "` FROM `" JOBS_TABLE_NAME "`\n" "WHERE `" SCOPE_COLUMN_NAME "` = $scope AND `" QUERY_ID_COLUMN_NAME "` = $query_id\n" " AND `" JOB_ID_COLUMN_NAME "` = $job_id AND (`" EXPIRE_AT_COLUMN_NAME "` is NULL OR `" EXPIRE_AT_COLUMN_NAME "` > $now);\n" ); - + const auto query = queryBuilder.Build(); auto debugInfo = Config.Proto.GetEnableDebugMode() ? std::make_shared<TDebugInfo>() : TDebugInfoPtr{}; auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo); - + auto prepare = [=, id=request.job_id(), resultSets=resultSets] { if (resultSets->size() != 1) { ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support"; - } + } YandexQuery::DescribeJobResult result; TResultSetParser parser(resultSets->front()); if (!parser.TryNextRow()) { ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Job does not exist or permission denied. Please check the job id or your access rights"; - } + } if (!result.mutable_job()->ParseFromString(*parser.ColumnParser(JOB_COLUMN_NAME).GetOptionalString())) { ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for job. Please contact internal support"; - } + } auto visibility = static_cast<YandexQuery::Acl::Visibility>(*parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64()); result.mutable_job()->mutable_meta()->set_id(id); - + bool hasViewAccces = HasViewAccess(permissions, visibility, result.job().meta().created_by(), user); if (!hasViewAccces) { ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Job does not exist or permission denied. Please check the job id or your access rights"; - } - return result; - }; - - auto success = SendResponse<TEvControlPlaneStorage::TEvDescribeJobResponse, YandexQuery::DescribeJobResult>( - MakeLogPrefix(scope, user, jobId) + "DescribeJobRequest", - NActors::TActivationContext::ActorSystem(), - result, - SelfId(), - ev, - startTime, - requestCounters, + } + return result; + }; + + auto success = SendResponse<TEvControlPlaneStorage::TEvDescribeJobResponse, YandexQuery::DescribeJobResult>( + MakeLogPrefix(scope, user, jobId) + "DescribeJobRequest", + NActors::TActivationContext::ActorSystem(), + result, + SelfId(), + ev, + startTime, + requestCounters, prepare, debugInfo); - - success.Apply([=](const auto& future) { - TDuration delta = TInstant::Now() - startTime; - LWPROBE(DescribeJobRequest, scope, user, jobId, delta, byteSize, future.GetValue()); - }); -} - + + success.Apply([=](const auto& future) { + TDuration delta = TInstant::Now() - startTime; + LWPROBE(DescribeJobRequest, scope, user, jobId, delta, byteSize, future.GetValue()); + }); +} + } // NYq diff --git a/ydb/core/yq/libs/ya.make b/ydb/core/yq/libs/ya.make index ccc88a55b6..1fb85c30d7 100644 --- a/ydb/core/yq/libs/ya.make +++ b/ydb/core/yq/libs/ya.make @@ -8,14 +8,14 @@ RECURSE( checkpointing_common common config - control_plane_proxy - control_plane_storage + control_plane_proxy + control_plane_storage db_resolver db_schema events gateway graph_params - hmac + hmac init logs mock @@ -24,7 +24,7 @@ RECURSE( read_rule result_formatter shared_resources - signer + signer tasks_packer test_connection ydb diff --git a/ydb/public/api/grpc/yq_v1.proto b/ydb/public/api/grpc/yq_v1.proto index 6f48bcc11f..dc88d27ec7 100644 --- a/ydb/public/api/grpc/yq_v1.proto +++ b/ydb/public/api/grpc/yq_v1.proto @@ -17,9 +17,9 @@ service YandexQueryService { // Get full information about the object of the query rpc DescribeQuery(YandexQuery.DescribeQueryRequest) returns (YandexQuery.DescribeQueryResponse); - // Get status of the query - rpc GetQueryStatus(YandexQuery.GetQueryStatusRequest) returns (YandexQuery.GetQueryStatusResponse); - + // Get status of the query + rpc GetQueryStatus(YandexQuery.GetQueryStatusRequest) returns (YandexQuery.GetQueryStatusResponse); + // Change the attributes of the query (acl, name, ...) rpc ModifyQuery(YandexQuery.ModifyQueryRequest) returns (YandexQuery.ModifyQueryResponse); @@ -34,12 +34,12 @@ service YandexQueryService { // Job // Job - appears immediately after starting the request and contains the request metadata - // Get a list of jobs + // Get a list of jobs rpc ListJobs(YandexQuery.ListJobsRequest) returns (YandexQuery.ListJobsResponse); - // Get information about the job - rpc DescribeJob(YandexQuery.DescribeJobRequest) returns (YandexQuery.DescribeJobResponse); - + // Get information about the job + rpc DescribeJob(YandexQuery.DescribeJobRequest) returns (YandexQuery.DescribeJobResponse); + // Connection // Connection - entity that describes connection points. This can be imagined as an analogue of a network address. // Create a connection object (ObjectStorage, YDB, YDS, ...) diff --git a/ydb/public/api/protos/draft/yq_private.proto b/ydb/public/api/protos/draft/yq_private.proto index 2af1c2f3ed..fe9aa67d2b 100644 --- a/ydb/public/api/protos/draft/yq_private.proto +++ b/ydb/public/api/protos/draft/yq_private.proto @@ -66,7 +66,7 @@ message GetTaskResult { bool automatic = 22; string query_name = 23; - google.protobuf.Timestamp deadline = 24; + google.protobuf.Timestamp deadline = 24; YandexQuery.StreamingDisposition disposition = 25; } repeated Task tasks = 1; @@ -100,7 +100,7 @@ message PingTaskRequest { string scope = 100; //TODO remove google.protobuf.Timestamp started_at = 101; google.protobuf.Timestamp finished_at = 102; - google.protobuf.Timestamp deadline = 103; + google.protobuf.Timestamp deadline = 103; } message PingTaskResult { @@ -119,7 +119,7 @@ message WriteTaskResultRequest { uint64 offset = 5; uint64 request_id = 6; Ydb.Operations.OperationParams operation_params = 7; - google.protobuf.Timestamp deadline = 8; + google.protobuf.Timestamp deadline = 8; } message WriteTaskResultResult { diff --git a/ydb/public/api/protos/yq.proto b/ydb/public/api/protos/yq.proto index 6aa7169a89..05153d0df0 100644 --- a/ydb/public/api/protos/yq.proto +++ b/ydb/public/api/protos/yq.proto @@ -32,16 +32,16 @@ message Acl { message Limits { // Used only for streaming queries - int64 vcpu_rate_limit = 1 [(Ydb.value) = ">= 0"]; // 0.01 vcpu per second - int64 flow_rate_limit = 2 [(Ydb.value) = ">= 0"]; // Bytes per second - int64 vcpu_time_limit = 3 [(Ydb.value) = ">= 0"]; // Milliseconds per second + int64 vcpu_rate_limit = 1 [(Ydb.value) = ">= 0"]; // 0.01 vcpu per second + int64 flow_rate_limit = 2 [(Ydb.value) = ">= 0"]; // Bytes per second + int64 vcpu_time_limit = 3 [(Ydb.value) = ">= 0"]; // Milliseconds per second // Used only for analytics queries - int64 max_result_size = 4 [(Ydb.value) = ">= 0"]; // Bytes - int64 max_result_rows = 5 [(Ydb.value) = ">= 0"]; // Count + int64 max_result_size = 4 [(Ydb.value) = ">= 0"]; // Bytes + int64 max_result_rows = 5 [(Ydb.value) = ">= 0"]; // Count // Common limits - int64 memory_limit = 6 [(Ydb.value) = ">= 0"]; // Bytes + int64 memory_limit = 6 [(Ydb.value) = ">= 0"]; // Bytes google.protobuf.Duration result_ttl = 7; } @@ -147,13 +147,13 @@ message QueryMeta { ComputeStatus status = 5; int64 last_job_query_revision = 6; string last_job_id = 7; - google.protobuf.Timestamp expire_at = 8; - google.protobuf.Timestamp result_expire_at = 9; - string started_by = 10; - oneof action { - string aborted_by = 11; - string paused_by = 12; - } + google.protobuf.Timestamp expire_at = 8; + google.protobuf.Timestamp result_expire_at = 9; + string started_by = 10; + oneof action { + string aborted_by = 11; + string paused_by = 12; + } // One of the versions of this query has fully saved checkpoint. // If this flag is not set streaming disposition mode "from last checkpoint" can't be used. bool has_saved_checkpoints = 13; @@ -171,10 +171,10 @@ message QueryPlan { string json = 1; // No validation because generated on server side } -message QueryAst { - string data = 1; -} - +message QueryAst { + string data = 1; +} + message ResultSetMeta { repeated Ydb.Column column = 1; int64 rows_count = 2 [(Ydb.value) = ">= 0"]; @@ -189,7 +189,7 @@ message Query { repeated Ydb.Issue.IssueMessage transient_issue = 5; QueryStatistics statistics = 6; repeated ResultSetMeta result_set_meta = 7; - QueryAst ast = 8; + QueryAst ast = 8; } message QueryStatistics { @@ -213,12 +213,12 @@ message CreateQueryResult { string query_id = 1 [(Ydb.length).le = 1024]; } -enum AutomaticType { - AUTOMATIC_TYPE_UNSPECIFIED = 0; - AUTOMATIC = 1; - NOT_AUTOMATIC = 2; -} - +enum AutomaticType { + AUTOMATIC_TYPE_UNSPECIFIED = 0; + AUTOMATIC = 1; + NOT_AUTOMATIC = 2; +} + // Getting brief information about queries message ListQueriesRequest { Ydb.Operations.OperationParams operation_params = 1; @@ -231,8 +231,8 @@ message ListQueriesRequest { repeated ExecuteMode mode = 3 [(Ydb.size).le = 20]; string name = 4 [(Ydb.length).le = 1024]; // queries whose name contains the filter.name substring bool created_by_me = 5; - Acl.Visibility visibility = 6; - AutomaticType automatic = 7; + Acl.Visibility visibility = 6; + AutomaticType automatic = 7; } Filter filter = 4; } @@ -260,21 +260,21 @@ message DescribeQueryResult { Query query = 1; } -// Getting status of the query -message GetQueryStatusRequest { - Ydb.Operations.OperationParams operation_params = 1; - string query_id = 2 [(Ydb.length).range = {min: 1, max: 1024}]; -} - -message GetQueryStatusResponse { - Ydb.Operations.Operation operation = 1; // GetQueryStatusResult -} - -message GetQueryStatusResult { - QueryMeta.ComputeStatus status = 1; - int64 meta_revision = 2; -} - +// Getting status of the query +message GetQueryStatusRequest { + Ydb.Operations.OperationParams operation_params = 1; + string query_id = 2 [(Ydb.length).range = {min: 1, max: 1024}]; +} + +message GetQueryStatusResponse { + Ydb.Operations.Operation operation = 1; // GetQueryStatusResult +} + +message GetQueryStatusResult { + QueryMeta.ComputeStatus status = 1; + int64 meta_revision = 2; +} + // Complete removal of query. Recovery of the query after this operation is not possible message DeleteQueryRequest { Ydb.Operations.OperationParams operation_params = 1; @@ -327,15 +327,15 @@ message ControlQueryResult { // === Job API === -message BriefJob { - CommonMeta meta = 1; - QueryMeta query_meta = 3; - string query_name = 9; - Acl.Visibility visibility = 10; - bool automatic = 11; - google.protobuf.Timestamp expire_at = 12; -} - +message BriefJob { + CommonMeta meta = 1; + QueryMeta query_meta = 3; + string query_name = 9; + Acl.Visibility visibility = 10; + bool automatic = 11; + google.protobuf.Timestamp expire_at = 12; +} + message Job { CommonMeta meta = 1; string text = 2; @@ -344,11 +344,11 @@ message Job { repeated Ydb.Issue.IssueMessage issue = 5; QueryStatistics statistics = 6; repeated ResultSetMeta result_set_meta = 7; - QueryAst ast = 8; - string query_name = 9; - Acl acl = 10; - bool automatic = 11; - google.protobuf.Timestamp expire_at = 12; + QueryAst ast = 8; + string query_name = 9; + Acl acl = 10; + bool automatic = 11; + google.protobuf.Timestamp expire_at = 12; } // Information about recent query runs @@ -370,24 +370,24 @@ message ListJobsResponse { } message ListJobsResult { - repeated BriefJob job = 1; + repeated BriefJob job = 1; string next_page_token = 2 [(Ydb.length).le = 1024]; } -// Getting information about the job -message DescribeJobRequest { - Ydb.Operations.OperationParams operation_params = 1; - string job_id = 2 [(Ydb.length).range = {min: 1, max: 1024}]; -} - -message DescribeJobResponse { - Ydb.Operations.Operation operation = 1; // DescribeJobResult -} - -message DescribeJobResult { - Job job = 1; -} - +// Getting information about the job +message DescribeJobRequest { + Ydb.Operations.OperationParams operation_params = 1; + string job_id = 2 [(Ydb.length).range = {min: 1, max: 1024}]; +} + +message DescribeJobResponse { + Ydb.Operations.Operation operation = 1; // DescribeJobResult +} + +message DescribeJobResult { + Job job = 1; +} + // === Connection API === message CurrentIAMTokenAuth { @@ -452,15 +452,15 @@ message ObjectStorageConnection { } message ConnectionSetting { - enum ConnectionType { - CONNECTION_TYPE_UNSPECIFIED = 0; - YDB_DATABASE = 1; - CLICKHOUSE_CLUSTER = 2; - DATA_STREAMS = 3; - OBJECT_STORAGE = 4; - MONITORING = 5; - } - + enum ConnectionType { + CONNECTION_TYPE_UNSPECIFIED = 0; + YDB_DATABASE = 1; + CLICKHOUSE_CLUSTER = 2; + DATA_STREAMS = 3; + OBJECT_STORAGE = 4; + MONITORING = 5; + } + oneof connection { YdbDatabase ydb_database = 1; ClickHouseCluster clickhouse_cluster = 2; @@ -506,7 +506,7 @@ message ListConnectionsRequest { message Filter { string name = 1 [(Ydb.length).le = 1024]; // connections whose name contains the filter.name substring bool created_by_me = 2; - ConnectionSetting.ConnectionType connection_type = 3; + ConnectionSetting.ConnectionType connection_type = 3; } Filter filter = 4; } @@ -585,7 +585,7 @@ message GetResultDataRequest { string query_id = 2 [(Ydb.length).range = {min: 1, max: 1024}]; int32 result_set_index = 3 [(Ydb.value) = ">= 0"]; int64 offset = 4 [(Ydb.value) = ">= 0"]; - int64 limit = 5 [(Ydb.value) = "[1; 1000]"]; + int64 limit = 5 [(Ydb.value) = "[1; 1000]"]; } message GetResultDataResponse { @@ -623,12 +623,12 @@ message ObjectStorageBinding { } message BindingSetting { - enum BindingType { - BINDING_TYPE_UNSPECIFIED = 0; - DATA_STREAMS = 1; - OBJECT_STORAGE = 2; - } - + enum BindingType { + BINDING_TYPE_UNSPECIFIED = 0; + DATA_STREAMS = 1; + OBJECT_STORAGE = 2; + } + oneof binding { DataStreamsBinding data_streams = 1; ObjectStorageBinding object_storage = 2; @@ -639,7 +639,7 @@ message BriefBinding { string name = 1 [(Ydb.length).range = {min: 1, max: 1024}]; string connection_id = 2 [(Ydb.length).range = {min: 1, max: 1024}]; CommonMeta meta = 3; - BindingSetting.BindingType type = 4; + BindingSetting.BindingType type = 4; } message BindingContent { diff --git a/ydb/public/lib/yq/yq.cpp b/ydb/public/lib/yq/yq.cpp index e9aa329323..64cece03f8 100644 --- a/ydb/public/lib/yq/yq.cpp +++ b/ydb/public/lib/yq/yq.cpp @@ -116,34 +116,34 @@ public: return future; } - TAsyncGetQueryStatusResult GetQueryStatus( - const YandexQuery::GetQueryStatusRequest& protoRequest, - const TGetQueryStatusSettings& settings) { - auto request = MakeOperationRequest<YandexQuery::GetQueryStatusRequest>(settings); - request = protoRequest; - - auto promise = NThreading::NewPromise<TGetQueryStatusResult>(); - auto future = promise.GetFuture(); - - auto extractor = MakeResultExtractor< - YandexQuery::GetQueryStatusResult, - TGetQueryStatusResult>(std::move(promise)); - - Connections_->RunDeferred< - YandexQuery::V1::YandexQueryService, - YandexQuery::GetQueryStatusRequest, - YandexQuery::GetQueryStatusResponse>( - std::move(request), - std::move(extractor), - &YandexQuery::V1::YandexQueryService::Stub::AsyncGetQueryStatus, - DbDriverState_, - INITIAL_DEFERRED_CALL_DELAY, - TRpcRequestSettings::Make(settings), - settings.ClientTimeout_); - - return future; - } - + TAsyncGetQueryStatusResult GetQueryStatus( + const YandexQuery::GetQueryStatusRequest& protoRequest, + const TGetQueryStatusSettings& settings) { + auto request = MakeOperationRequest<YandexQuery::GetQueryStatusRequest>(settings); + request = protoRequest; + + auto promise = NThreading::NewPromise<TGetQueryStatusResult>(); + auto future = promise.GetFuture(); + + auto extractor = MakeResultExtractor< + YandexQuery::GetQueryStatusResult, + TGetQueryStatusResult>(std::move(promise)); + + Connections_->RunDeferred< + YandexQuery::V1::YandexQueryService, + YandexQuery::GetQueryStatusRequest, + YandexQuery::GetQueryStatusResponse>( + std::move(request), + std::move(extractor), + &YandexQuery::V1::YandexQueryService::Stub::AsyncGetQueryStatus, + DbDriverState_, + INITIAL_DEFERRED_CALL_DELAY, + TRpcRequestSettings::Make(settings), + settings.ClientTimeout_); + + return future; + } + TAsyncModifyQueryResult ModifyQuery( const YandexQuery::ModifyQueryRequest& protoRequest, const TModifyQuerySettings& settings) { @@ -284,34 +284,34 @@ public: return future; } - TAsyncDescribeJobResult DescribeJob( - const YandexQuery::DescribeJobRequest& protoRequest, - const TDescribeJobSettings& settings) { - auto request = MakeOperationRequest<YandexQuery::DescribeJobRequest>(settings); - request = protoRequest; - - auto promise = NThreading::NewPromise<TDescribeJobResult>(); - auto future = promise.GetFuture(); - - auto extractor = MakeResultExtractor< - YandexQuery::DescribeJobResult, - TDescribeJobResult>(std::move(promise)); - - Connections_->RunDeferred< - YandexQuery::V1::YandexQueryService, - YandexQuery::DescribeJobRequest, - YandexQuery::DescribeJobResponse>( - std::move(request), - std::move(extractor), - &YandexQuery::V1::YandexQueryService::Stub::AsyncDescribeJob, - DbDriverState_, - INITIAL_DEFERRED_CALL_DELAY, - TRpcRequestSettings::Make(settings), - settings.ClientTimeout_); - - return future; - } - + TAsyncDescribeJobResult DescribeJob( + const YandexQuery::DescribeJobRequest& protoRequest, + const TDescribeJobSettings& settings) { + auto request = MakeOperationRequest<YandexQuery::DescribeJobRequest>(settings); + request = protoRequest; + + auto promise = NThreading::NewPromise<TDescribeJobResult>(); + auto future = promise.GetFuture(); + + auto extractor = MakeResultExtractor< + YandexQuery::DescribeJobResult, + TDescribeJobResult>(std::move(promise)); + + Connections_->RunDeferred< + YandexQuery::V1::YandexQueryService, + YandexQuery::DescribeJobRequest, + YandexQuery::DescribeJobResponse>( + std::move(request), + std::move(extractor), + &YandexQuery::V1::YandexQueryService::Stub::AsyncDescribeJob, + DbDriverState_, + INITIAL_DEFERRED_CALL_DELAY, + TRpcRequestSettings::Make(settings), + settings.ClientTimeout_); + + return future; + } + TAsyncCreateConnectionResult CreateConnection( const YandexQuery::CreateConnectionRequest& protoRequest, const TCreateConnectionSettings& settings) { @@ -643,12 +643,12 @@ TAsyncDescribeQueryResult TClient::DescribeQuery( return Impl_->DescribeQuery(request, settings); } -TAsyncGetQueryStatusResult TClient::GetQueryStatus( - const YandexQuery::GetQueryStatusRequest& request, - const TGetQueryStatusSettings& settings) { - return Impl_->GetQueryStatus(request, settings); -} - +TAsyncGetQueryStatusResult TClient::GetQueryStatus( + const YandexQuery::GetQueryStatusRequest& request, + const TGetQueryStatusSettings& settings) { + return Impl_->GetQueryStatus(request, settings); +} + TAsyncModifyQueryResult TClient::ModifyQuery( const YandexQuery::ModifyQueryRequest& request, const TModifyQuerySettings& settings) { @@ -679,12 +679,12 @@ TAsyncListJobsResult TClient::ListJobs( return Impl_->ListJobs(request, settings); } -TAsyncDescribeJobResult TClient::DescribeJob( - const YandexQuery::DescribeJobRequest& request, - const TDescribeJobSettings& settings) { - return Impl_->DescribeJob(request, settings); -} - +TAsyncDescribeJobResult TClient::DescribeJob( + const YandexQuery::DescribeJobRequest& request, + const TDescribeJobSettings& settings) { + return Impl_->DescribeJob(request, settings); +} + TAsyncCreateConnectionResult TClient::CreateConnection( const YandexQuery::CreateConnectionRequest& request, const TCreateConnectionSettings& settings) { diff --git a/ydb/public/lib/yq/yq.h b/ydb/public/lib/yq/yq.h index 31b3a6b991..9543150346 100644 --- a/ydb/public/lib/yq/yq.h +++ b/ydb/public/lib/yq/yq.h @@ -46,10 +46,10 @@ using TDescribeQueryResult = TProtoResultWrapper<YandexQuery::DescribeQueryResul using TAsyncDescribeQueryResult = NThreading::TFuture<TDescribeQueryResult>; struct TDescribeQuerySettings : public NYdb::TOperationRequestSettings<TDescribeQuerySettings> {}; -using TGetQueryStatusResult = TProtoResultWrapper<YandexQuery::GetQueryStatusResult>; -using TAsyncGetQueryStatusResult = NThreading::TFuture<TGetQueryStatusResult>; -struct TGetQueryStatusSettings : public NYdb::TOperationRequestSettings<TGetQueryStatusSettings> {}; - +using TGetQueryStatusResult = TProtoResultWrapper<YandexQuery::GetQueryStatusResult>; +using TAsyncGetQueryStatusResult = NThreading::TFuture<TGetQueryStatusResult>; +struct TGetQueryStatusSettings : public NYdb::TOperationRequestSettings<TGetQueryStatusSettings> {}; + using TModifyQueryResult = TProtoResultWrapper<YandexQuery::ModifyQueryResult>; using TAsyncModifyQueryResult = NThreading::TFuture<TModifyQueryResult>; struct TModifyQuerySettings : public NYdb::TOperationRequestSettings<TModifyQuerySettings> {}; @@ -70,10 +70,10 @@ using TListJobsResult = TProtoResultWrapper<YandexQuery::ListJobsResult>; using TAsyncListJobsResult = NThreading::TFuture<TListJobsResult>; struct TListJobsSettings : public NYdb::TOperationRequestSettings<TListJobsSettings> {}; -using TDescribeJobResult = TProtoResultWrapper<YandexQuery::DescribeJobResult>; -using TAsyncDescribeJobResult = NThreading::TFuture<TDescribeJobResult>; -struct TDescribeJobSettings : public NYdb::TOperationRequestSettings<TDescribeJobSettings> {}; - +using TDescribeJobResult = TProtoResultWrapper<YandexQuery::DescribeJobResult>; +using TAsyncDescribeJobResult = NThreading::TFuture<TDescribeJobResult>; +struct TDescribeJobSettings : public NYdb::TOperationRequestSettings<TDescribeJobSettings> {}; + using TCreateConnectionResult = TProtoResultWrapper<YandexQuery::CreateConnectionResult>; using TAsyncCreateConnectionResult = NThreading::TFuture<TCreateConnectionResult>; struct TCreateConnectionSettings : public NYdb::TOperationRequestSettings<TCreateConnectionSettings> {}; @@ -136,10 +136,10 @@ public: const YandexQuery::DescribeQueryRequest& request, const TDescribeQuerySettings& settings = TDescribeQuerySettings()); - TAsyncGetQueryStatusResult GetQueryStatus( - const YandexQuery::GetQueryStatusRequest& request, - const TGetQueryStatusSettings& settings = TGetQueryStatusSettings()); - + TAsyncGetQueryStatusResult GetQueryStatus( + const YandexQuery::GetQueryStatusRequest& request, + const TGetQueryStatusSettings& settings = TGetQueryStatusSettings()); + TAsyncModifyQueryResult ModifyQuery( const YandexQuery::ModifyQueryRequest& request, const TModifyQuerySettings& settings = TModifyQuerySettings()); @@ -160,10 +160,10 @@ public: const YandexQuery::ListJobsRequest& request, const TListJobsSettings& settings = TListJobsSettings()); - TAsyncDescribeJobResult DescribeJob( - const YandexQuery::DescribeJobRequest& request, - const TDescribeJobSettings& settings = TDescribeJobSettings()); - + TAsyncDescribeJobResult DescribeJob( + const YandexQuery::DescribeJobRequest& request, + const TDescribeJobSettings& settings = TDescribeJobSettings()); + TAsyncCreateConnectionResult CreateConnection( const YandexQuery::CreateConnectionRequest& request, const TCreateConnectionSettings& settings = TCreateConnectionSettings()); diff --git a/ydb/services/yq/ut_integration/yq_ut.cpp b/ydb/services/yq/ut_integration/yq_ut.cpp index d4a35f195e..db08530c35 100644 --- a/ydb/services/yq/ut_integration/yq_ut.cpp +++ b/ydb/services/yq/ut_integration/yq_ut.cpp @@ -57,16 +57,16 @@ namespace { UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); queryId = result.GetResult().query_id(); } - // GetQueryStatus - const auto request = ::NYq::TGetQueryStatusBuilder{} + // GetQueryStatus + const auto request = ::NYq::TGetQueryStatusBuilder{} .SetQueryId(queryId) .Build(); const auto result = DoWithRetryOnRetCode([&]() { - auto result = client.GetQueryStatus( - request, CreateYqSettings<TGetQueryStatusSettings>(folderId)) + auto result = client.GetQueryStatus( + request, CreateYqSettings<TGetQueryStatusSettings>(folderId)) .ExtractValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); - return result.GetResult().status() == expectedStatusResult; + return result.GetResult().status() == expectedStatusResult; }, TRetryOptions(Retries)); UNIT_ASSERT_C(result, "the execution of the query did not end within the time limit"); @@ -581,8 +581,8 @@ Y_UNIT_TEST_SUITE(Yq_1) { NYdb::NYq::TClient client(driver); const auto folderId = TString(__func__) + "folder_id"; - auto name = TString(__func__) + "_name"; - name.to_lower(); + auto name = TString(__func__) + "_name"; + name.to_lower(); { const auto request = ::NYq::TCreateConnectionBuilder() @@ -788,71 +788,71 @@ Y_UNIT_TEST_SUITE(Yq_1) { UNIT_ASSERT_VALUES_EQUAL(query.content().description(), "OK"); } } - - Y_UNIT_TEST(DescribeJob) { - TKikimrWithGrpcAndRootSchema server({}, {}, {}, true); - ui16 grpc = server.GetPort(); - TString location = TStringBuilder() << "localhost:" << grpc; - auto driver = TDriver(TDriverConfig().SetEndpoint(location).SetAuthToken("root@builtin")); - NYdb::NYq::TClient client(driver); - const auto folderId = "some_folder_id"; - const auto queryId = CreateNewHistoryAndWaitFinish(folderId, client, "select 1", YandexQuery::QueryMeta::COMPLETED); - CheckGetResultData(client, queryId, folderId, 1, 1, 1); - TString jobId; - - { - auto request = ::NYq::TListJobsBuilder{}.SetQueryId(queryId).Build(); - auto result = DoWithRetryOnRetCode([&]() { - auto result = client.ListJobs( - request, CreateYqSettings<TListJobsSettings>(folderId)) - .ExtractValueSync(); - UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); - UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job_size(), 1); - jobId = result.GetResult().job(0).meta().id(); - return result.GetStatus() == EStatus::SUCCESS; - }, TRetryOptions(Retries)); - UNIT_ASSERT_C(result, "the execution of the query did not end within the time limit"); - } - - { - const auto request = ::NYq::TDescribeJobBuilder() - .SetJobId(jobId) - .Build(); - auto result = client.DescribeJob( - request, CreateYqSettings<TDescribeJobSettings>(folderId)) - .ExtractValueSync(); - UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + + Y_UNIT_TEST(DescribeJob) { + TKikimrWithGrpcAndRootSchema server({}, {}, {}, true); + ui16 grpc = server.GetPort(); + TString location = TStringBuilder() << "localhost:" << grpc; + auto driver = TDriver(TDriverConfig().SetEndpoint(location).SetAuthToken("root@builtin")); + NYdb::NYq::TClient client(driver); + const auto folderId = "some_folder_id"; + const auto queryId = CreateNewHistoryAndWaitFinish(folderId, client, "select 1", YandexQuery::QueryMeta::COMPLETED); + CheckGetResultData(client, queryId, folderId, 1, 1, 1); + TString jobId; + + { + auto request = ::NYq::TListJobsBuilder{}.SetQueryId(queryId).Build(); + auto result = DoWithRetryOnRetCode([&]() { + auto result = client.ListJobs( + request, CreateYqSettings<TListJobsSettings>(folderId)) + .ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job_size(), 1); + jobId = result.GetResult().job(0).meta().id(); + return result.GetStatus() == EStatus::SUCCESS; + }, TRetryOptions(Retries)); + UNIT_ASSERT_C(result, "the execution of the query did not end within the time limit"); + } + + { + const auto request = ::NYq::TDescribeJobBuilder() + .SetJobId(jobId) + .Build(); + auto result = client.DescribeJob( + request, CreateYqSettings<TDescribeJobSettings>(folderId)) + .ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job().query_meta().common().id(), queryId); - UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job().meta().id(), jobId); - UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job().query_name(), "test_query_name_1"); - } - } - - Y_UNIT_TEST(DescribeQuery) { - TKikimrWithGrpcAndRootSchema server({}, {}, {}, true); - ui16 grpc = server.GetPort(); - TString location = TStringBuilder() << "localhost:" << grpc; - auto driver = TDriver(TDriverConfig().SetEndpoint(location).SetAuthToken("root@builtin")); - NYdb::NYq::TClient client(driver); - const auto folderId = "some_folder_id"; - const auto queryId = CreateNewHistoryAndWaitFinish(folderId, client, "select 1", YandexQuery::QueryMeta::COMPLETED); - CheckGetResultData(client, queryId, folderId, 1, 1, 1); - TString jobId; - - { - const auto request = ::NYq::TDescribeQueryBuilder() - .SetQueryId(queryId) - .Build(); - auto result = client.DescribeQuery( - request, CreateYqSettings<TDescribeQuerySettings>(folderId)) - .ExtractValueSync(); - UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); - const auto query = result.GetResult().query(); - UNIT_ASSERT_VALUES_EQUAL(YandexQuery::QueryMeta::ComputeStatus_Name(query.meta().status()), YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::COMPLETED)); - UNIT_ASSERT_VALUES_EQUAL(query.content().text(), "select 1"); - UNIT_ASSERT_VALUES_EQUAL(query.content().name(), "test_query_name_1"); - } - } + UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job().meta().id(), jobId); + UNIT_ASSERT_VALUES_EQUAL(result.GetResult().job().query_name(), "test_query_name_1"); + } + } + + Y_UNIT_TEST(DescribeQuery) { + TKikimrWithGrpcAndRootSchema server({}, {}, {}, true); + ui16 grpc = server.GetPort(); + TString location = TStringBuilder() << "localhost:" << grpc; + auto driver = TDriver(TDriverConfig().SetEndpoint(location).SetAuthToken("root@builtin")); + NYdb::NYq::TClient client(driver); + const auto folderId = "some_folder_id"; + const auto queryId = CreateNewHistoryAndWaitFinish(folderId, client, "select 1", YandexQuery::QueryMeta::COMPLETED); + CheckGetResultData(client, queryId, folderId, 1, 1, 1); + TString jobId; + + { + const auto request = ::NYq::TDescribeQueryBuilder() + .SetQueryId(queryId) + .Build(); + auto result = client.DescribeQuery( + request, CreateYqSettings<TDescribeQuerySettings>(folderId)) + .ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + const auto query = result.GetResult().query(); + UNIT_ASSERT_VALUES_EQUAL(YandexQuery::QueryMeta::ComputeStatus_Name(query.meta().status()), YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::COMPLETED)); + UNIT_ASSERT_VALUES_EQUAL(query.content().text(), "select 1"); + UNIT_ASSERT_VALUES_EQUAL(query.content().name(), "test_query_name_1"); + } + } } Y_UNIT_TEST_SUITE(Yq_2) { |