Skip to content

Commit 25615e5

Browse files
ivanmorozov333blinkov
authored andcommitted
fix compaction logic in case huge-deletion (#15039)
1 parent 06974bd commit 25615e5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,34 @@ TConclusionStatus TGeneralCompactColumnEngineChanges::DoConstructBlobs(TConstruc
8484
if (NYDBTest::TControllers::GetColumnShardController()->CheckPortionsToMergeOnCompaction(
8585
sumMemory + i->GetColumnMaxChunkMemory(), subsetsCount) &&
8686
subsetsCount > 1) {
87-
appendedToMerge.emplace_back(std::make_shared<TWritePortionsToMerge>(
88-
BuildAppendedPortionsByChunks(context, std::move(toMerge), resultFiltered, stats)));
87+
auto merged = BuildAppendedPortionsByChunks(context, std::move(toMerge), resultFiltered, stats);
88+
if (merged.size()) {
89+
appendedToMerge.emplace_back(std::make_shared<TWritePortionsToMerge>(std::move(merged)));
90+
}
8991
toMerge.clear();
9092
sumMemory = 0;
93+
subsetsCount = 0;
9194
}
9295
sumMemory += i->GetColumnMaxChunkMemory();
9396
totalSumMemory += i->GetColumnMaxChunkMemory();
9497
auto mergePortions = i->BuildPortionsToMerge(context, seqDataColumnIds, resultFiltered, usedPortionIds);
9598
toMerge.insert(toMerge.end(), mergePortions.begin(), mergePortions.end());
9699
++subsetsCount;
97100
}
98-
if (toMerge.size() > 1) {
101+
if (toMerge.size()) {
99102
auto merged = BuildAppendedPortionsByChunks(context, std::move(toMerge), resultFiltered, stats);
100103
if (appendedToMerge.size()) {
101-
appendedToMerge.emplace_back(std::make_shared<TWritePortionsToMerge>(std::move(merged)));
104+
if (merged.size()) {
105+
appendedToMerge.emplace_back(std::make_shared<TWritePortionsToMerge>(std::move(merged)));
106+
}
102107
} else {
103108
context.Counters.OnCompactionCorrectMemory(totalSumMemory);
104109
AppendedPortions = std::move(merged);
105110
break;
106111
}
107-
} else {
108-
AFL_VERIFY(appendedToMerge.size());
109-
AFL_VERIFY(currentToMerge.size());
110-
appendedToMerge.emplace_back(currentToMerge.back());
112+
}
113+
if (!appendedToMerge.size()) {
114+
break;
111115
}
112116
context.Counters.OnCompactionHugeMemory(totalSumMemory, appendedToMerge.size());
113117
currentToMerge = std::move(appendedToMerge);

0 commit comments

Comments
 (0)