From d9e60f7f0bd4f2d50d0007ef688c28cbd17182d3 Mon Sep 17 00:00:00 2001 From: ivanmorozov333 Date: Thu, 3 Oct 2024 09:23:55 +0300 Subject: [PATCH 1/2] fix unregister group race --- .../tx/limiter/grouped_memory/service/process.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ydb/core/tx/limiter/grouped_memory/service/process.h b/ydb/core/tx/limiter/grouped_memory/service/process.h index a1c13e091d59..2351b9d0872a 100644 --- a/ydb/core/tx/limiter/grouped_memory/service/process.h +++ b/ydb/core/tx/limiter/grouped_memory/service/process.h @@ -127,12 +127,15 @@ class TProcessMemoryScope { } void UnregisterGroup(const bool isPriorityProcess, const ui64 externalGroupId) { - const ui64 internalGroupId = GroupIds.ExtractInternalIdVerified(externalGroupId); - AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "remove_group")("external_group_id", externalGroupId)( - "internal_group_id", internalGroupId); - UnregisterGroupImpl(internalGroupId); - if (isPriorityProcess && (internalGroupId < GroupIds.GetMinInternalIdDef(internalGroupId))) { - Y_UNUSED(TryAllocateWaiting(isPriorityProcess, 0)); + if (auto internalGroupId = GroupIds.GetInternalIdOptional()) { + AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "remove_group")("external_group_id", externalGroupId)( + "internal_group_id", internalGroupId); + UnregisterGroupImpl(*internalGroupId); + if (isPriorityProcess && (*internalGroupId < GroupIds.GetMinInternalIdDef(*internalGroupId))) { + Y_UNUSED(TryAllocateWaiting(isPriorityProcess, 0)); + } + } else { + AFL_WARN(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "remove_absent_group")("external_group_id", externalGroupId); } } From 34a44c49cd44e97409c4244e9fc417a168b0c5ec Mon Sep 17 00:00:00 2001 From: ivanmorozov333 Date: Thu, 3 Oct 2024 09:36:28 +0300 Subject: [PATCH 2/2] fix build --- ydb/core/tx/limiter/grouped_memory/service/process.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ydb/core/tx/limiter/grouped_memory/service/process.h b/ydb/core/tx/limiter/grouped_memory/service/process.h index 2351b9d0872a..855b3daeb43a 100644 --- a/ydb/core/tx/limiter/grouped_memory/service/process.h +++ b/ydb/core/tx/limiter/grouped_memory/service/process.h @@ -127,7 +127,7 @@ class TProcessMemoryScope { } void UnregisterGroup(const bool isPriorityProcess, const ui64 externalGroupId) { - if (auto internalGroupId = GroupIds.GetInternalIdOptional()) { + if (auto internalGroupId = GroupIds.GetInternalIdOptional(externalGroupId)) { AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "remove_group")("external_group_id", externalGroupId)( "internal_group_id", internalGroupId); UnregisterGroupImpl(*internalGroupId);