Skip to content

Commit

Permalink
Fix double portion deletion attempt (#4947)
Browse files Browse the repository at this point in the history
  • Loading branch information
zverevgeny authored May 28, 2024
1 parent 4e3063e commit d1de63e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ydb/core/tx/columnshard/engines/column_engine_logs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ 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) {
Expand All @@ -342,6 +343,8 @@ std::shared_ptr<TCleanupPortionsColumnEngineChanges> TColumnEngineForLogs::Start
limitExceeded = true;
break;
}
const auto inserted = uniquePortions.emplace(info->GetAddress()).second;
Y_ABORT_UNLESS(inserted);
changes->PortionsToDrop.push_back(*info);
++portionsFromDrop;
}
Expand All @@ -359,14 +362,17 @@ std::shared_ptr<TCleanupPortionsColumnEngineChanges> TColumnEngineForLogs::Start
++i;
continue;
}
Y_ABORT_UNLESS(it->second[i].CheckForCleanup(snapshot));
if (txSize + it->second[i].GetTxVolume() < txSizeLimit || changes->PortionsToDrop.empty()) {
txSize += it->second[i].GetTxVolume();
} else {
limitExceeded = true;
break;
const auto inserted = uniquePortions.emplace(it->second[i].GetAddress()).second;
if (inserted) {
Y_ABORT_UNLESS(it->second[i].CheckForCleanup(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]));
}
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 d1de63e

Please sign in to comment.