Skip to content

Commit

Permalink
Statistics: test for SA reboot (#8012)
Browse files Browse the repository at this point in the history
  • Loading branch information
azevaykin authored Aug 20, 2024
1 parent d8fe9db commit 767ff64
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ydb/core/statistics/aggregator/tx_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,19 @@ struct TStatisticsAggregator::TTxInit : public TTxBase {
ui64 ownerId = rowset.GetValue<Schema::ForceTraversalTables::OwnerId>();
ui64 localPathId = rowset.GetValue<Schema::ForceTraversalTables::LocalPathId>();
TString columnTags = rowset.GetValue<Schema::ForceTraversalTables::ColumnTags>();
ui64 status = rowset.GetValue<Schema::ForceTraversalTables::Status>();
TForceTraversalTable::EStatus status = (TForceTraversalTable::EStatus)rowset.GetValue<Schema::ForceTraversalTables::Status>();

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) {
Expand Down Expand Up @@ -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();
Expand Down
26 changes: 26 additions & 0 deletions ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TEvStatistics::TEvAnalyzeTableResponse>([&](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<TEvStatistics::TEvAnalyzeResponse>(sender);
}

}

} // NStat
Expand Down

0 comments on commit 767ff64

Please sign in to comment.