aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaxkovalev <maxkovalev@yandex-team.com>2023-01-25 15:25:01 +0300
committermaxkovalev <maxkovalev@yandex-team.com>2023-01-25 15:25:01 +0300
commit17979d2f0b89fb14e33d6c328f4e4a0deeb4df8e (patch)
tree95600bda8b1394655cf30875ffb7290ae5386a73
parent9891487626af4bc05ee05ac05f06238704fac139 (diff)
downloadydb-17979d2f0b89fb14e33d6c328f4e4a0deeb4df8e.tar.gz
Make DbPool library self-sufficient
YQ: Make DbPool library self-sufficient
-rw-r--r--ydb/core/yq/libs/CMakeLists.txt1
-rw-r--r--ydb/core/yq/libs/common/CMakeLists.darwin.txt1
-rw-r--r--ydb/core/yq/libs/common/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/yq/libs/common/CMakeLists.linux.txt1
-rw-r--r--ydb/core/yq/libs/common/debug_info.cpp32
-rw-r--r--ydb/core/yq/libs/common/debug_info.h23
-rw-r--r--ydb/core/yq/libs/control_plane_config/control_plane_config.cpp2
-rw-r--r--ydb/core/yq/libs/control_plane_storage/CMakeLists.darwin.txt1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/CMakeLists.linux.txt1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/events/events.h37
-rw-r--r--ydb/core/yq/libs/control_plane_storage/exceptions.cpp37
-rw-r--r--ydb/core/yq/libs/control_plane_storage/exceptions.h26
-rw-r--r--ydb/core/yq/libs/control_plane_storage/extractors.h4
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.darwin.txt1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux.txt1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/task_get.cpp4
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/task_ping.cpp32
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/task_result_write.cpp2
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/utils.h1
-rw-r--r--ydb/core/yq/libs/control_plane_storage/request_actor.h2
-rw-r--r--ydb/core/yq/libs/control_plane_storage/validators.cpp64
-rw-r--r--ydb/core/yq/libs/control_plane_storage/validators.h10
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage.cpp51
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_bindings.cpp30
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_connections.cpp22
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h8
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_queries.cpp104
-rw-r--r--ydb/core/yq/libs/exceptions/CMakeLists.darwin.txt18
-rw-r--r--ydb/core/yq/libs/exceptions/CMakeLists.linux-aarch64.txt19
-rw-r--r--ydb/core/yq/libs/exceptions/CMakeLists.linux.txt19
-rw-r--r--ydb/core/yq/libs/exceptions/CMakeLists.txt15
-rw-r--r--ydb/core/yq/libs/exceptions/exceptions.cpp37
-rw-r--r--ydb/core/yq/libs/exceptions/exceptions.h27
-rw-r--r--ydb/core/yq/libs/quota_manager/quota_manager.cpp20
-rw-r--r--ydb/core/yq/libs/shared_resources/CMakeLists.darwin.txt4
-rw-r--r--ydb/core/yq/libs/shared_resources/CMakeLists.linux-aarch64.txt4
-rw-r--r--ydb/core/yq/libs/shared_resources/CMakeLists.linux.txt4
-rw-r--r--ydb/core/yq/libs/shared_resources/db_exec.h12
-rw-r--r--ydb/core/yq/libs/shared_resources/db_pool.cpp29
-rw-r--r--ydb/core/yq/libs/shared_resources/db_pool.h24
42 files changed, 430 insertions, 303 deletions
diff --git a/ydb/core/yq/libs/CMakeLists.txt b/ydb/core/yq/libs/CMakeLists.txt
index a0657f4bea..112d4924c4 100644
--- a/ydb/core/yq/libs/CMakeLists.txt
+++ b/ydb/core/yq/libs/CMakeLists.txt
@@ -19,6 +19,7 @@ add_subdirectory(control_plane_storage)
add_subdirectory(db_id_async_resolver_impl)
add_subdirectory(db_schema)
add_subdirectory(events)
+add_subdirectory(exceptions)
add_subdirectory(gateway)
add_subdirectory(graph_params)
add_subdirectory(grpc)
diff --git a/ydb/core/yq/libs/common/CMakeLists.darwin.txt b/ydb/core/yq/libs/common/CMakeLists.darwin.txt
index 5c5eea9845..9784279731 100644
--- a/ydb/core/yq/libs/common/CMakeLists.darwin.txt
+++ b/ydb/core/yq/libs/common/CMakeLists.darwin.txt
@@ -24,6 +24,7 @@ target_link_libraries(yq-libs-common PUBLIC
)
target_sources(yq-libs-common PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/compression.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/debug_info.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/entity_id.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/rows_proto_splitter.cpp
)
diff --git a/ydb/core/yq/libs/common/CMakeLists.linux-aarch64.txt b/ydb/core/yq/libs/common/CMakeLists.linux-aarch64.txt
index c797b7c622..e37fff1049 100644
--- a/ydb/core/yq/libs/common/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/yq/libs/common/CMakeLists.linux-aarch64.txt
@@ -25,6 +25,7 @@ target_link_libraries(yq-libs-common PUBLIC
)
target_sources(yq-libs-common PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/compression.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/debug_info.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/entity_id.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/rows_proto_splitter.cpp
)
diff --git a/ydb/core/yq/libs/common/CMakeLists.linux.txt b/ydb/core/yq/libs/common/CMakeLists.linux.txt
index c797b7c622..e37fff1049 100644
--- a/ydb/core/yq/libs/common/CMakeLists.linux.txt
+++ b/ydb/core/yq/libs/common/CMakeLists.linux.txt
@@ -25,6 +25,7 @@ target_link_libraries(yq-libs-common PUBLIC
)
target_sources(yq-libs-common PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/compression.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/debug_info.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/entity_id.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/common/rows_proto_splitter.cpp
)
diff --git a/ydb/core/yq/libs/common/debug_info.cpp b/ydb/core/yq/libs/common/debug_info.cpp
new file mode 100644
index 0000000000..ba03e8dd53
--- /dev/null
+++ b/ydb/core/yq/libs/common/debug_info.cpp
@@ -0,0 +1,32 @@
+#include "debug_info.h"
+
+#include <ydb/public/sdk/cpp/client/ydb_proto/accessor.h>
+
+namespace NYq {
+
+TString TDebugItem::ToString() const {
+ TString result;
+ result += "Query: " + Query + "\n";
+ result += "Plan: " + Plan + "\n";
+ result += "Ast: " + Ast + "\n";
+ for (const auto& param: Params.GetValues()) {
+ result += "Params: " + param.first + ", " + param.second.GetType().ToString() + "\n";
+ }
+ result += "Error: " + Error + "\n";
+ return result;
+}
+
+size_t TDebugItem::GetByteSize() const {
+ size_t paramsSize = 0;
+ for (const auto& [key, value]: Params.GetValues()) {
+ paramsSize += key.Size() + NYdb::TProtoAccessor::GetProto(value).ByteSizeLong();
+ }
+ return sizeof(*this)
+ + Query.Size()
+ + paramsSize
+ + Plan.Size()
+ + Ast.Size()
+ + Error.Size();
+}
+
+} // namespace NYq \ No newline at end of file
diff --git a/ydb/core/yq/libs/common/debug_info.h b/ydb/core/yq/libs/common/debug_info.h
new file mode 100644
index 0000000000..698f81210e
--- /dev/null
+++ b/ydb/core/yq/libs/common/debug_info.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <util/generic/string.h>
+
+#include <ydb/public/sdk/cpp/client/ydb_params/params.h>
+
+namespace NYq {
+
+struct TDebugItem {
+ TString Query;
+ NYdb::TParams Params;
+ TString Plan;
+ TString Ast;
+ TString Error;
+
+ TString ToString() const;
+ size_t GetByteSize() const;
+};
+
+using TDebugInfo = TVector<TDebugItem>;
+using TDebugInfoPtr = std::shared_ptr<TDebugInfo>;
+
+} // namespace NYq \ No newline at end of file
diff --git a/ydb/core/yq/libs/control_plane_config/control_plane_config.cpp b/ydb/core/yq/libs/control_plane_config/control_plane_config.cpp
index b260bef85f..3e83245a05 100644
--- a/ydb/core/yq/libs/control_plane_config/control_plane_config.cpp
+++ b/ydb/core/yq/libs/control_plane_config/control_plane_config.cpp
@@ -252,7 +252,7 @@ TActorId ControlPlaneConfigActorId() {
return NActors::TActorId(0, name);
}
-IActor* CreateControlPlaneConfigActor(const ::NYq::TYqSharedResources::TPtr& yqSharedResources, const NKikimr::TYdbCredentialsProviderFactory& credProviderFactory, const NConfig::TControlPlaneStorageConfig& config, const ::NMonitoring::TDynamicCounterPtr& counters) {
+NActors::IActor* CreateControlPlaneConfigActor(const ::NYq::TYqSharedResources::TPtr& yqSharedResources, const NKikimr::TYdbCredentialsProviderFactory& credProviderFactory, const NConfig::TControlPlaneStorageConfig& config, const ::NMonitoring::TDynamicCounterPtr& counters) {
return new TControlPlaneConfigActor(yqSharedResources, credProviderFactory, config, counters);
}
diff --git a/ydb/core/yq/libs/control_plane_storage/CMakeLists.darwin.txt b/ydb/core/yq/libs/control_plane_storage/CMakeLists.darwin.txt
index f0d2fb8e50..a0a3f4a27c 100644
--- a/ydb/core/yq/libs/control_plane_storage/CMakeLists.darwin.txt
+++ b/ydb/core/yq/libs/control_plane_storage/CMakeLists.darwin.txt
@@ -43,7 +43,6 @@ target_link_libraries(yq-libs-control_plane_storage PUBLIC
target_sources(yq-libs-control_plane_storage PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/config.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/control_plane_storage_counters.cpp
- ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/exceptions.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/probes.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/request_validators.cpp
diff --git a/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux-aarch64.txt b/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux-aarch64.txt
index 23811f1727..d62369ae17 100644
--- a/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux-aarch64.txt
@@ -44,7 +44,6 @@ target_link_libraries(yq-libs-control_plane_storage PUBLIC
target_sources(yq-libs-control_plane_storage PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/config.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/control_plane_storage_counters.cpp
- ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/exceptions.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/probes.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/request_validators.cpp
diff --git a/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux.txt b/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux.txt
index 23811f1727..d62369ae17 100644
--- a/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux.txt
+++ b/ydb/core/yq/libs/control_plane_storage/CMakeLists.linux.txt
@@ -44,7 +44,6 @@ target_link_libraries(yq-libs-control_plane_storage PUBLIC
target_sources(yq-libs-control_plane_storage PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/config.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/control_plane_storage_counters.cpp
- ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/exceptions.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/in_memory_control_plane_storage.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/probes.cpp
${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/control_plane_storage/request_validators.cpp
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 24cddda42d..358b367918 100644
--- a/ydb/core/yq/libs/control_plane_storage/events/events.h
+++ b/ydb/core/yq/libs/control_plane_storage/events/events.h
@@ -14,6 +14,7 @@
#include <ydb/library/yql/public/issue/yql_issue.h>
+#include <ydb/core/yq/libs/common/debug_info.h>
#include <ydb/core/yq/libs/control_plane_config/events/events.h>
#include <ydb/core/yq/libs/control_plane_storage/proto/yq_internal.pb.h>
#include <ydb/core/yq/libs/events/event_subspace.h>
@@ -43,42 +44,6 @@ struct TNodeInfo {
TString HostName;
};
-struct TDebugItem {
- TString Query;
- NYdb::TParams Params;
- TString Plan;
- TString Ast;
- TString Error;
-
- TString ToString() const {
- TString result;
- result += "Query: " + Query + "\n";
- result += "Plan: " + Plan + "\n";
- result += "Ast: " + Ast + "\n";
- for (const auto& param: Params.GetValues()) {
- result += "Params: " + param.first + ", " + param.second.GetType().ToString() + "\n";
- }
- result += "Error: " + Error + "\n";
- return result;
- }
-
- size_t GetByteSize() const {
- size_t paramsSize = 0;
- for (const auto& [key, value]: Params.GetValues()) {
- paramsSize += key.Size() + NYdb::TProtoAccessor::GetProto(value).ByteSizeLong();
- }
- return sizeof(*this)
- + Query.Size()
- + paramsSize
- + Plan.Size()
- + Ast.Size()
- + Error.Size();
- }
-};
-
-using TDebugInfo = TVector<TDebugItem>;
-using TDebugInfoPtr = std::shared_ptr<TDebugInfo>;
-
struct TPermissions {
enum TPermission {
VIEW_PUBLIC = 0x1,
diff --git a/ydb/core/yq/libs/control_plane_storage/exceptions.cpp b/ydb/core/yq/libs/control_plane_storage/exceptions.cpp
deleted file mode 100644
index ab971f11d3..0000000000
--- a/ydb/core/yq/libs/control_plane_storage/exceptions.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "exceptions.h"
-
-#include <util/string/builder.h>
-
-namespace NYq {
-
-TControlPlaneStorageException::TControlPlaneStorageException(TIssuesIds::EIssueCode code)
- : SourceLocation("", 0)
- , Code(code)
-{}
-
-TControlPlaneStorageException::TControlPlaneStorageException(const TSourceLocation& sl, const TControlPlaneStorageException& t)
- : yexception(t)
- , SourceLocation(sl)
- , Code(t.Code)
-{}
-
-const char* TControlPlaneStorageException::GetRawMessage() const {
- return yexception::what();
-}
-
-const char* TControlPlaneStorageException::what() const noexcept {
- try {
- if (!Message) {
- Message = TStringBuilder{} << SourceLocation << TStringBuf(": ") << yexception::what();
- }
- return Message.c_str();
- } catch(...) {
- return "Unexpected exception in TControlPlaneStorageException::what()";
- }
-}
-
-TControlPlaneStorageException operator+(const TSourceLocation& sl, TControlPlaneStorageException&& t) {
- return TControlPlaneStorageException(sl, t);
-}
-
-} // namespace NYq \ No newline at end of file
diff --git a/ydb/core/yq/libs/control_plane_storage/exceptions.h b/ydb/core/yq/libs/control_plane_storage/exceptions.h
deleted file mode 100644
index 996fc379f4..0000000000
--- a/ydb/core/yq/libs/control_plane_storage/exceptions.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include <util/generic/yexception.h>
-#include <util/system/compiler.h>
-
-#include <ydb/core/yq/libs/config/protos/issue_id.pb.h>
-
-namespace NYq {
-
-struct TControlPlaneStorageException: public yexception {
- TSourceLocation SourceLocation;
- mutable TString Message;
- TIssuesIds::EIssueCode Code;
-
- TControlPlaneStorageException(TIssuesIds::EIssueCode code);
-
- TControlPlaneStorageException(const TSourceLocation& sl, const TControlPlaneStorageException& t);
-
- const char* what() const noexcept override;
-
- const char* GetRawMessage() const;
-};
-
-TControlPlaneStorageException operator+(const TSourceLocation& sl, TControlPlaneStorageException&& t);
-
-} // namespace NYq
diff --git a/ydb/core/yq/libs/control_plane_storage/extractors.h b/ydb/core/yq/libs/control_plane_storage/extractors.h
index 6d75f372a3..0513af677a 100644
--- a/ydb/core/yq/libs/control_plane_storage/extractors.h
+++ b/ydb/core/yq/libs/control_plane_storage/extractors.h
@@ -25,7 +25,7 @@ TValidationQuery CreateEntityExtractor(const TString& scope,
auto validator = [response, entityColumnName](NYdb::NTable::TDataQueryResult result) {
const auto& resultSets = result.GetResultSets();
if (resultSets.size() != 1) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "internal error, result set size is not equal to 1 but equal " << resultSets.size();
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "internal error, result set size is not equal to 1 but equal " << resultSets.size();
}
NYdb::TResultSetParser parser(resultSets.back());
@@ -34,7 +34,7 @@ TValidationQuery CreateEntityExtractor(const TString& scope,
}
if (!response->second.Before.ConstructInPlace().ParseFromString(*parser.ColumnParser(entityColumnName).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message. Please contact internal support";
}
return false;
};
diff --git a/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.darwin.txt b/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.darwin.txt
index 1cacc2fca5..9f0f917231 100644
--- a/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.darwin.txt
+++ b/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.darwin.txt
@@ -23,6 +23,7 @@ target_link_libraries(libs-control_plane_storage-internal PUBLIC
yq-libs-common
yq-libs-config
libs-control_plane_storage-proto
+ yq-libs-exceptions
yq-libs-quota_manager
libs-quota_manager-events
libs-rate_limiter-events
diff --git a/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux-aarch64.txt b/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux-aarch64.txt
index c3b21889cf..5b69f6913b 100644
--- a/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux-aarch64.txt
@@ -24,6 +24,7 @@ target_link_libraries(libs-control_plane_storage-internal PUBLIC
yq-libs-common
yq-libs-config
libs-control_plane_storage-proto
+ yq-libs-exceptions
yq-libs-quota_manager
libs-quota_manager-events
libs-rate_limiter-events
diff --git a/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux.txt b/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux.txt
index c3b21889cf..5b69f6913b 100644
--- a/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux.txt
+++ b/ydb/core/yq/libs/control_plane_storage/internal/CMakeLists.linux.txt
@@ -24,6 +24,7 @@ target_link_libraries(libs-control_plane_storage-internal PUBLIC
yq-libs-common
yq-libs-config
libs-control_plane_storage-proto
+ yq-libs-exceptions
yq-libs-quota_manager
libs-quota_manager-events
libs-rate_limiter-events
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 8d768270c8..490575f227 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
@@ -186,12 +186,12 @@ std::tuple<TString, NYdb::TParams, std::function<std::pair<TString, NYdb::TParam
task.Generation = parser.ColumnParser(GENERATION_COLUMN_NAME).GetOptionalUint64().GetOrElse(0) + 1;
if (!task.Query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- throw TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ throw TCodeLineException(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;
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";
+ throw TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
}
if (disableCurrentIam) {
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 bd1cac2655..f58fbed247 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
@@ -52,29 +52,29 @@ TPingTaskParams ConstructHardPingTask(
TString owner;
if (resultSets.size() != 3) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "RESULT SET SIZE of " << resultSets.size() << " != 3";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "RESULT SET SIZE of " << resultSets.size() << " != 3";
}
{
TResultSetParser parser(resultSets[0]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " QUERIES_TABLE_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " QUERIES_TABLE_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"";
}
if (!query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " QUERIES_TABLE_NAME "." QUERY_COLUMN_NAME " where " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\"";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " QUERIES_TABLE_NAME "." QUERY_COLUMN_NAME " where " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\"";
}
if (!internal.ParseFromString(*parser.ColumnParser(INTERNAL_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " QUERIES_TABLE_NAME "." INTERNAL_COLUMN_NAME " where " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\"";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " QUERIES_TABLE_NAME "." INTERNAL_COLUMN_NAME " where " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\"";
}
}
{
TResultSetParser parser(resultSets[1]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " JOBS_TABLE_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " JOBS_TABLE_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"";
}
if (!job.ParseFromString(*parser.ColumnParser(JOB_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " JOBS_TABLE_NAME "." JOB_COLUMN_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " JOBS_TABLE_NAME "." JOB_COLUMN_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"";
}
jobId = *parser.ColumnParser(JOB_ID_COLUMN_NAME).GetOptionalString();
}
@@ -83,11 +83,11 @@ TPingTaskParams ConstructHardPingTask(
{
TResultSetParser parser(resultSets[2]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " PENDING_SMALL_TABLE_NAME " where " TENANT_COLUMN_NAME " = \"" << request.tenant() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"" ;
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " PENDING_SMALL_TABLE_NAME " where " TENANT_COLUMN_NAME " = \"" << request.tenant() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"" ;
}
owner = *parser.ColumnParser(OWNER_COLUMN_NAME).GetOptionalString();
if (owner != request.owner_id()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "OWNER of QUERY ID = \"" << request.query_id().value() << "\" MISMATCHED: \"" << request.owner_id() << "\" (received) != \"" << owner << "\" (selected)";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "OWNER of QUERY ID = \"" << request.query_id().value() << "\" MISMATCHED: \"" << request.owner_id() << "\" (received) != \"" << owner << "\" (selected)";
}
retryLimiter.Assign(
parser.ColumnParser(RETRY_COUNTER_COLUMN_NAME).GetOptionalUint64().GetOrElse(0),
@@ -291,15 +291,15 @@ TPingTaskParams ConstructHardPingTask(
}
if (job.ByteSizeLong() > maxRequestSize) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Job proto exceeded the size limit: " << job.ByteSizeLong() << " of " << maxRequestSize << " " << TSizeFormatPrinter(job).ToString();
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Job proto exceeded the size limit: " << job.ByteSizeLong() << " of " << maxRequestSize << " " << TSizeFormatPrinter(job).ToString();
}
if (query.ByteSizeLong() > maxRequestSize) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Query proto exceeded the size limit: " << query.ByteSizeLong() << " of " << maxRequestSize << " " << TSizeFormatPrinter(query).ToString();
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Query proto exceeded the size limit: " << query.ByteSizeLong() << " of " << maxRequestSize << " " << TSizeFormatPrinter(query).ToString();
}
if (internal.ByteSizeLong() > maxRequestSize) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "QueryInternal proto exceeded the size limit: " << internal.ByteSizeLong() << " of " << maxRequestSize << " " << TSizeFormatPrinter(internal).ToString();
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "QueryInternal proto exceeded the size limit: " << internal.ByteSizeLong() << " of " << maxRequestSize << " " << TSizeFormatPrinter(internal).ToString();
}
TSqlQueryBuilder writeQueryBuilder(tablePathPrefix, "HardPingTask(write)");
@@ -414,27 +414,27 @@ TPingTaskParams ConstructSoftPingTask(
YandexQuery::Internal::QueryInternal internal;
if (resultSets.size() != 2) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "RESULT SET SIZE of " << resultSets.size() << " != 2";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "RESULT SET SIZE of " << resultSets.size() << " != 2";
}
{
TResultSetParser parser(resultSets[0]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " QUERIES_TABLE_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"" ;
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " QUERIES_TABLE_NAME " where " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"" ;
}
if (!internal.ParseFromString(*parser.ColumnParser(INTERNAL_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " QUERIES_TABLE_NAME "." INTERNAL_COLUMN_NAME " where " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\"";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "ERROR PARSING " QUERIES_TABLE_NAME "." INTERNAL_COLUMN_NAME " where " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\"";
}
}
{
TResultSetParser parser(resultSets[1]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " PENDING_SMALL_TABLE_NAME " where " TENANT_COLUMN_NAME " = \"" << request.tenant() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"" ;
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "NOT FOUND " PENDING_SMALL_TABLE_NAME " where " TENANT_COLUMN_NAME " = \"" << request.tenant() << "\" and " SCOPE_COLUMN_NAME " = \"" << request.scope() << "\" and " QUERY_ID_COLUMN_NAME " = \"" << request.query_id().value() << "\"" ;
}
owner = *parser.ColumnParser(OWNER_COLUMN_NAME).GetOptionalString();
if (owner != request.owner_id()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "OWNER of QUERY ID = \"" << request.query_id().value() << "\" MISMATCHED: \"" << request.owner_id() << "\" (received) != \"" << owner << "\" (selected)";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "OWNER of QUERY ID = \"" << request.query_id().value() << "\" MISMATCHED: \"" << request.owner_id() << "\" (received) != \"" << owner << "\" (selected)";
}
}
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 9cc68f7258..185b7b8d40 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
@@ -39,7 +39,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvWriteResult
for (const auto& row : resultSet.rows()) {
TString serializedRow;
if (!row.SerializeToString(&serializedRow)) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error serialize proto message for row. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error serialize proto message for row. Please contact internal support";
}
itemsAsList.AddListItem()
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 b5ff5f1f33..4b56cf06a3 100644
--- a/ydb/core/yq/libs/control_plane_storage/internal/utils.h
+++ b/ydb/core/yq/libs/control_plane_storage/internal/utils.h
@@ -8,6 +8,7 @@
#include <ydb/core/yq/libs/config/protos/issue_id.pb.h>
#include <ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h>
+#include <ydb/core/yq/libs/exceptions/exceptions.h>
namespace NYq {
diff --git a/ydb/core/yq/libs/control_plane_storage/request_actor.h b/ydb/core/yq/libs/control_plane_storage/request_actor.h
index 2ea87440f5..83f00e4fd8 100644
--- a/ydb/core/yq/libs/control_plane_storage/request_actor.h
+++ b/ydb/core/yq/libs/control_plane_storage/request_actor.h
@@ -125,7 +125,7 @@ protected:
issues.AddIssues(status.GetIssues());
internalIssues.AddIssues(status.GetIssues());
}
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
NYql::TIssue issue = MakeErrorIssue(exception.Code, exception.GetRawMessage());
issues.AddIssue(issue);
NYql::TIssue internalIssue = MakeErrorIssue(exception.Code, CurrentExceptionMessage());
diff --git a/ydb/core/yq/libs/control_plane_storage/validators.cpp b/ydb/core/yq/libs/control_plane_storage/validators.cpp
index aab2c37582..1b731031f2 100644
--- a/ydb/core/yq/libs/control_plane_storage/validators.cpp
+++ b/ydb/core/yq/libs/control_plane_storage/validators.cpp
@@ -33,17 +33,17 @@ TValidationQuery CreateUniqueNameValidator(const TString& tableName,
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";
+ ythrow TCodeLineException(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) << "Not valid number of lines, one is expected. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
}
ui64 countNames = parser.ColumnParser("count").GetUint64();
if (countNames != 0) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << error;
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << error;
}
return false;
@@ -81,13 +81,13 @@ TValidationQuery CreateModifyUniqueNameValidator(const TString& tableName,
auto validator = [error, visibility, name](NYdb::NTable::TDataQueryResult result) {
const auto& resultSets = result.GetResultSets();
if (resultSets.size() != 2) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets.size() << ". Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets.size() << ". Please contact internal support";
}
{
TResultSetParser parser(resultSets.front());
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
}
YandexQuery::Acl::Visibility oldVisibility = static_cast<YandexQuery::Acl::Visibility>(parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64().GetOrElse(YandexQuery::Acl::VISIBILITY_UNSPECIFIED));
@@ -100,12 +100,12 @@ TValidationQuery CreateModifyUniqueNameValidator(const TString& tableName,
TResultSetParser parser(resultSets.back());
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
}
ui64 countNames = parser.ColumnParser("count").GetUint64();
if (countNames != 0) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << error;
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << error;
}
return false;
@@ -130,17 +130,17 @@ TValidationQuery CreateCountEntitiesValidator(const TString& scope,
auto validator = [error, limit](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";
+ ythrow TCodeLineException(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) << "Not valid number of lines, one is expected. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
}
ui64 countEntities = parser.ColumnParser("count").GetUint64();
if (countEntities >= limit) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << error;
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << error;
}
return false;
@@ -167,7 +167,7 @@ TValidationQuery CreateRevisionValidator(const TString& tableName,
auto validator = [error, previousRevision](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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets.size() << ". Please contact internal support";
}
TResultSetParser parser(resultSets.front());
@@ -177,7 +177,7 @@ TValidationQuery CreateRevisionValidator(const TString& tableName,
i64 revision = parser.ColumnParser(REVISION_COLUMN_NAME).GetOptionalInt64().GetOrElse(0);
if (revision != previousRevision) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << error;
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << error;
}
return false;
@@ -207,19 +207,19 @@ static TValidationQuery CreateAccessValidatorImpl(const TString& tableName,
auto validator = [error, user, permissions, privatePermission, publicPermission](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";
+ ythrow TCodeLineException(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) << error;
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << error;
}
TString queryUser = parser.ColumnParser(USER_COLUMN_NAME).GetOptionalString().GetOrElse("");
YandexQuery::Acl::Visibility visibility = static_cast<YandexQuery::Acl::Visibility>(parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64().GetOrElse(YandexQuery::Acl::VISIBILITY_UNSPECIFIED));
bool hasAccess = HasAccessImpl(permissions, visibility, queryUser, user, privatePermission, publicPermission);
if (!hasAccess) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << error;
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << error;
}
return false;
@@ -271,17 +271,17 @@ TValidationQuery CreateRelatedBindingsValidator(const TString& scope,
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";
+ ythrow TCodeLineException(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) << "Not valid number of lines, one is expected. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Not valid number of lines, one is expected. Please contact internal support";
}
ui64 countEntities = parser.ColumnParser("count").GetUint64();
if (countEntities != 0) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << error;
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << error;
}
return false;
@@ -308,23 +308,23 @@ TValidationQuery CreateConnectionExistsValidator(const TString& scope,
auto validator = [error, user, permissions, bindingVisibility](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";
+ ythrow TCodeLineException(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) << error;
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << error;
}
YandexQuery::Acl::Visibility connectionVisibility = static_cast<YandexQuery::Acl::Visibility>(parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64().GetOrElse(YandexQuery::Acl::VISIBILITY_UNSPECIFIED));
TString connectionUser = parser.ColumnParser(USER_COLUMN_NAME).GetOptionalString().GetOrElse("");
if (bindingVisibility == YandexQuery::Acl::SCOPE && connectionVisibility == YandexQuery::Acl::PRIVATE) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Binding with SCOPE visibility cannot refer to connection with PRIVATE visibility";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Binding with SCOPE visibility cannot refer to connection with PRIVATE visibility";
}
if (!HasManageAccess(permissions, connectionVisibility, connectionUser, user)) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << error;
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << error;
}
return false;
@@ -352,7 +352,7 @@ TValidationQuery CreateConnectionOverrideBindingValidator(const TString& scope,
auto validator = [connectionName, user, permissions](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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets.size() << ". Please contact internal support";
}
TResultSetParser parser(resultSets.front());
@@ -365,7 +365,7 @@ TValidationQuery CreateConnectionOverrideBindingValidator(const TString& scope,
YandexQuery::Acl::Visibility bindingVisibility = static_cast<YandexQuery::Acl::Visibility>(parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64().GetOrElse(YandexQuery::Acl::VISIBILITY_UNSPECIFIED));
if (HasViewAccess(permissions, bindingVisibility, bindingUser, user)) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Connection named " << connectionName << " overrides connection from binding " << bindingName << ". Please rename this connection";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Connection named " << connectionName << " overrides connection from binding " << bindingName << ". Please rename this connection";
}
return false;
@@ -393,7 +393,7 @@ TValidationQuery CreateBindingConnectionValidator(const TString& scope,
auto validator = [connectionId](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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets.size() << ". Please contact internal support";
}
TResultSetParser parser(resultSets.front());
@@ -404,7 +404,7 @@ TValidationQuery CreateBindingConnectionValidator(const TString& scope,
TString privateConnectionName = parser.ColumnParser(NAME_COLUMN_NAME).GetOptionalString().GetOrElse("");
TString privateConnectionId = parser.ColumnParser(CONNECTION_ID_COLUMN_NAME).GetOptionalString().GetOrElse("");
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "The connection with id " << connectionId << " is overridden by the private conection with id " << privateConnectionId << " (" << privateConnectionName << "). Please rename the private connection or use another connection";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "The connection with id " << connectionId << " is overridden by the private conection with id " << privateConnectionId << " (" << privateConnectionName << "). Please rename the private connection or use another connection";
};
const auto query = queryBuilder.Build();
return {query.Sql, query.Params, validator};
@@ -428,12 +428,12 @@ TValidationQuery CreateTtlValidator(const TString& tableName,
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";
+ ythrow TCodeLineException(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;
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << error;
}
return false;
@@ -459,22 +459,22 @@ TValidationQuery CreateQueryComputeStatusValidator(const std::vector<YandexQuery
auto validator = [error, computeStatuses](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";
+ ythrow TCodeLineException(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::BAD_REQUEST) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
YandexQuery::Query query;
if (!query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
}
const YandexQuery::QueryMeta::ComputeStatus status = query.meta().status();
if (!IsIn(computeStatuses, status)) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << error;
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << error;
}
return false;
diff --git a/ydb/core/yq/libs/control_plane_storage/validators.h b/ydb/core/yq/libs/control_plane_storage/validators.h
index cc0d3dfc51..a61b882138 100644
--- a/ydb/core/yq/libs/control_plane_storage/validators.h
+++ b/ydb/core/yq/libs/control_plane_storage/validators.h
@@ -1,6 +1,5 @@
#pragma once
-#include "exceptions.h"
#include "schema.h"
#include <functional>
@@ -16,6 +15,7 @@
#include <ydb/core/yq/libs/control_plane_storage/events/events.h>
#include <ydb/core/yq/libs/db_schema/db_schema.h>
+#include <ydb/core/yq/libs/exceptions/exceptions.h>
namespace NYq {
@@ -128,7 +128,7 @@ TValidationQuery CreateIdempotencyKeyValidator(const TString& scope,
auto validator = [response](NYdb::NTable::TDataQueryResult result) {
const auto& resultSets = result.GetResultSets();
if (resultSets.size() != 1) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "internal error, result set size is not equal to 1 but equal " << resultSets.size();
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "internal error, result set size is not equal to 1 but equal " << resultSets.size();
}
NYdb::TResultSetParser parser(resultSets.back());
@@ -137,7 +137,7 @@ TValidationQuery CreateIdempotencyKeyValidator(const TString& scope,
}
if (!response->first.ParseFromString(*parser.ColumnParser(RESPONSE_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for response. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for response. Please contact internal support";
}
return true;
@@ -162,7 +162,7 @@ TValidationQuery CreateIdempotencyKeyValidator(const TString& scope,
auto validator = [response](NYdb::NTable::TDataQueryResult result) {
const auto& resultSets = result.GetResultSets();
if (resultSets.size() != 1) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "internal error, result set size is not equal to 1 but equal " << resultSets.size();
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "internal error, result set size is not equal to 1 but equal " << resultSets.size();
}
NYdb::TResultSetParser parser(resultSets.back());
@@ -171,7 +171,7 @@ TValidationQuery CreateIdempotencyKeyValidator(const TString& scope,
}
if (!response->first.ParseFromString(*parser.ColumnParser(RESPONSE_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for response. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for response. Please contact internal support";
}
response->second.IdempotencyResult = true;
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 cbd7fc62ac..6bc04c7a93 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
@@ -3,6 +3,7 @@
#include "ydb_control_plane_storage_impl.h"
#include <ydb/core/yq/libs/ydb/schema.h>
+#include <ydb/core/yq/libs/shared_resources/db_pool.h>
#include <ydb/library/security/ydb_credentials_provider_factory.h>
@@ -337,50 +338,6 @@ void ReadIdempotencyKeyQuery(TSqlQueryBuilder& builder, const TString& scope, co
}
}
-class TDbRequest: public NActors::TActorBootstrapped<TDbRequest> {
- using TFunction = std::function<NYdb::TAsyncStatus(NYdb::NTable::TSession&)>;
- TDbPool::TPtr DbPool;
- TPromise<NYdb::TStatus> Promise;
- TFunction Handler;
-
-public:
- TDbRequest(const TDbPool::TPtr& dbPool, const TPromise<NYdb::TStatus>& promise, const TFunction& handler)
- : DbPool(dbPool)
- , Promise(promise)
- , Handler(handler)
- {}
-
- static constexpr char ActorName[] = "YQ_CONTROL_PLANE_STORAGE_DB_REQUEST";
-
- void Bootstrap() {
- CPS_LOG_T("DbRequest actor request. Actor id: " << SelfId());
- Become(&TDbRequest::StateFunc);
- Send(DbPool->GetNextActor(), new TEvents::TEvDbFunctionRequest(Handler), IEventHandle::FlagTrackDelivery);
- }
-
- STRICT_STFUNC(StateFunc,
- hFunc(TEvents::TEvDbFunctionResponse, Handle);
- hFunc(NActors::TEvents::TEvUndelivered, OnUndelivered)
- )
-
- void Handle(TEvents::TEvDbFunctionResponse::TPtr& ev) {
- CPS_LOG_T("DbRequest actor response. Actor id: " << SelfId());
- Promise.SetValue(ev->Get()->Status);
- PassAway();
- }
-
- void OnUndelivered(NActors::TEvents::TEvUndelivered::TPtr&) {
- CPS_LOG_E("On delivered. Actor id: " << SelfId());
- Send(DbPool->GetNextActor(), new TEvents::TEvDbFunctionRequest(Handler), IEventHandle::FlagTrackDelivery);
- }
-};
-
-TAsyncStatus ExecDbRequest(TDbPool::TPtr dbPool, std::function<NYdb::TAsyncStatus(NYdb::NTable::TSession&)> handler) {
- TPromise<NYdb::TStatus> promise = NewPromise<NYdb::TStatus>();
- TActivationContext::Register(new TDbRequest(dbPool, promise, handler));
- return promise.GetFuture();
-}
-
std::pair<TAsyncStatus, std::shared_ptr<TVector<NYdb::TResultSet>>> TDbRequester::Read(
const TString& query,
const NYdb::TParams& params,
@@ -505,7 +462,7 @@ TAsyncStatus TDbRequester::Write(
return future;
}
return writeHandler(session);
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
CPS_LOG_AS_D(*actorSystem, "Validation: " << CurrentExceptionMessage());
return MakeFuture(TStatus{EStatus::GENERIC_ERROR, NYql::TIssues{MakeErrorIssue(exception.Code, exception.GetRawMessage())}});
} catch (const std::exception& exception) {
@@ -612,7 +569,7 @@ TAsyncStatus TDbRequester::ReadModifyWrite(
}
return status;
});
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
CPS_LOG_AS_D(*actorSystem, "Validation: " << CurrentExceptionMessage());
return MakeFuture(TStatus{EStatus::GENERIC_ERROR, NYql::TIssues{MakeErrorIssue(exception.Code, exception.GetRawMessage())}});
} catch (const std::exception& exception) {
@@ -642,7 +599,7 @@ TAsyncStatus TDbRequester::ReadModifyWrite(
return future;
}
return readModifyWriteHandler(session);
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
CPS_LOG_AS_D(*actorSystem, "Validation: " << CurrentExceptionMessage());
return MakeFuture(TStatus{EStatus::GENERIC_ERROR, NYql::TIssues{MakeErrorIssue(exception.Code, exception.GetRawMessage())}});
} catch (const std::exception& exception) {
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 dc8322cfff..ffe1064b8b 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
@@ -236,7 +236,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListBinding
auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo);
auto prepare = [resultSets=resultSets, limit] {
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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support";
}
YandexQuery::ListBindingsResult result;
@@ -244,7 +244,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListBinding
while (parser.TryNextRow()) {
YandexQuery::Binding binding;
if (!binding.ParseFromString(*parser.ColumnParser(BINDING_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for binding. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for binding. Please contact internal support";
}
YandexQuery::BriefBinding& briefBinding = *result.add_binding();
briefBinding.set_name(binding.content().name());
@@ -340,22 +340,22 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeBin
auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo);
auto prepare = [=, 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";
+ ythrow TCodeLineException(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) << "Binding does not exist or permission denied. Please check the id binding or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the id binding or your access rights";
}
YandexQuery::DescribeBindingResult result;
if (!result.mutable_binding()->ParseFromString(*parser.ColumnParser(BINDING_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for binding. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for binding. Please contact internal support";
}
bool hasViewAccess = HasViewAccess(permissions, result.binding().content().acl().visibility(), result.binding().meta().created_by(), user);
if (!hasViewAccess) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the id binding or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the id binding or your access rights";
}
return result;
};
@@ -432,18 +432,18 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyBindi
std::shared_ptr<std::pair<YandexQuery::ModifyBindingResult, TAuditDetails<YandexQuery::Binding>>> response = std::make_shared<std::pair<YandexQuery::ModifyBindingResult, TAuditDetails<YandexQuery::Binding>>>();
auto prepareParams = [=, config=Config](const TVector<TResultSet>& resultSets) {
if (resultSets.size() != 2) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets.size() << ". Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets.size() << ". Please contact internal support";
}
YandexQuery::Binding binding;
{
TResultSetParser parser(resultSets.front());
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the binding id or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the binding id or your access rights";
}
if (!binding.ParseFromString(*parser.ColumnParser(BINDING_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for binding. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for binding. Please contact internal support";
}
}
@@ -451,7 +451,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyBindi
{
TResultSetParser parser(resultSets.back());
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the connectin id or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the connectin id or your access rights";
}
connectionVisibility = static_cast<YandexQuery::Acl::Visibility>(parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64().GetOrElse(YandexQuery::Acl::VISIBILITY_UNSPECIFIED));
@@ -459,12 +459,12 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyBindi
const YandexQuery::Acl::Visibility requestBindingVisibility = request.content().acl().visibility();
if (requestBindingVisibility == YandexQuery::Acl::SCOPE && connectionVisibility == YandexQuery::Acl::PRIVATE) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Binding with SCOPE visibility cannot refer to connection with PRIVATE visibility";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Binding with SCOPE visibility cannot refer to connection with PRIVATE visibility";
}
bool hasManageAccess = HasManageAccess(permissions, binding.content().acl().visibility(), binding.meta().created_by(), user);
if (!hasManageAccess) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the id binding or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Binding does not exist or permission denied. Please check the id binding or your access rights";
}
auto& meta = *binding.mutable_meta();
@@ -477,15 +477,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyBindi
bool validateType = content.setting().binding_case() == request.content().setting().binding_case();
if (!validateType) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Binding type cannot be changed. Please specify the same binding type";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Binding type cannot be changed. Please specify the same binding type";
}
if (binding.content().acl().visibility() == YandexQuery::Acl::SCOPE && requestBindingVisibility == YandexQuery::Acl::PRIVATE) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Changing visibility from SCOPE to PRIVATE is forbidden. Please create a new binding with visibility PRIVATE";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Changing visibility from SCOPE to PRIVATE is forbidden. Please create a new binding with visibility PRIVATE";
}
if (content.connection_id() != request.content().connection_id()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Connection id cannot be changed. Please specify the same connection id";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Connection id cannot be changed. Please specify the same connection id";
}
content = request.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 5167f1b107..bb70983da2 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
@@ -231,7 +231,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListConnect
auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo);
auto prepare = [resultSets=resultSets, limit] {
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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support";
}
YandexQuery::ListConnectionsResult result;
@@ -239,7 +239,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListConnect
while (parser.TryNextRow()) {
auto& connection = *result.add_connection();
if (!connection.ParseFromString(*parser.ColumnParser(CONNECTION_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for connection. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for connection. Please contact internal support";
}
auto& setting = *connection.mutable_content()->mutable_setting();
if (setting.has_clickhouse_cluster()) {
@@ -325,22 +325,22 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeCon
auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo);
auto prepare = [=, 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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support";
}
YandexQuery::DescribeConnectionResult result;
TResultSetParser parser(resultSets->front());
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the id connection or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the id connection or your access rights";
}
if (!result.mutable_connection()->ParseFromString(*parser.ColumnParser(CONNECTION_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for connection. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for connection. Please contact internal support";
}
bool hasViewAccess = HasViewAccess(permissions, result.connection().content().acl().visibility(), result.connection().meta().created_by(), user);
if (!hasViewAccess) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the id connection or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the id connection or your access rights";
}
auto& setting = *result.mutable_connection()->mutable_content()->mutable_setting();
@@ -419,17 +419,17 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyConne
std::shared_ptr<std::pair<YandexQuery::ModifyConnectionResult, TAuditDetails<YandexQuery::Connection>>> response = std::make_shared<std::pair<YandexQuery::ModifyConnectionResult, TAuditDetails<YandexQuery::Connection>>>();
auto prepareParams = [=, config=Config](const TVector<TResultSet>& 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";
+ ythrow TCodeLineException(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) << "Connection does not exist or permission denied. Please check the id connection or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Connection does not exist or permission denied. Please check the id connection or your access rights";
}
YandexQuery::Connection connection;
if (!connection.ParseFromString(*parser.ColumnParser(CONNECTION_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for connection. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for connection. Please contact internal support";
}
auto& meta = *connection.mutable_meta();
@@ -442,11 +442,11 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyConne
bool validateType = content.setting().connection_case() == request.content().setting().connection_case();
if (!validateType) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Connection type cannot be changed. Please specify the same connection type";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Connection type cannot be changed. Please specify the same connection type";
}
if (content.acl().visibility() == YandexQuery::Acl::SCOPE && request.content().acl().visibility() == YandexQuery::Acl::PRIVATE) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Changing visibility from SCOPE to PRIVATE is forbidden. Please create a new connection with visibility PRIVATE";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Changing visibility from SCOPE to PRIVATE is forbidden. Please create a new connection with visibility PRIVATE";
}
TString clickHousePassword;
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 82b9e31269..72a3c97a29 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
@@ -3,7 +3,6 @@
#include "config.h"
#include "control_plane_storage.h"
#include "control_plane_storage_counters.h"
-#include "exceptions.h"
#include "extractors.h"
#include "probes.h"
#include "request_validators.h"
@@ -35,6 +34,7 @@
#include <ydb/core/yq/libs/control_plane_storage/proto/yq_internal.pb.h>
#include <ydb/core/yq/libs/db_schema/db_schema.h>
#include <ydb/core/yq/libs/events/events.h>
+#include <ydb/core/yq/libs/exceptions/exceptions.h>
#include <ydb/core/yq/libs/quota_manager/events/events.h>
#include <ydb/core/yq/libs/ydb/util.h>
#include <ydb/core/yq/libs/ydb/ydb.h>
@@ -91,8 +91,6 @@ inline static bool HasManageAccess(TPermissions permissions, YandexQuery::Acl::V
return HasAccessImpl(permissions, entityVisibility, entityUser, user, TPermissions::MANAGE_PRIVATE, TPermissions::MANAGE_PUBLIC);
}
-TAsyncStatus ExecDbRequest(TDbPool::TPtr dbPool, std::function<NYdb::TAsyncStatus(NYdb::NTable::TSession&)> handler);
-
LWTRACE_USING(YQ_CONTROL_PLANE_STORAGE_PROVIDER);
using TRequestScopeCountersPtr = TIntrusivePtr<TRequestScopeCounters>;
@@ -722,7 +720,7 @@ private:
issues.AddIssues(status.GetIssues());
internalIssues.AddIssues(status.GetIssues());
}
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
NYql::TIssue issue = MakeErrorIssue(exception.Code, exception.GetRawMessage());
issues.AddIssue(issue);
NYql::TIssue internalIssue = MakeErrorIssue(exception.Code, CurrentExceptionMessage());
@@ -798,7 +796,7 @@ private:
} else {
issues.AddIssues(status.GetIssues());
}
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
NYql::TIssue issue = MakeErrorIssue(exception.Code, exception.GetRawMessage());
issues.AddIssue(issue);
NYql::TIssue internalIssue = MakeErrorIssue(exception.Code, CurrentExceptionMessage());
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 7eb13879f9..e843b80575 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
@@ -181,14 +181,14 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery
auto prepareParams = [=](const TVector<TResultSet>& resultSets) mutable {
const size_t countSets = (idempotencyKey ? 1 : 0) + (request.execute_mode() != YandexQuery::SAVE ? 2 : 0);
if (resultSets.size() != countSets) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to " << countSets << " but equal " << resultSets.size() << ". Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to " << countSets << " but equal " << resultSets.size() << ". Please contact internal support";
}
if (idempotencyKey) {
TResultSetParser parser(resultSets.front());
if (parser.TryNextRow()) {
if (!response->first.ParseFromString(*parser.ColumnParser(RESPONSE_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for idempotency key request. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for idempotency key request. Please contact internal support";
}
response->second.IdempotencyResult = true;
return make_pair(TString{}, TParamsBuilder{}.Build());
@@ -247,18 +247,18 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvCreateQuery
*queryInternal.add_binding() = binding;
if (!connectionIds.contains(binding.content().connection_id())) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Unable to resolve connection for binding " << binding.meta().id() << ", name " << binding.content().name() << ", connection id " << binding.content().connection_id();
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Unable to resolve connection for binding " << binding.meta().id() << ", name " << binding.content().name() << ", connection id " << binding.content().connection_id();
}
}
}
}
if (query.ByteSizeLong() > Config->Proto.GetMaxRequestSize()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Incoming request exceeded the size limit: " << query.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please shorten your request";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Incoming request exceeded the size limit: " << query.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please shorten your request";
}
if (queryInternal.ByteSizeLong() > Config->Proto.GetMaxRequestSize()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "The size of all connections and bindings in the project exceeded the limit: " << queryInternal.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please reduce the number of connections and bindings";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "The size of all connections and bindings in the project exceeded the limit: " << queryInternal.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please reduce the number of connections and bindings";
}
response->second.After.ConstructInPlace().CopyFrom(query);
@@ -461,7 +461,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListQueries
auto [result, resultSets] = Read(read.Sql, read.Params, requestCounters, debugInfo);
auto prepare = [resultSets=resultSets, limit] {
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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support";
}
YandexQuery::ListQueriesResult result;
@@ -469,7 +469,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListQueries
while (parser.TryNextRow()) {
YandexQuery::Query query;
if (!query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
}
YandexQuery::BriefQuery briefQuery;
const auto lastJobId = query.meta().last_job_id();
@@ -551,17 +551,17 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeQue
auto [result, resultSets] = Read(query.Sql, query.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";
+ ythrow TCodeLineException(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 of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
YandexQuery::DescribeQueryResult result;
if (!result.mutable_query()->ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
}
const auto lastJobId = result.query().meta().last_job_id();
@@ -571,12 +571,12 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeQue
const auto queryUser = result.query().meta().common().created_by();
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 of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
YandexQuery::Internal::QueryInternal internal;
if (!internal.ParseFromString(*parser.ColumnParser(INTERNAL_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
}
// decompress plan
@@ -607,7 +607,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeQue
}
if (result.query().ByteSizeLong() > GRPC_MESSAGE_SIZE_LIMIT) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Resulting query of size " << result.query().ByteSizeLong() << " bytes is too big";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Resulting query of size " << result.query().ByteSizeLong() << " bytes is too big";
}
return result;
};
@@ -675,12 +675,12 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetQuerySta
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";
+ ythrow TCodeLineException(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 of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
YandexQuery::GetQueryStatusResult result;
@@ -691,7 +691,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetQuerySta
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 of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
return result;
@@ -798,23 +798,23 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery
const size_t countSets = 1 + (request.execute_mode() != YandexQuery::SAVE ? 2 : 0);
if (resultSets.size() != countSets) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to " << countSets << " but equal " << resultSets.size() << ". Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to " << countSets << " but equal " << resultSets.size() << ". Please contact internal support";
}
TResultSetParser parser(resultSets.back());
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
YandexQuery::Query query;
if (!query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
}
YandexQuery::Internal::QueryInternal internal;
if (!internal.ParseFromString(*parser.ColumnParser(INTERNAL_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
}
const TString resultId = request.execute_mode() == YandexQuery::SAVE ? parser.ColumnParser(RESULT_ID_COLUMN_NAME).GetOptionalString().GetOrElse("") : "";
@@ -823,15 +823,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery
const auto queryUser = query.meta().common().created_by();
const bool hasManageAccess = HasManageAccess(permissions, queryVisibility, queryUser, user);
if (!hasManageAccess) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
if (query.content().type() != request.content().type()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Query type cannot be changed. Please specify " << YandexQuery::QueryContent_QueryType_Name(query.content().type()) << " instead of " << YandexQuery::QueryContent_QueryType_Name(request.content().type());
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Query type cannot be changed. Please specify " << YandexQuery::QueryContent_QueryType_Name(query.content().type()) << " instead of " << YandexQuery::QueryContent_QueryType_Name(request.content().type());
}
if (query.content().acl().visibility() == YandexQuery::Acl::SCOPE && request.content().acl().visibility() == YandexQuery::Acl::PRIVATE) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Changing visibility from SCOPE to PRIVATE is forbidden. Please create a new query with visibility PRIVATE";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Changing visibility from SCOPE to PRIVATE is forbidden. Please create a new query with visibility PRIVATE";
}
auto oldVisibility = query.content().acl().visibility();
@@ -855,7 +855,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery
}, query.meta().status());
if (!isValidMode) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Conversion from status " << YandexQuery::QueryMeta::ComputeStatus_Name(query.meta().status()) << " to " << YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::STARTING) << " is not possible. Please wait for the query to complete or stop it";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Conversion from status " << YandexQuery::QueryMeta::ComputeStatus_Name(query.meta().status()) << " to " << YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::STARTING) << " is not possible. Please wait for the query to complete or stop it";
}
if (!Config->Proto.GetDisableCurrentIam()) {
@@ -910,18 +910,18 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvModifyQuery
*internal.add_binding() = binding;
if (!connectionIds.contains(binding.content().connection_id())) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Unable to resolve connection for binding " << binding.meta().id() << ", name " << binding.content().name() << ", connection id " << binding.content().connection_id();
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Unable to resolve connection for binding " << binding.meta().id() << ", name " << binding.content().name() << ", connection id " << binding.content().connection_id();
}
}
}
}
if (query.ByteSizeLong() > Config->Proto.GetMaxRequestSize()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Incoming request exceeded the size limit: " << query.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please shorten your request";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Incoming request exceeded the size limit: " << query.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please shorten your request";
}
if (internal.ByteSizeLong() > Config->Proto.GetMaxRequestSize()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "The size of all connections and bindings in the project exceeded the limit: " << internal.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please reduce the number of connections and bindings";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "The size of all connections and bindings in the project exceeded the limit: " << internal.ByteSizeLong() << " of " << Config->Proto.GetMaxRequestSize() << ". Please reduce the number of connections and bindings";
}
YandexQuery::Job job;
@@ -1271,7 +1271,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer
auto prepareParams = [=, config=Config](const TVector<TResultSet>& resultSets) {
if (resultSets.size() != 2) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets.size() << ". Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets.size() << ". Please contact internal support";
}
auto now = TInstant::Now();
@@ -1281,15 +1281,15 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer
{
TResultSetParser parser(resultSets[0]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
if (!query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
}
if (!queryInternal.ParseFromString(*parser.ColumnParser(INTERNAL_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query internal. Please contact internal support";
}
tenantName = *parser.ColumnParser(TENANT_COLUMN_NAME).GetOptionalString();
}
@@ -1299,18 +1299,18 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer
{
TResultSetParser parser(resultSets[1]);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Job does not exist or permission denied. Please check the id query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Job does not exist or permission denied. Please check the id query or your access rights";
}
if (!job.ParseFromString(parser.ColumnParser(JOB_COLUMN_NAME).GetOptionalString().GetOrElse(""))) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for job. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for job. Please contact internal support";
}
jobId = job.meta().id();
const bool hasManageAccess = HasManageAccess(permissions, query.content().acl().visibility(), query.meta().common().created_by(), user);
if (!hasManageAccess) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
}
@@ -1339,7 +1339,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer
metaQuery.set_status(YandexQuery::QueryMeta::ABORTING_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";
+ ythrow TCodeLineException(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";
}
}
@@ -1353,7 +1353,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer
metaQuery.set_status(YandexQuery::QueryMeta::PAUSING);
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";
+ ythrow TCodeLineException(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";
}
}
@@ -1362,7 +1362,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvControlQuer
if (isValidStatusForResume) {
metaQuery.set_status(YandexQuery::QueryMeta::RESUMING);
} else {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Conversion from status " << YandexQuery::QueryMeta::ComputeStatus_Name(metaQuery.status()) << " to " << YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::RESUMING) << " is not possible. Please wait for the previous operation to be completed";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Conversion from status " << YandexQuery::QueryMeta::ComputeStatus_Name(metaQuery.status()) << " to " << YandexQuery::QueryMeta::ComputeStatus_Name(YandexQuery::QueryMeta::RESUMING) << " is not possible. Please wait for the previous operation to be completed";
}
}
@@ -1508,7 +1508,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetResultDa
auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo);
auto prepare = [resultSets=resultSets, resultSetIndex, user, permissions] {
if (resultSets->size() != 2) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets->size() << ". Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 2 but equal " << resultSets->size() << ". Please contact internal support";
}
YandexQuery::GetResultDataResult result;
@@ -1517,12 +1517,12 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetResultDa
const auto& resultSet = (*resultSets)[0];
TResultSetParser parser(resultSet);
if (!parser.TryNextRow()) {
- ythrow TControlPlaneStorageException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
YandexQuery::Query query;
if (!query.ParseFromString(*parser.ColumnParser(QUERY_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for query. Please contact internal support";
}
YandexQuery::Acl::Visibility queryVisibility = static_cast<YandexQuery::Acl::Visibility>(parser.ColumnParser(VISIBILITY_COLUMN_NAME).GetOptionalInt64().GetOrElse(YandexQuery::Acl::VISIBILITY_UNSPECIFIED));
@@ -1530,24 +1530,24 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetResultDa
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 of the query or your access rights";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Query does not exist or permission denied. Please check the id of the query or your access rights";
}
if (resultSetIndex >= query.result_set_meta_size()) {
- ythrow TControlPlaneStorageException(TIssuesIds::BAD_REQUEST) << "Result set index out of bound: " << resultSetIndex << " >= " << query.result_set_meta_size();
+ ythrow TCodeLineException(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";
+ ythrow TCodeLineException(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";
+ ythrow TCodeLineException(TIssuesIds::BAD_REQUEST) << "Result doesn't exist";
}
if (*resultSetsExpireAtParser < TInstant::Now()) {
- ythrow TControlPlaneStorageException(TIssuesIds::EXPIRED) << "Result removed by TTL";
+ ythrow TCodeLineException(TIssuesIds::EXPIRED) << "Result removed by TTL";
}
resultSetProto.mutable_columns()->CopyFrom(query.result_set_meta(resultSetIndex).column());
@@ -1558,7 +1558,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvGetResultDa
TResultSetParser parser(resultSet);
while (parser.TryNextRow()) {
if (!resultSetProto.add_rows()->ParseFromString(*parser.ColumnParser(RESULT_SET_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for row. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for row. Please contact internal support";
}
}
}
@@ -1666,7 +1666,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListJobsReq
auto [result, resultSets] = Read(query.Sql, query.Params, requestCounters, debugInfo);
auto prepare = [resultSets=resultSets, limit] {
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";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Result set size is not equal to 1 but equal " << resultSets->size() << ". Please contact internal support";
}
YandexQuery::ListJobsResult result;
@@ -1674,7 +1674,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvListJobsReq
while (parser.TryNextRow()) {
YandexQuery::Job job;
if (!job.ParseFromString(*parser.ColumnParser(JOB_COLUMN_NAME).GetOptionalString())) {
- ythrow TControlPlaneStorageException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for job. Please contact internal support";
+ ythrow TCodeLineException(TIssuesIds::INTERNAL_ERROR) << "Error parsing proto message for job. Please contact internal support";
}
const TString mergedId = job.meta().id() + "-" + job.query_meta().common().id();
job.mutable_meta()->set_id(mergedId);
@@ -1767,23 +1767,23 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvDescribeJob
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";
+ ythrow TCodeLineException(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";
+ ythrow TCodeLineException(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";
+ ythrow TCodeLineException(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";
+ ythrow TCodeLineException(TIssuesIds::ACCESS_DENIED) << "Job does not exist or permission denied. Please check the job id or your access rights";
}
return result;
};
diff --git a/ydb/core/yq/libs/exceptions/CMakeLists.darwin.txt b/ydb/core/yq/libs/exceptions/CMakeLists.darwin.txt
new file mode 100644
index 0000000000..d3e0c08314
--- /dev/null
+++ b/ydb/core/yq/libs/exceptions/CMakeLists.darwin.txt
@@ -0,0 +1,18 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(yq-libs-exceptions)
+target_link_libraries(yq-libs-exceptions PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ libs-config-protos
+)
+target_sources(yq-libs-exceptions PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/exceptions/exceptions.cpp
+)
diff --git a/ydb/core/yq/libs/exceptions/CMakeLists.linux-aarch64.txt b/ydb/core/yq/libs/exceptions/CMakeLists.linux-aarch64.txt
new file mode 100644
index 0000000000..ad785f3b1a
--- /dev/null
+++ b/ydb/core/yq/libs/exceptions/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(yq-libs-exceptions)
+target_link_libraries(yq-libs-exceptions PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ libs-config-protos
+)
+target_sources(yq-libs-exceptions PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/exceptions/exceptions.cpp
+)
diff --git a/ydb/core/yq/libs/exceptions/CMakeLists.linux.txt b/ydb/core/yq/libs/exceptions/CMakeLists.linux.txt
new file mode 100644
index 0000000000..ad785f3b1a
--- /dev/null
+++ b/ydb/core/yq/libs/exceptions/CMakeLists.linux.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(yq-libs-exceptions)
+target_link_libraries(yq-libs-exceptions PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ libs-config-protos
+)
+target_sources(yq-libs-exceptions PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/exceptions/exceptions.cpp
+)
diff --git a/ydb/core/yq/libs/exceptions/CMakeLists.txt b/ydb/core/yq/libs/exceptions/CMakeLists.txt
new file mode 100644
index 0000000000..bede1861df
--- /dev/null
+++ b/ydb/core/yq/libs/exceptions/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND UNIX AND NOT APPLE AND NOT ANDROID)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (APPLE)
+ include(CMakeLists.darwin.txt)
+elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND UNIX AND NOT APPLE AND NOT ANDROID)
+ include(CMakeLists.linux.txt)
+endif()
diff --git a/ydb/core/yq/libs/exceptions/exceptions.cpp b/ydb/core/yq/libs/exceptions/exceptions.cpp
new file mode 100644
index 0000000000..9a39c9ddf5
--- /dev/null
+++ b/ydb/core/yq/libs/exceptions/exceptions.cpp
@@ -0,0 +1,37 @@
+#include "exceptions.h"
+
+#include <util/string/builder.h>
+
+namespace NYq {
+
+TCodeLineException::TCodeLineException(TIssuesIds::EIssueCode code)
+ : SourceLocation("", 0)
+ , Code(code)
+{}
+
+TCodeLineException::TCodeLineException(const TSourceLocation& sl, const TCodeLineException& t)
+ : yexception(t)
+ , SourceLocation(sl)
+ , Code(t.Code)
+{}
+
+const char* TCodeLineException::GetRawMessage() const {
+ return yexception::what();
+}
+
+const char* TCodeLineException::what() const noexcept {
+ try {
+ if (!Message) {
+ Message = TStringBuilder{} << SourceLocation << TStringBuf(": ") << yexception::what();
+ }
+ return Message.c_str();
+ } catch(...) {
+ return "Unexpected exception in TCodeLineException::what()";
+ }
+}
+
+TCodeLineException operator+(const TSourceLocation& sl, TCodeLineException&& t) {
+ return TCodeLineException(sl, t);
+}
+
+} // namespace NYq \ No newline at end of file
diff --git a/ydb/core/yq/libs/exceptions/exceptions.h b/ydb/core/yq/libs/exceptions/exceptions.h
new file mode 100644
index 0000000000..7c5ba4fa83
--- /dev/null
+++ b/ydb/core/yq/libs/exceptions/exceptions.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <util/generic/yexception.h>
+#include <ydb/core/yq/libs/config/protos/issue_id.pb.h>
+
+namespace NYq {
+
+// This exception can separate code line and file name from the error message
+struct TCodeLineException: public yexception {
+
+ TSourceLocation SourceLocation;
+ mutable TString Message;
+ TIssuesIds::EIssueCode Code;
+
+ TCodeLineException(TIssuesIds::EIssueCode code);
+
+ TCodeLineException(const TSourceLocation& sl, const TCodeLineException& t);
+
+ virtual const char* what() const noexcept override;
+
+ const char* GetRawMessage() const;
+
+};
+
+TCodeLineException operator+(const TSourceLocation& sl, TCodeLineException&& t);
+
+} // namespace NYq \ No newline at end of file
diff --git a/ydb/core/yq/libs/quota_manager/quota_manager.cpp b/ydb/core/yq/libs/quota_manager/quota_manager.cpp
index ead18d9624..7f6f589863 100644
--- a/ydb/core/yq/libs/quota_manager/quota_manager.cpp
+++ b/ydb/core/yq/libs/quota_manager/quota_manager.cpp
@@ -4,11 +4,15 @@
#include <library/cpp/actors/interconnect/interconnect_impl.h>
#include <library/cpp/actors/core/hfunc.h>
#include <library/cpp/actors/core/log.h>
+#include <library/cpp/protobuf/interop/cast.h>
#include <ydb/public/sdk/cpp/client/ydb_table/table.h>
+#include <ydb/core/yq/libs/control_plane_storage/schema.h>
#include <ydb/core/yq/libs/control_plane_storage/util.h>
#include <ydb/core/yq/libs/shared_resources/db_exec.h>
#include <ydb/core/yq/libs/shared_resources/shared_resources.h>
+#include <ydb/core/yq/libs/ydb/ydb.h>
+
#include <ydb/core/protos/services.pb.h>
@@ -180,12 +184,12 @@ public:
void Bootstrap() {
if (Monitoring) {
Monitoring->RegisterActorPage(Monitoring->RegisterIndexPage("fq_diag", "Federated Query diagnostics"),
- "quotas", "Quota Manager", false, TActivationContext::ActorSystem(), SelfId());
+ "quotas", "Quota Manager", false, NActors::TActivationContext::ActorSystem(), SelfId());
}
YdbConnection = NewYdbConnection(StorageConfig, CredProviderFactory, YqSharedResources->CoreYdbDriver);
DbPool = YqSharedResources->DbPoolHolder->GetOrCreate(EDbPoolId::MAIN, 10, YdbConnection->TablePathPrefix);
- Send(GetNameserviceActorId(), new NActors::TEvInterconnect::TEvListNodes());
+ Send(NActors::GetNameserviceActorId(), new NActors::TEvInterconnect::TEvListNodes());
Become(&TQuotaManagementService::StateFunc);
LOG_I("STARTED");
}
@@ -203,7 +207,7 @@ private:
hFunc(NActors::TEvInterconnect::TEvNodesInfo, Handle)
hFunc(TEvQuotaService::TEvQuotaUpdateNotification, Handle)
hFunc(NActors::TEvents::TEvUndelivered, Handle)
- hFunc(NMon::TEvHttpInfo, Handle)
+ hFunc(NActors::NMon::TEvHttpInfo, Handle)
);
void Handle(NActors::TEvents::TEvUndelivered::TPtr& ev) {
@@ -223,7 +227,7 @@ private:
if (oldPeerCount != NodeIds.size()) {
LOG_D("IC Peers[" << NodeIds.size() << "]: " << ToString(NodeIds));
}
- TActivationContext::Schedule(TDuration::Seconds(NodeIds.empty() ? 1 : 5), new IEventHandle(GetNameserviceActorId(), SelfId(), new NActors::TEvInterconnect::TEvListNodes()));
+ NActors::TActivationContext::Schedule(TDuration::Seconds(NodeIds.empty() ? 1 : 5), new IEventHandle(NActors::GetNameserviceActorId(), SelfId(), new NActors::TEvInterconnect::TEvListNodes()));
}
void Handle(TEvQuotaService::TQuotaGetRequest::TPtr& ev) {
@@ -712,7 +716,7 @@ private:
}
html << "</tbody></table>";
- Send(HttpMonId, new NMon::TEvHttpInfoRes(html.Str()));
+ Send(HttpMonId, new NActors::NMon::TEvHttpInfoRes(html.Str()));
HttpMonId = NActors::TActorId();
}
@@ -754,11 +758,11 @@ private:
}
html << "</tbody></table>";
- Send(HttpMonId, new NMon::TEvHttpInfoRes(html.Str()));
+ Send(HttpMonId, new NActors::NMon::TEvHttpInfoRes(html.Str()));
HttpMonId = NActors::TActorId();
}
- void Handle(NMon::TEvHttpInfo::TPtr& ev) {
+ void Handle(NActors::NMon::TEvHttpInfo::TPtr& ev) {
const auto& params = ev->Get()->Request.GetParams();
@@ -824,7 +828,7 @@ private:
}
html << "</tbody></table>";
- Send(ev->Sender, new NMon::TEvHttpInfoRes(html.Str()));
+ Send(ev->Sender, new NActors::NMon::TEvHttpInfoRes(html.Str()));
}
NConfig::TQuotasManagerConfig Config;
diff --git a/ydb/core/yq/libs/shared_resources/CMakeLists.darwin.txt b/ydb/core/yq/libs/shared_resources/CMakeLists.darwin.txt
index 41976b3936..b2fbbe52e4 100644
--- a/ydb/core/yq/libs/shared_resources/CMakeLists.darwin.txt
+++ b/ydb/core/yq/libs/shared_resources/CMakeLists.darwin.txt
@@ -18,8 +18,12 @@ target_link_libraries(yq-libs-shared_resources PUBLIC
cpp-actors-core
cpp-monlib-dynamic_counters
ydb-core-protos
+ yq-libs-common
+ yq-libs-config
libs-control_plane_storage-proto
+ yq-libs-db_schema
yq-libs-events
+ yq-libs-exceptions
libs-quota_manager-events
libs-shared_resources-interface
ydb-library-logger
diff --git a/ydb/core/yq/libs/shared_resources/CMakeLists.linux-aarch64.txt b/ydb/core/yq/libs/shared_resources/CMakeLists.linux-aarch64.txt
index 16a28c1e87..191d8418b2 100644
--- a/ydb/core/yq/libs/shared_resources/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/yq/libs/shared_resources/CMakeLists.linux-aarch64.txt
@@ -19,8 +19,12 @@ target_link_libraries(yq-libs-shared_resources PUBLIC
cpp-actors-core
cpp-monlib-dynamic_counters
ydb-core-protos
+ yq-libs-common
+ yq-libs-config
libs-control_plane_storage-proto
+ yq-libs-db_schema
yq-libs-events
+ yq-libs-exceptions
libs-quota_manager-events
libs-shared_resources-interface
ydb-library-logger
diff --git a/ydb/core/yq/libs/shared_resources/CMakeLists.linux.txt b/ydb/core/yq/libs/shared_resources/CMakeLists.linux.txt
index 16a28c1e87..191d8418b2 100644
--- a/ydb/core/yq/libs/shared_resources/CMakeLists.linux.txt
+++ b/ydb/core/yq/libs/shared_resources/CMakeLists.linux.txt
@@ -19,8 +19,12 @@ target_link_libraries(yq-libs-shared_resources PUBLIC
cpp-actors-core
cpp-monlib-dynamic_counters
ydb-core-protos
+ yq-libs-common
+ yq-libs-config
libs-control_plane_storage-proto
+ yq-libs-db_schema
yq-libs-events
+ yq-libs-exceptions
libs-quota_manager-events
libs-shared_resources-interface
ydb-library-logger
diff --git a/ydb/core/yq/libs/shared_resources/db_exec.h b/ydb/core/yq/libs/shared_resources/db_exec.h
index 1add5e82b3..53caecc453 100644
--- a/ydb/core/yq/libs/shared_resources/db_exec.h
+++ b/ydb/core/yq/libs/shared_resources/db_exec.h
@@ -2,11 +2,17 @@
#include "db_pool.h"
-#include <ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h>
+#include <ydb/core/yq/libs/common/debug_info.h>
+#include <ydb/core/yq/libs/config/yq_issue.h>
+#include <ydb/core/yq/libs/exceptions/exceptions.h>
#include <ydb/core/yq/libs/db_schema/db_schema.h>
namespace NYq {
+using namespace NThreading;
+using namespace NYdb;
+using namespace NYdb::NTable;
+
class TDbExecutable {
public:
using TPtr = std::shared_ptr<TDbExecutable>;
@@ -192,7 +198,7 @@ public:
if (this->Steps[CurrentStepIndex].ResultCallback) {
try {
this->Steps[CurrentStepIndex].ResultCallback(*this, result.GetResultSets());
- } catch (const TControlPlaneStorageException& exception) {
+ } catch (const TCodeLineException& exception) {
NYql::TIssue issue = MakeErrorIssue(exception.Code, exception.GetRawMessage());
Issues.AddIssue(issue);
NYql::TIssue internalIssue = MakeErrorIssue(exception.Code, CurrentExceptionMessage());
@@ -248,7 +254,7 @@ public:
, TCallback handlerCallback
) {
Y_VERIFY(HandlerActorId == NActors::TActorId{}, "Handler must be empty");
- ActorSystem = TActivationContext::ActorSystem();
+ ActorSystem = NActors::TActivationContext::ActorSystem();
HandlerActorId = actorId;
HandlerCallback = handlerCallback;
}
diff --git a/ydb/core/yq/libs/shared_resources/db_pool.cpp b/ydb/core/yq/libs/shared_resources/db_pool.cpp
index 8204117bd2..2d6ded1a28 100644
--- a/ydb/core/yq/libs/shared_resources/db_pool.cpp
+++ b/ydb/core/yq/libs/shared_resources/db_pool.cpp
@@ -333,4 +333,33 @@ NYdb::TDriver& TDbPoolHolder::GetDriver() {
return Driver;
}
+TDbRequest::TDbRequest(const TDbPool::TPtr& dbPool, const NThreading::TPromise<NYdb::TStatus>& promise, const TFunction& handler)
+ : DbPool(dbPool)
+ , Promise(promise)
+ , Handler(handler)
+{}
+
+void TDbRequest::Bootstrap() {
+ LOG_T("DbRequest actor request. Actor id: " << SelfId());
+ Become(&TDbRequest::StateFunc);
+ Send(DbPool->GetNextActor(), new TEvents::TEvDbFunctionRequest(Handler), IEventHandle::FlagTrackDelivery);
+}
+
+void TDbRequest::Handle(TEvents::TEvDbFunctionResponse::TPtr& ev) {
+ LOG_T("DbRequest actor response. Actor id: " << SelfId());
+ Promise.SetValue(ev->Get()->Status);
+ PassAway();
+}
+
+void TDbRequest::OnUndelivered(NActors::TEvents::TEvUndelivered::TPtr&) {
+ LOG_E("On delivered. Actor id: " << SelfId());
+ Send(DbPool->GetNextActor(), new TEvents::TEvDbFunctionRequest(Handler), IEventHandle::FlagTrackDelivery);
+}
+
+NYdb::TAsyncStatus ExecDbRequest(TDbPool::TPtr dbPool, std::function<NYdb::TAsyncStatus(NYdb::NTable::TSession&)> handler) {
+ NThreading::TPromise<NYdb::TStatus> promise = NThreading::NewPromise<NYdb::TStatus>();
+ TActivationContext::Register(new TDbRequest(dbPool, promise, handler));
+ return promise.GetFuture();
+}
+
} /* namespace NYq */
diff --git a/ydb/core/yq/libs/shared_resources/db_pool.h b/ydb/core/yq/libs/shared_resources/db_pool.h
index b474530375..51bde518e2 100644
--- a/ydb/core/yq/libs/shared_resources/db_pool.h
+++ b/ydb/core/yq/libs/shared_resources/db_pool.h
@@ -7,6 +7,8 @@
#include <ydb/library/security/ydb_credentials_provider_factory.h>
#include <library/cpp/actors/core/actor.h>
+#include <library/cpp/actors/core/hfunc.h>
+#include <library/cpp/actors/core/actor_bootstrapped.h>
#include <library/cpp/monlib/dynamic_counters/counters.h>
#include <util/system/mutex.h>
@@ -84,4 +86,26 @@ public:
TDbPoolMap::TPtr Pools;
};
+NYdb::TAsyncStatus ExecDbRequest(TDbPool::TPtr dbPool, std::function<NYdb::TAsyncStatus(NYdb::NTable::TSession&)> handler);
+
+class TDbRequest: public NActors::TActorBootstrapped<TDbRequest> {
+ using TFunction = std::function<NYdb::TAsyncStatus(NYdb::NTable::TSession&)>;
+ TDbPool::TPtr DbPool;
+ NThreading::TPromise<NYdb::TStatus> Promise;
+ TFunction Handler;
+public:
+ TDbRequest(const TDbPool::TPtr& dbPool, const NThreading::TPromise<NYdb::TStatus>& promise, const TFunction& handler);
+
+ static constexpr char ActorName[] = "YQ_DB_REQUEST";
+
+ STRICT_STFUNC(StateFunc,
+ hFunc(TEvents::TEvDbFunctionResponse, Handle);
+ hFunc(NActors::TEvents::TEvUndelivered, OnUndelivered)
+ )
+
+ void Bootstrap();
+ void Handle(TEvents::TEvDbFunctionResponse::TPtr& ev);
+ void OnUndelivered(NActors::TEvents::TEvUndelivered::TPtr&);
+};
+
} /* NYq */