@@ -83,20 +83,6 @@ std::shared_ptr<arrow::RecordBatch> UpdateColumn(std::shared_ptr<arrow::RecordBa
8383 return arrow::RecordBatch::Make (schema, batch->num_rows (), columns);
8484}
8585
86- bool TriggerTTL (TTestBasicRuntime& runtime, TActorId& sender, NOlap::TSnapshot snap, const std::vector<ui64>& pathIds,
87- ui64 tsSeconds, const TString& ttlColumnName) {
88- TString txBody = TTestSchema::TtlTxBody (pathIds, ttlColumnName, tsSeconds);
89- auto event = std::make_unique<TEvColumnShard::TEvProposeTransaction>(
90- NKikimrTxColumnShard::TX_KIND_TTL, sender, snap.GetTxId (), txBody);
91-
92- ForwardToTablet (runtime, TTestTxConfig::TxTablet0, sender, event.release ());
93- auto ev = runtime.GrabEdgeEvent <TEvColumnShard::TEvProposeTransactionResult>(sender);
94- const auto & res = ev->Get ()->Record ;
95- UNIT_ASSERT_EQUAL (res.GetTxId (), snap.GetTxId ());
96- UNIT_ASSERT_EQUAL (res.GetTxKind (), NKikimrTxColumnShard::TX_KIND_TTL);
97- return (res.GetStatus () == NKikimrTxColumnShard::SUCCESS);
98- }
99-
10086bool TriggerMetadata (
10187 TTestBasicRuntime& runtime, TActorId& sender, NYDBTest::TControllers::TGuard<NOlap::TWaitCompactionController>& controller) {
10288 auto isDone = [initialCounter = controller->GetTieringMetadataActualizationCount ().Val (), &controller]() {
@@ -225,6 +211,8 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
225211 ui32 ttlSec = TAppData::TimeProvider->Now ().Seconds (); // disable internal tll
226212 if (internal) {
227213 ttlSec -= (ts[0 ] + ts[1 ]) / 2 ; // enable internal ttl between ts1 and ts2
214+ } else {
215+ ttlSec -= ts[0 ] + ttlIncSeconds;
228216 }
229217 if (spec.HasTiers ()) {
230218 spec.Tiers [0 ].EvictAfter = TDuration::Seconds (ttlSec);
@@ -242,6 +230,7 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
242230
243231 auto blobs = MakeData (ts, PORTION_ROWS, PORTION_ROWS / 2 , spec.TtlColumn , ydbSchema);
244232 UNIT_ASSERT_EQUAL (blobs.size (), 2 );
233+ auto lastTtlFinishedCount = csControllerGuard->GetTTLFinishedCounter ().Val ();
245234 for (auto & data : blobs) {
246235 std::vector<ui64> writeIds;
247236 UNIT_ASSERT (WriteData (runtime, sender, ++writeId, tableId, data, ydbSchema, true , &writeIds));
@@ -255,12 +244,8 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
255244 RebootTablet (runtime, TTestTxConfig::TxTablet0, sender);
256245 }
257246
258- if (internal) {
259- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {}, 0 , spec.TtlColumn );
260- } else {
261- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), { tableId }, ts[0 ] + ttlIncSeconds, spec.TtlColumn );
262- }
263- while (csControllerGuard->GetTTLFinishedCounter ().Val () != csControllerGuard->GetTTLStartedCounter ().Val ()) {
247+ ForwardToTablet (runtime, TTestTxConfig::TxTablet0, sender, new TEvPrivate::TEvPeriodicWakeup (true ));
248+ while (csControllerGuard->GetTTLFinishedCounter ().Val () == lastTtlFinishedCount) {
264249 runtime.SimulateSleep (TDuration::Seconds (1 )); // wait all finished before (ttl especially)
265250 }
266251
@@ -271,7 +256,6 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
271256 }
272257
273258 {
274- --planStep;
275259 TShardReader reader (runtime, TTestTxConfig::TxTablet0, tableId, NOlap::TSnapshot (planStep, Max<ui64>()));
276260 reader.SetReplyColumnIds (TTestSchema::GetColumnIds (TTestSchema::YdbSchema (), { spec.TtlColumn }));
277261 auto rb = reader.ReadAll ();
@@ -292,18 +276,13 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
292276 if (spec.HasTiers ()) {
293277 csControllerGuard->OverrideTierConfigs (runtime, sender, TTestSchema::BuildSnapshot (spec));
294278 }
295-
296- if (internal) {
297- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {}, 0 , spec.TtlColumn );
298- } else {
299- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {tableId}, ts[1 ] + ttlIncSeconds, spec.TtlColumn );
300- }
301- while (csControllerGuard->GetTTLFinishedCounter ().Val () != csControllerGuard->GetTTLStartedCounter ().Val ()) {
279+ lastTtlFinishedCount = csControllerGuard->GetTTLFinishedCounter ().Val ();
280+ ForwardToTablet (runtime, TTestTxConfig::TxTablet0, sender, new TEvPrivate::TEvPeriodicWakeup (true ));
281+ while (csControllerGuard->GetTTLFinishedCounter ().Val () == lastTtlFinishedCount) {
302282 runtime.SimulateSleep (TDuration::Seconds (1 )); // wait all finished before (ttl especially)
303283 }
304284
305285 {
306- --planStep;
307286 TShardReader reader (runtime, TTestTxConfig::TxTablet0, tableId, NOlap::TSnapshot (planStep, Max<ui64>()));
308287 auto columnIds = TTestSchema::GetColumnIds (TTestSchema::YdbSchema (), { spec.TtlColumn });
309288 columnIds.emplace_back ((ui32)NOlap::IIndexInfo::ESpecialColumn::PLAN_STEP);
@@ -314,6 +293,7 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
314293 }
315294
316295 // Disable TTL
296+ lastTtlFinishedCount = csControllerGuard->GetTTLFinishedCounter ().Val ();
317297 auto ok = ProposeSchemaTx (runtime, sender,
318298 TTestSchema::AlterTableTxBody (tableId, 3 , TTestSchema::TTableSpecials ()),
319299 NOlap::TSnapshot (++planStep, ++txId));
@@ -329,17 +309,9 @@ void TestTtl(bool reboots, bool internal, TTestSchema::TTableSpecials spec = {},
329309 ProposeCommit (runtime, sender, ++txId, writeIds);
330310 PlanCommit (runtime, sender, ++planStep, txId);
331311
332- if (internal) {
333- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {}, 0 , spec.TtlColumn );
334- } else {
335- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {tableId}, ts[0 ] - ttlIncSeconds, spec.TtlColumn );
336- }
337- while (csControllerGuard->GetTTLFinishedCounter ().Val () != csControllerGuard->GetTTLStartedCounter ().Val ()) {
338- runtime.SimulateSleep (TDuration::Seconds (1 )); // wait all finished before (ttl especially)
339- }
312+ ForwardToTablet (runtime, TTestTxConfig::TxTablet0, sender, new TEvPrivate::TEvPeriodicWakeup (true ));
340313
341314 {
342- --planStep;
343315 TShardReader reader (runtime, TTestTxConfig::TxTablet0, tableId, NOlap::TSnapshot (planStep, Max<ui64>()));
344316 reader.SetReplyColumnIds (TTestSchema::GetColumnIds (TTestSchema::YdbSchema (), { spec.TtlColumn }));
345317 auto rb = reader.ReadAll ();
@@ -660,7 +632,7 @@ std::vector<std::pair<ui32, ui64>> TestTiers(bool reboots, const std::vector<TSt
660632 reader->Ack ();
661633 }
662634 // Eviction
663- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {}, 0 , specs[i]. TtlColumn );
635+ ForwardToTablet (runtime, TTestTxConfig::TxTablet0, sender, new TEvPrivate::TEvPeriodicWakeup ( true ) );
664636
665637 Cerr << " -- " << (hasColdEviction ? " COLD" : " HOT" )
666638 << " TIERING(" << i << " ) num tiers: " << specs[i].Tiers .size () << Endl;
@@ -690,7 +662,7 @@ std::vector<std::pair<ui32, ui64>> TestTiers(bool reboots, const std::vector<TSt
690662 // Read data after eviction
691663 TString columnToRead = specs[i].TtlColumn ;
692664
693- TShardReader reader (runtime, TTestTxConfig::TxTablet0, tableId, NOlap::TSnapshot (planStep - 1 , Max<ui64>()));
665+ TShardReader reader (runtime, TTestTxConfig::TxTablet0, tableId, NOlap::TSnapshot (planStep, Max<ui64>()));
694666 reader.SetReplyColumnIds (TTestSchema::GetColumnIds (TTestSchema::YdbSchema (), { columnToRead }));
695667 auto rb = reader.ReadAll ();
696668 if (expectedReadResult == EExpectedResult::ERROR) {
@@ -1121,9 +1093,6 @@ void TestCompaction(std::optional<ui32> numWrites = {}) {
11211093 ProposeCommit (runtime, sender, txId, writeIds);
11221094 PlanCommit (runtime, sender, planStep, txId);
11231095
1124- if (i % 2 == 0 ) {
1125- TriggerTTL (runtime, sender, NOlap::TSnapshot (++planStep, ++txId), {}, 0 , spec.TtlColumn );
1126- }
11271096 }
11281097}
11291098
0 commit comments