Skip to content

Commit 8e30a70

Browse files
swalrus1ivanmorozov333
authored andcommitted
fix groups allocation cleaning (#10274) (#10325)
Co-authored-by: ivanmorozov333 <[email protected]>
1 parent 087f903 commit 8e30a70

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ydb/core/tx/limiter/grouped_memory/service/ids.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ ui64 TIdsControl::ExtractInternalIdVerified(const ui64 externalId) {
1212
return result;
1313
}
1414

15+
std::optional<ui64> TIdsControl::ExtractInternalIdOptional(const ui64 externalId) {
16+
auto it = ExternalIdIntoInternalId.find(externalId);
17+
if (it == ExternalIdIntoInternalId.end()) {
18+
return std::nullopt;
19+
}
20+
const ui64 result = it->second;
21+
InternalIdIntoExternalId.erase(result);
22+
ExternalIdIntoInternalId.erase(it);
23+
return result;
24+
}
25+
1526
std::optional<ui64> TIdsControl::GetInternalIdOptional(const ui64 externalId) const {
1627
auto it = ExternalIdIntoInternalId.find(externalId);
1728
if (it != ExternalIdIntoInternalId.end()) {

ydb/core/tx/limiter/grouped_memory/service/ids.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class TIdsControl {
2929
}
3030

3131
[[nodiscard]] ui64 ExtractInternalIdVerified(const ui64 externalId);
32+
[[nodiscard]] std::optional<ui64> ExtractInternalIdOptional(const ui64 externalId);
3233

3334
ui64 GetMinInternalIdVerified() const;
3435
ui64 GetExternalIdVerified(const ui64 internalId) const;

ydb/core/tx/limiter/grouped_memory/service/process.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class TProcessMemoryScope: public NColumnShard::TMonitoringObjectsCounter<TProce
135135
}
136136

137137
void UnregisterGroup(const bool isPriorityProcess, const ui64 externalGroupId) {
138-
if (auto internalGroupId = GroupIds.GetInternalIdOptional(externalGroupId)) {
138+
if (auto internalGroupId = GroupIds.ExtractInternalIdOptional(externalGroupId)) {
139139
AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "remove_group")("external_group_id", externalGroupId)(
140140
"internal_group_id", internalGroupId);
141141
UnregisterGroupImpl(*internalGroupId);

0 commit comments

Comments
 (0)