From 1cf548dfba8926958cd76f1dee518536c80375a7 Mon Sep 17 00:00:00 2001 From: azevaykin <145343289+azevaykin@users.noreply.github.com> Date: Thu, 29 Aug 2024 05:36:50 +0300 Subject: [PATCH] Statistics: status for TEvAnalyzeResponse (#8404) --- ydb/core/protos/out/out.cpp | 4 ++++ ydb/core/protos/statistics.proto | 7 +++++++ ydb/core/statistics/aggregator/tx_analyze_deadline.cpp | 1 + ydb/core/statistics/aggregator/tx_finish_trasersal.cpp | 1 + .../statistics/aggregator/ut/ut_analyze_columnshard.cpp | 5 ++++- ydb/core/statistics/ut_common/ut_common.cpp | 4 +++- 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ydb/core/protos/out/out.cpp b/ydb/core/protos/out/out.cpp index f85c5b9c0256..72bb4d1e22ba 100644 --- a/ydb/core/protos/out/out.cpp +++ b/ydb/core/protos/out/out.cpp @@ -240,6 +240,10 @@ Y_DECLARE_OUT_SPEC(, NKikimrDataEvents::TEvWrite::ETxMode, stream, value) { stream << NKikimrDataEvents::TEvWrite::ETxMode_Name(value); } +Y_DECLARE_OUT_SPEC(, NKikimrStat::TEvAnalyzeResponse_EStatus, stream, value) { + stream << NKikimrStat::TEvAnalyzeResponse_EStatus_Name(value); +} + Y_DECLARE_OUT_SPEC(, NKikimrStat::TEvAnalyzeStatusResponse_EStatus, stream, value) { stream << NKikimrStat::TEvAnalyzeStatusResponse_EStatus_Name(value); } diff --git a/ydb/core/protos/statistics.proto b/ydb/core/protos/statistics.proto index 838bc9f64e38..5ecebcaa32c2 100644 --- a/ydb/core/protos/statistics.proto +++ b/ydb/core/protos/statistics.proto @@ -89,6 +89,13 @@ message TEvAnalyze { // SA -> KQP message TEvAnalyzeResponse { optional bytes OperationId = 1; + + enum EStatus { + STATUS_UNSPECIFIED = 0; + STATUS_SUCCESS = 1; + STATUS_ERROR = 2; + } + optional EStatus Status = 2; } // KQP -> SA diff --git a/ydb/core/statistics/aggregator/tx_analyze_deadline.cpp b/ydb/core/statistics/aggregator/tx_analyze_deadline.cpp index 67730beadb57..1143faca4390 100644 --- a/ydb/core/statistics/aggregator/tx_analyze_deadline.cpp +++ b/ydb/core/statistics/aggregator/tx_analyze_deadline.cpp @@ -46,6 +46,7 @@ struct TStatisticsAggregator::TTxAnalyzeDeadline : public TTxBase { "Send TEvAnalyzeResponse for deleted operation, OperationId=" << OperationId << ", ActorId=" << ReplyToActorId); auto response = std::make_unique(); response->Record.SetOperationId(OperationId); + response->Record.SetStatus(NKikimrStat::TEvAnalyzeResponse::STATUS_ERROR); ctx.Send(ReplyToActorId, response.release()); } else { SA_LOG_D("[" << Self->TabletID() << "] TTxAnalyzeDeadline::Complete. No ActorId to send reply. OperationId=" << OperationId); diff --git a/ydb/core/statistics/aggregator/tx_finish_trasersal.cpp b/ydb/core/statistics/aggregator/tx_finish_trasersal.cpp index a48dd94c2170..cb94e4eac7a8 100644 --- a/ydb/core/statistics/aggregator/tx_finish_trasersal.cpp +++ b/ydb/core/statistics/aggregator/tx_finish_trasersal.cpp @@ -50,6 +50,7 @@ struct TStatisticsAggregator::TTxFinishTraversal : public TTxBase { "Send TEvAnalyzeResponse, OperationId=" << OperationId << ", ActorId=" << ReplyToActorId); auto response = std::make_unique(); response->Record.SetOperationId(OperationId); + response->Record.SetStatus(NKikimrStat::TEvAnalyzeResponse::STATUS_SUCCESS); ctx.Send(ReplyToActorId, response.release()); } } diff --git a/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp b/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp index ac5fd563fdd8..2d914b383459 100644 --- a/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp +++ b/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp @@ -313,7 +313,10 @@ Y_UNIT_TEST_SUITE(AnalyzeColumnshard) { runtime.WaitFor("TEvAnalyzeTableResponse", [&]{ return block.size(); }); runtime.AdvanceCurrentTime(TDuration::Days(2)); - runtime.GrabEdgeEventRethrow(sender); + auto analyzeResponse = runtime.GrabEdgeEventRethrow(sender); + const auto& record = analyzeResponse->Get()->Record; + UNIT_ASSERT_VALUES_EQUAL(record.GetOperationId(), "operationId"); + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus(), NKikimrStat::TEvAnalyzeResponse::STATUS_ERROR); } } diff --git a/ydb/core/statistics/ut_common/ut_common.cpp b/ydb/core/statistics/ut_common/ut_common.cpp index c670a3f026c5..5d64386040d2 100644 --- a/ydb/core/statistics/ut_common/ut_common.cpp +++ b/ydb/core/statistics/ut_common/ut_common.cpp @@ -408,7 +408,9 @@ void Analyze(TTestActorRuntime& runtime, ui64 saTabletId, const std::vector(sender); - UNIT_ASSERT_VALUES_EQUAL(evResponse->Get()->Record.GetOperationId(), operationId); + const auto& record = evResponse->Get()->Record; + UNIT_ASSERT_VALUES_EQUAL(record.GetOperationId(), operationId); + UNIT_ASSERT_VALUES_EQUAL(record.GetStatus(), NKikimrStat::TEvAnalyzeResponse::STATUS_SUCCESS); } void AnalyzeTable(TTestActorRuntime& runtime, ui64 shardTabletId, const TAnalyzedTable& table) {