Skip to content

Commit 767ff64

Browse files
authored
Statistics: test for SA reboot (#8012)
1 parent d8fe9db commit 767ff64

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

ydb/core/statistics/aggregator/tx_init.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,19 @@ struct TStatisticsAggregator::TTxInit : public TTxBase {
227227
ui64 ownerId = rowset.GetValue<Schema::ForceTraversalTables::OwnerId>();
228228
ui64 localPathId = rowset.GetValue<Schema::ForceTraversalTables::LocalPathId>();
229229
TString columnTags = rowset.GetValue<Schema::ForceTraversalTables::ColumnTags>();
230-
ui64 status = rowset.GetValue<Schema::ForceTraversalTables::Status>();
230+
TForceTraversalTable::EStatus status = (TForceTraversalTable::EStatus)rowset.GetValue<Schema::ForceTraversalTables::Status>();
231+
232+
if (status == TForceTraversalTable::EStatus::AnalyzeStarted) {
233+
// Resent TEvAnalyzeTable to shards
234+
status = TForceTraversalTable::EStatus::None;
235+
}
231236

232237
auto pathId = TPathId(ownerId, localPathId);
233238

234239
TForceTraversalTable operationTable {
235240
.PathId = pathId,
236241
.ColumnTags = columnTags,
237-
.Status = (TForceTraversalTable::EStatus)status,
242+
.Status = status,
238243
};
239244
auto forceTraversalOperation = Self->ForceTraversalOperation(operationId);
240245
if (!forceTraversalOperation) {
@@ -270,7 +275,7 @@ struct TStatisticsAggregator::TTxInit : public TTxBase {
270275

271276
Self->InitializeStatisticsTable();
272277

273-
if (Self->TraversalPathId) {
278+
if (Self->TraversalPathId && Self->TraversalStartKey) {
274279
Self->NavigateType = ENavigateType::Traversal;
275280
Self->NavigatePathId = Self->TraversalPathId;
276281
Self->Navigate();

ydb/core/statistics/aggregator/ut/ut_analyze_columnshard.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,32 @@ Y_UNIT_TEST_SUITE(AnalyzeColumnshard) {
117117
UNIT_ASSERT(!response2);
118118
}
119119

120+
Y_UNIT_TEST(AnalyzeRebootSa) {
121+
TTestEnv env(1, 1);
122+
auto& runtime = *env.GetServer().GetRuntime();
123+
auto tableInfo = CreateDatabaseTables(env, 1, 1)[0];
124+
125+
auto sender = runtime.AllocateEdgeActor();
126+
127+
bool eventSeen = false;
128+
auto observer = runtime.AddObserver<TEvStatistics::TEvAnalyzeTableResponse>([&](auto&) {
129+
if (!eventSeen) {
130+
RebootTablet(runtime, tableInfo.SaTabletId, sender);
131+
eventSeen = true;
132+
}
133+
});
134+
135+
auto analyzeRequest1 = MakeAnalyzeRequest({tableInfo.PathId});
136+
runtime.SendToPipe(tableInfo.SaTabletId, sender, analyzeRequest1.release());
137+
138+
runtime.WaitFor("blocked 1st TEvAnalyzeTableResponse event", [&]{ return eventSeen; });
139+
140+
auto analyzeRequest2 = MakeAnalyzeRequest({tableInfo.PathId});
141+
runtime.SendToPipe(tableInfo.SaTabletId, sender, analyzeRequest2.release());
142+
143+
runtime.GrabEdgeEventRethrow<TEvStatistics::TEvAnalyzeResponse>(sender);
144+
}
145+
120146
}
121147

122148
} // NStat

0 commit comments

Comments
 (0)