@@ -75,7 +75,7 @@ namespace {
75
75
}
76
76
77
77
Y_UNIT_TEST_SUITE (TestDataErasure) {
78
- void SimpleDataErasureTest (const TSchemeObject& createSchemeObject) {
78
+ void SimpleDataErasureTest (const TSchemeObject& createSchemeObject, ui64 currentBscGeneration = 0 ) {
79
79
TTestBasicRuntime runtime;
80
80
TTestEnv env (runtime);
81
81
@@ -93,6 +93,11 @@ Y_UNIT_TEST_SUITE(TestDataErasure) {
93
93
dataErasureConfig.SetBlobStorageControllerRequestIntervalSeconds (1 );
94
94
95
95
auto sender = runtime.AllocateEdgeActor ();
96
+ // Change BSC counter value between data erasure iterations
97
+ if (currentBscGeneration > 1 ) {
98
+ auto request = MakeHolder<TEvBlobStorage::TEvControllerShredRequest>(currentBscGeneration);
99
+ runtime.SendToPipe (MakeBSControllerID (), sender, request.Release (), 0 , GetPipeConfigWithRetries ());
100
+ }
96
101
RebootTablet (runtime, TTestTxConfig::SchemeShard, sender);
97
102
98
103
ui64 txId = 100 ;
@@ -101,7 +106,7 @@ Y_UNIT_TEST_SUITE(TestDataErasure) {
101
106
CreateTestExtSubdomain (runtime, env, &txId, " Database2" , createSchemeObject);
102
107
103
108
TDispatchOptions options;
104
- options.FinalEvents .push_back (TDispatchOptions::TFinalEventCondition (TEvBlobStorage::EvControllerShredResponse, 3 ));
109
+ options.FinalEvents .push_back (TDispatchOptions::TFinalEventCondition (TEvBlobStorage::EvControllerShredResponse, (currentBscGeneration > 1 ? 4 : 3 ) ));
105
110
runtime.DispatchEvents (options);
106
111
107
112
auto request = MakeHolder<TEvSchemeShard::TEvDataErasureInfoRequest>();
@@ -110,22 +115,30 @@ Y_UNIT_TEST_SUITE(TestDataErasure) {
110
115
TAutoPtr<IEventHandle> handle;
111
116
auto response = runtime.GrabEdgeEventRethrow <TEvSchemeShard::TEvDataErasureInfoResponse>(handle);
112
117
113
- UNIT_ASSERT_EQUAL_C (response->Record .GetGeneration (), 1 , response->Record .GetGeneration ());
118
+ if (currentBscGeneration > 1 ) {
119
+ UNIT_ASSERT_EQUAL_C (response->Record .GetGeneration (), currentBscGeneration + 1 , response->Record .GetGeneration ());
120
+ } else {
121
+ UNIT_ASSERT_EQUAL_C (response->Record .GetGeneration (), 1 , response->Record .GetGeneration ());
122
+ }
114
123
UNIT_ASSERT_EQUAL (response->Record .GetStatus (), NKikimrScheme::TEvDataErasureInfoResponse::COMPLETED);
115
124
}
116
125
117
- Y_UNIT_TEST (SimpleDataErasureTestForTables ) {
126
+ Y_UNIT_TEST (SimpleTestForTables ) {
118
127
SimpleDataErasureTest ({.Table = true , .Topic = false });
119
128
}
120
129
121
- Y_UNIT_TEST (SimpleDataErasureTestForTopic ) {
130
+ Y_UNIT_TEST (SimpleTestForTopic ) {
122
131
SimpleDataErasureTest ({.Table = false , .Topic = true });
123
132
}
124
133
125
- Y_UNIT_TEST (SimpleDataErasureTestForAllSupportedObjects ) {
134
+ Y_UNIT_TEST (SimpleTestForAllSupportedObjects ) {
126
135
SimpleDataErasureTest ({.Table = true , .Topic = true });
127
136
}
128
137
138
+ Y_UNIT_TEST (SchemeShardCounterDoesNotConsistWithBscCounter) {
139
+ SimpleDataErasureTest ({.Table = true , .Topic = false }, /* currentBscGeneration*/ 47 );
140
+ }
141
+
129
142
void DataErasureRun3Cycles (const TSchemeObject& createSchemeObject) {
130
143
TTestBasicRuntime runtime;
131
144
TTestEnv env (runtime);
@@ -165,15 +178,15 @@ Y_UNIT_TEST_SUITE(TestDataErasure) {
165
178
UNIT_ASSERT_EQUAL (response->Record .GetStatus (), NKikimrScheme::TEvDataErasureInfoResponse::COMPLETED);
166
179
}
167
180
168
- Y_UNIT_TEST (DataErasureRun3CyclesForTables ) {
181
+ Y_UNIT_TEST (Run3CyclesForTables ) {
169
182
DataErasureRun3Cycles ({.Table = true , .Topic = false });
170
183
}
171
184
172
- Y_UNIT_TEST (DataErasureRun3CyclesForTopics ) {
185
+ Y_UNIT_TEST (Run3CyclesForTopics ) {
173
186
DataErasureRun3Cycles ({.Table = false , .Topic = true });
174
187
}
175
188
176
- Y_UNIT_TEST (DataErasureRun3CyclesForAllSupportedObjects ) {
189
+ Y_UNIT_TEST (Run3CyclesForAllSupportedObjects ) {
177
190
DataErasureRun3Cycles ({.Table = true , .Topic = true });
178
191
}
179
192
@@ -221,7 +234,7 @@ Y_UNIT_TEST_SUITE(TestDataErasure) {
221
234
UNIT_ASSERT_EQUAL (response->Record .GetStatus (), NKikimrScheme::TEvDataErasureInfoResponse::COMPLETED);
222
235
}
223
236
224
- Y_UNIT_TEST (DataErasureManualLaunch3Cycles ) {
237
+ Y_UNIT_TEST (ManualLaunch3Cycles ) {
225
238
TTestBasicRuntime runtime;
226
239
TTestEnv env (runtime);
227
240
@@ -272,6 +285,67 @@ Y_UNIT_TEST_SUITE(TestDataErasure) {
272
285
RunDataErasure (3 );
273
286
}
274
287
288
+ Y_UNIT_TEST (ManualLaunch3CyclesWithNotConsistentCountersInSchemeShardAndBSC) {
289
+ TTestBasicRuntime runtime;
290
+ TTestEnv env (runtime);
291
+
292
+ runtime.SetLogPriority (NKikimrServices::TX_PROXY, NLog::PRI_DEBUG);
293
+ runtime.SetLogPriority (NKikimrServices::FLAT_TX_SCHEMESHARD, NActors::NLog::PRI_TRACE);
294
+
295
+ auto info = CreateTestTabletInfo (MakeBSControllerID (), TTabletTypes::BSController);
296
+ CreateTestBootstrapper (runtime, info, [](const TActorId &tablet, TTabletStorageInfo *info) -> IActor* {
297
+ return new TFakeBSController (tablet, info);
298
+ });
299
+
300
+ runtime.GetAppData ().FeatureFlags .SetEnableDataErasure (true );
301
+ auto & dataErasureConfig = runtime.GetAppData ().DataErasureConfig ;
302
+ dataErasureConfig.SetDataErasureIntervalSeconds (0 ); // do not schedule
303
+ dataErasureConfig.SetBlobStorageControllerRequestIntervalSeconds (1 );
304
+
305
+ auto sender = runtime.AllocateEdgeActor ();
306
+ RebootTablet (runtime, TTestTxConfig::SchemeShard, sender);
307
+
308
+ ui64 txId = 100 ;
309
+
310
+ CreateTestExtSubdomain (runtime, env, &txId, " Database1" );
311
+ CreateTestExtSubdomain (runtime, env, &txId, " Database2" );
312
+
313
+ auto RunDataErasure = [&runtime] (ui32 expectedGeneration, ui32 requiredCountShredResponses) {
314
+ auto sender = runtime.AllocateEdgeActor ();
315
+ {
316
+ auto request = MakeHolder<TEvSchemeShard::TEvDataErasureManualStartupRequest>();
317
+ runtime.SendToPipe (TTestTxConfig::SchemeShard, sender, request.Release (), 0 , GetPipeConfigWithRetries ());
318
+ }
319
+
320
+ TDispatchOptions options;
321
+ options.FinalEvents .push_back (TDispatchOptions::TFinalEventCondition (TEvBlobStorage::EvControllerShredResponse, requiredCountShredResponses));
322
+ runtime.DispatchEvents (options);
323
+
324
+ auto request = MakeHolder<TEvSchemeShard::TEvDataErasureInfoRequest>();
325
+ runtime.SendToPipe (TTestTxConfig::SchemeShard, sender, request.Release (), 0 , GetPipeConfigWithRetries ());
326
+
327
+ TAutoPtr<IEventHandle> handle;
328
+ auto response = runtime.GrabEdgeEventRethrow <TEvSchemeShard::TEvDataErasureInfoResponse>(handle);
329
+
330
+ UNIT_ASSERT_EQUAL_C (response->Record .GetGeneration (), expectedGeneration, response->Record .GetGeneration ());
331
+ UNIT_ASSERT_EQUAL (response->Record .GetStatus (), NKikimrScheme::TEvDataErasureInfoResponse::COMPLETED);
332
+ };
333
+
334
+ RunDataErasure (1 , 3 );
335
+ // Change BSC counter value between data erasure iterations
336
+ {
337
+ auto request = MakeHolder<TEvBlobStorage::TEvControllerShredRequest>(50 );
338
+ runtime.SendToPipe (MakeBSControllerID (), sender, request.Release (), 0 , GetPipeConfigWithRetries ());
339
+ }
340
+ RunDataErasure (51 , 4 );
341
+ // Change BSC counter value between data erasure iterations
342
+ {
343
+ auto request = MakeHolder<TEvBlobStorage::TEvControllerShredRequest>(100 );
344
+ runtime.SendToPipe (MakeBSControllerID (), sender, request.Release (), 0 , GetPipeConfigWithRetries ());
345
+ }
346
+ RunDataErasure (101 , 4 );
347
+ }
348
+
275
349
Y_UNIT_TEST (DataErasureWithCopyTable) {
276
350
TTestBasicRuntime runtime;
277
351
TVector<TIntrusivePtr<NFake::TProxyDS>> dsProxies {
0 commit comments