Skip to content

Commit

Permalink
fix portions cleaning in case table removed (#9325)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Sep 17, 2024
1 parent c42930c commit a37a4ae
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ydb/core/tx/columnshard/engines/column_engine_logs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,16 @@ std::shared_ptr<TCleanupPortionsColumnEngineChanges> TColumnEngineForLogs::Start
ui32 skipLocked = 0;
ui32 portionsFromDrop = 0;
bool limitExceeded = false;
THashSet<TPortionAddress> uniquePortions;
for (ui64 pathId : pathsToDrop) {
auto g = GranulesStorage->GetGranuleOptional(pathId);
if (!g) {
continue;
}

for (auto& [portion, info] : g->GetPortions()) {
if (info->CheckForCleanup()) {
continue;
}
if (dataLocksManager->IsLocked(*info)) {
++skipLocked;
continue;
Expand All @@ -361,7 +363,6 @@ std::shared_ptr<TCleanupPortionsColumnEngineChanges> TColumnEngineForLogs::Start
limitExceeded = true;
break;
}
AFL_VERIFY(uniquePortions.emplace(info->GetAddress()).second);
changes->PortionsToDrop.push_back(*info);
++portionsFromDrop;
}
Expand All @@ -380,16 +381,14 @@ std::shared_ptr<TCleanupPortionsColumnEngineChanges> TColumnEngineForLogs::Start
++i;
continue;
}
if (uniquePortions.emplace(it->second[i].GetAddress()).second) {
AFL_VERIFY(it->second[i].CheckForCleanup(snapshot))("p_snapshot", it->second[i].GetRemoveSnapshotOptional())("snapshot", snapshot);
if (txSize + it->second[i].GetTxVolume() < txSizeLimit || changes->PortionsToDrop.empty()) {
txSize += it->second[i].GetTxVolume();
} else {
limitExceeded = true;
break;
}
changes->PortionsToDrop.push_back(std::move(it->second[i]));
AFL_VERIFY(it->second[i].CheckForCleanup(snapshot))("p_snapshot", it->second[i].GetRemoveSnapshotOptional())("snapshot", snapshot);
if (txSize + it->second[i].GetTxVolume() < txSizeLimit || changes->PortionsToDrop.empty()) {
txSize += it->second[i].GetTxVolume();
} else {
limitExceeded = true;
break;
}
changes->PortionsToDrop.push_back(std::move(it->second[i]));
if (i + 1 < it->second.size()) {
it->second[i] = std::move(it->second.back());
}
Expand Down

0 comments on commit a37a4ae

Please sign in to comment.