Skip to content

Commit 93834a3

Browse files
fix race with table removing on compaction in progress (#3232)
1 parent 3b87a8e commit 93834a3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77

88
namespace NKikimr::NOlap {
99

10-
void TChangesWithAppend::DoWriteIndexOnExecute(NColumnShard::TColumnShard* /*self*/, TWriteIndexContext& context) {
10+
void TChangesWithAppend::DoWriteIndexOnExecute(NColumnShard::TColumnShard* self, TWriteIndexContext& context) {
1111
THashSet<ui64> usedPortionIds;
1212
for (auto& [_, portionInfo] : PortionsToRemove) {
1313
Y_ABORT_UNLESS(!portionInfo.Empty());
1414
Y_ABORT_UNLESS(portionInfo.HasRemoveSnapshot());
1515
AFL_VERIFY(usedPortionIds.emplace(portionInfo.GetPortionId()).second)("portion_info", portionInfo.DebugString(true));
1616
portionInfo.SaveToDatabase(context.DBWrapper);
1717
}
18+
const auto predRemoveDroppedTable = [self](const TPortionInfoWithBlobs& item) {
19+
auto& portionInfo = item.GetPortionInfo();
20+
if (!self->TablesManager.HasTable(portionInfo.GetPathId()) || self->TablesManager.GetTable(portionInfo.GetPathId()).IsDropped()) {
21+
AFL_WARN(NKikimrServices::TX_COLUMNSHARD)("event", "skip_inserted_data")("reason", "table_removed")("path_id", portionInfo.GetPathId());
22+
return true;
23+
} else {
24+
return false;
25+
}
26+
};
27+
AppendedPortions.erase(std::remove_if(AppendedPortions.begin(), AppendedPortions.end(), predRemoveDroppedTable), AppendedPortions.end());
1828
for (auto& portionInfoWithBlobs : AppendedPortions) {
1929
auto& portionInfo = portionInfoWithBlobs.GetPortionInfo();
2030
Y_ABORT_UNLESS(!portionInfo.Empty());

0 commit comments

Comments
 (0)