diff --git a/ydb/core/statistics/aggregator/tx_init.cpp b/ydb/core/statistics/aggregator/tx_init.cpp index 0281115f9f26..de0bc44a0bca 100644 --- a/ydb/core/statistics/aggregator/tx_init.cpp +++ b/ydb/core/statistics/aggregator/tx_init.cpp @@ -227,14 +227,19 @@ struct TStatisticsAggregator::TTxInit : public TTxBase { ui64 ownerId = rowset.GetValue(); ui64 localPathId = rowset.GetValue(); TString columnTags = rowset.GetValue(); - ui64 status = rowset.GetValue(); + TForceTraversalTable::EStatus status = (TForceTraversalTable::EStatus)rowset.GetValue(); + + if (status == TForceTraversalTable::EStatus::AnalyzeStarted) { + // Resent TEvAnalyzeTable to shards + status = TForceTraversalTable::EStatus::None; + } auto pathId = TPathId(ownerId, localPathId); TForceTraversalTable operationTable { .PathId = pathId, .ColumnTags = columnTags, - .Status = (TForceTraversalTable::EStatus)status, + .Status = status, }; auto forceTraversalOperation = Self->ForceTraversalOperation(operationId); if (!forceTraversalOperation) { @@ -270,7 +275,7 @@ struct TStatisticsAggregator::TTxInit : public TTxBase { Self->InitializeStatisticsTable(); - if (Self->TraversalPathId) { + if (Self->TraversalPathId && Self->TraversalStartKey) { Self->NavigateType = ENavigateType::Traversal; Self->NavigatePathId = Self->TraversalPathId; Self->Navigate(); diff --git a/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp b/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp index 5b90aa0362f8..16257cddcd8d 100644 --- a/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp +++ b/ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp @@ -117,6 +117,32 @@ Y_UNIT_TEST_SUITE(AnalyzeColumnshard) { UNIT_ASSERT(!response2); } + Y_UNIT_TEST(AnalyzeRebootSa) { + TTestEnv env(1, 1); + auto& runtime = *env.GetServer().GetRuntime(); + auto tableInfo = CreateDatabaseTables(env, 1, 1)[0]; + + auto sender = runtime.AllocateEdgeActor(); + + bool eventSeen = false; + auto observer = runtime.AddObserver([&](auto&) { + if (!eventSeen) { + RebootTablet(runtime, tableInfo.SaTabletId, sender); + eventSeen = true; + } + }); + + auto analyzeRequest1 = MakeAnalyzeRequest({tableInfo.PathId}); + runtime.SendToPipe(tableInfo.SaTabletId, sender, analyzeRequest1.release()); + + runtime.WaitFor("blocked 1st TEvAnalyzeTableResponse event", [&]{ return eventSeen; }); + + auto analyzeRequest2 = MakeAnalyzeRequest({tableInfo.PathId}); + runtime.SendToPipe(tableInfo.SaTabletId, sender, analyzeRequest2.release()); + + runtime.GrabEdgeEventRethrow(sender); + } + } } // NStat