Skip to content

Commit ba7abc4

Browse files
fix case indexation removed table (#8713)
1 parent 15da817 commit ba7abc4

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

ydb/core/kqp/ut/olap/write_ut.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ Y_UNIT_TEST_SUITE(KqpOlapWrite) {
4747
AFL_VERIFY(!Singleton<NKikimr::NWrappers::NExternalStorage::TFakeExternalStorage>()->GetSize());
4848
}
4949

50+
Y_UNIT_TEST(TestRemoveTableBeforeIndexation) {
51+
auto csController = NKikimr::NYDBTest::TControllers::RegisterCSControllerGuard<NKikimr::NYDBTest::NColumnShard::TController>();
52+
csController->SetIndexWriteControllerEnabled(false);
53+
csController->SetOverridePeriodicWakeupActivationPeriod(TDuration::Seconds(1));
54+
csController->DisableBackground(NKikimr::NYDBTest::ICSController::EBackground::Indexation);
55+
csController->DisableBackground(NKikimr::NYDBTest::ICSController::EBackground::Compaction);
56+
57+
auto settings = TKikimrSettings().SetWithSampleTables(false);
58+
TKikimrRunner kikimr(settings);
59+
TLocalHelper(kikimr).CreateTestOlapTable();
60+
Tests::NCommon::TLoggerInit(kikimr).SetComponents({ NKikimrServices::TX_COLUMNSHARD }, "CS").SetPriority(NActors::NLog::PRI_DEBUG).Initialize();
61+
auto tableClient = kikimr.GetTableClient();
62+
63+
WriteTestData(kikimr, "/Root/olapStore/olapTable", 30000, 1000000, 11000);
64+
TTypedLocalHelper("Utf8", kikimr).ExecuteSchemeQuery("DROP TABLE `/Root/olapStore/olapTable`;");
65+
csController->EnableBackground(NKikimr::NYDBTest::ICSController::EBackground::Indexation);
66+
csController->EnableBackground(NKikimr::NYDBTest::ICSController::EBackground::Compaction);
67+
csController->WaitIndexation(TDuration::Seconds(5));
68+
csController->WaitCompactions(TDuration::Seconds(5));
69+
}
70+
5071
Y_UNIT_TEST(TierDraftsGCWithRestart) {
5172
auto csController = NKikimr::NYDBTest::TControllers::RegisterCSControllerGuard<NKikimr::NYDBTest::NColumnShard::TController>();
5273
csController->SetIndexWriteControllerEnabled(false);

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ void TColumnShard::StartIndexTask(std::vector<const NOlap::TInsertedData*>&& dat
638638
data.reserve(dataToIndex.size());
639639
for (auto& ptr : dataToIndex) {
640640
data.push_back(*ptr);
641+
if (!TablesManager.HasTable(data.back().PathId)) {
642+
data.back().SetRemove();
643+
}
641644
}
642645

643646
Y_ABORT_UNLESS(data.size());

ydb/core/tx/columnshard/engines/changes/indexation.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,20 @@ TConclusionStatus TInsertColumnEngineChanges::DoConstructBlobs(TConstructionCont
220220

221221
TPathesData pathBatches(resultSchema);
222222
for (auto& inserted : DataToIndex) {
223+
if (inserted.GetRemove()) {
224+
continue;
225+
}
223226
pathBatches.AddChunkInfo(inserted, context);
224227
}
225228

226229
pathBatches.FinishChunksInfo();
227230

228231
for (auto& inserted : DataToIndex) {
229232
const TBlobRange& blobRange = inserted.GetBlobRange();
233+
if (inserted.GetRemove()) {
234+
Blobs.Extract(IStoragesManager::DefaultStorageId, blobRange);
235+
continue;
236+
}
230237
auto blobSchema = context.SchemaVersions.GetSchemaVerified(inserted.GetSchemaVersion());
231238

232239
std::shared_ptr<NArrow::TGeneralContainer> batch;
@@ -261,7 +268,7 @@ TConclusionStatus TInsertColumnEngineChanges::DoConstructBlobs(TConstructionCont
261268
filters.resize(batches.size());
262269

263270
auto itGranule = PathToGranule.find(pathId);
264-
AFL_VERIFY(itGranule != PathToGranule.end());
271+
AFL_VERIFY(itGranule != PathToGranule.end())("path_id", pathId);
265272
NCompaction::TMerger merger(context, SaverContext, std::move(batches), std::move(filters));
266273
merger.SetOptimizationWritingPackMode(true);
267274
auto localAppended = merger.Execute(stats, itGranule->second, filteredSnapshot, pathId, shardingVersion);

ydb/core/tx/columnshard/engines/column_engine_logs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ std::shared_ptr<TInsertColumnEngineChanges> TColumnEngineForLogs::StartInsert(st
285285
if (changes->PathToGranule.contains(pathId)) {
286286
continue;
287287
}
288-
AFL_VERIFY(changes->PathToGranule.emplace(pathId, GetGranulePtrVerified(pathId)->GetBucketPositions()).second);
288+
if (!data.GetRemove()) {
289+
AFL_VERIFY(changes->PathToGranule.emplace(pathId, GetGranulePtrVerified(pathId)->GetBucketPositions()).second);
290+
}
291+
289292
}
290293

291294
return changes;

ydb/core/tx/columnshard/engines/insert_table/data.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct TInsertedData {
2424
};
2525

2626
std::shared_ptr<TBlobStorageGuard> BlobDataGuard;
27+
YDB_READONLY(bool, Remove, false);
2728

2829
public:
2930
ui64 PlanStep = 0;
@@ -36,6 +37,11 @@ struct TInsertedData {
3637
YDB_READONLY_FLAG(NotAbortable, false);
3738

3839
public:
40+
void SetRemove() {
41+
AFL_VERIFY(!Remove);
42+
Remove = true;
43+
}
44+
3945
void MarkAsNotAbortable() {
4046
NotAbortableFlag = true;
4147
}

0 commit comments

Comments
 (0)