@@ -131,6 +131,63 @@ Y_UNIT_TEST_SUITE(KqpOlapWrite) {
131131 UNIT_ASSERT_VALUES_EQUAL (GetUint64 (rows[0 ].at (" count" )), 800000 );
132132 }
133133
134+ Y_UNIT_TEST (WriteDeleteCleanGC) {
135+ auto csController = NKikimr::NYDBTest::TControllers::RegisterCSControllerGuard<NKikimr::NYDBTest::NColumnShard::TController>();
136+ csController->SetPeriodicWakeupActivationPeriod (TDuration::MilliSeconds (100 ));
137+ csController->DisableBackground (NKikimr::NYDBTest::ICSController::EBackground::GC);
138+ Singleton<NKikimr::NWrappers::NExternalStorage::TFakeExternalStorage>()->ResetWriteCounters ();
139+
140+ NKikimrConfig::TAppConfig appConfig;
141+ appConfig.MutableTableServiceConfig ()->SetEnableOlapSink (true );
142+
143+ auto settings = TKikimrSettings ().SetAppConfig (appConfig).SetWithSampleTables (false );
144+ TKikimrRunner kikimr (settings);
145+ TLocalHelper (kikimr).CreateTestOlapTable ();
146+ Tests::NCommon::TLoggerInit (kikimr).SetComponents ({ NKikimrServices::TX_COLUMNSHARD, NKikimrServices::TX_COLUMNSHARD_BLOBS }, " CS" ).SetPriority (NActors::NLog::PRI_DEBUG).Initialize ();
147+ auto tableClient = kikimr.GetTableClient ();
148+
149+ auto client = kikimr.GetQueryClient ();
150+
151+ {
152+ auto it = client.ExecuteQuery (R"(
153+ INSERT INTO `/Root/olapStore/olapTable` (timestamp, uid, resource_id) VALUES (Timestamp('1970-01-01T00:00:00Z'), 'a', '0');
154+ INSERT INTO `/Root/olapStore/olapTable` (timestamp, uid, resource_id) VALUES (Timestamp('1970-01-01T00:00:01Z'), 'a', 'test');
155+ INSERT INTO `/Root/olapStore/olapTable` (timestamp, uid, resource_id) VALUES (Timestamp('1970-01-01T00:00:02Z'), 'a', 't');
156+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
157+ UNIT_ASSERT_C (it.IsSuccess (), it.GetIssues ().ToString ());
158+ }
159+
160+ while (csController->GetInsertStartedCounter ().Val () == 0 ) {
161+ Cerr << " Wait indexation..." << Endl;
162+ Sleep (TDuration::Seconds (2 ));
163+ }
164+ {
165+ const TInstant start = TInstant::Now ();
166+ while (!Singleton<NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize () && TInstant::Now () - start < TDuration::Seconds (10 )) {
167+ Cerr << " Wait size in memory... " << Singleton<NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize () << Endl;
168+ Sleep (TDuration::Seconds (2 ));
169+ }
170+ AFL_VERIFY (Singleton<NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize ());
171+ }
172+ {
173+ auto it = client.ExecuteQuery (R"(
174+ DELETE FROM `/Root/olapStore/olapTable` ON SELECT CAST(0u AS Timestamp) AS timestamp, Unwrap(CAST('a' AS Utf8)) AS uid;
175+ DELETE FROM `/Root/olapStore/olapTable`;
176+ )" , NYdb::NQuery::TTxControl::BeginTx ().CommitTx ()).ExtractValueSync ();
177+ UNIT_ASSERT_C (it.IsSuccess (), it.GetIssues ().ToString ());
178+ }
179+ csController->SetReadTimeoutClean (TDuration::Zero ());
180+ csController->EnableBackground (NKikimr::NYDBTest::ICSController::EBackground::GC);
181+ {
182+ const TInstant start = TInstant::Now ();
183+ while (Singleton<NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize () && TInstant::Now () - start < TDuration::Seconds (10 )) {
184+ Cerr << " Wait empty... " << Singleton<NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize () << Endl;
185+ Sleep (TDuration::Seconds (2 ));
186+ }
187+ AFL_VERIFY (!Singleton<NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize ());
188+ }
189+ }
190+
134191}
135192
136193} // namespace
0 commit comments