2
2
#include " group.h"
3
3
#include " ids.h"
4
4
5
+ #include < ydb/core/tx/columnshard/counters/common/object_counter.h>
6
+
5
7
#include < ydb/library/accessor/validator.h>
6
8
7
9
namespace NKikimr ::NOlap::NGroupedMemoryManager {
8
10
9
- class TProcessMemoryScope {
11
+ class TProcessMemoryScope : public NColumnShard ::TMonitoringObjectsCounter<TProcessMemoryScope> {
10
12
private:
11
13
const ui64 ExternalProcessId;
12
14
const ui64 ExternalScopeId;
@@ -63,6 +65,8 @@ class TProcessMemoryScope {
63
65
}
64
66
GroupIds.Clear ();
65
67
AllocationInfo.clear ();
68
+ AFL_INFO (NKikimrServices::GROUPED_MEMORY_LIMITER)(" event" , " scope_cleaned" )(" process_id" , ExternalProcessId)(
69
+ " external_scope_id" , ExternalScopeId);
66
70
return true ;
67
71
}
68
72
@@ -106,7 +110,11 @@ class TProcessMemoryScope {
106
110
bool UnregisterAllocation (const ui64 allocationId) {
107
111
ui64 memoryAllocated = 0 ;
108
112
auto it = AllocationInfo.find (allocationId);
109
- AFL_VERIFY (it != AllocationInfo.end ());
113
+ if (it == AllocationInfo.end ()) {
114
+ AFL_WARN (NKikimrServices::GROUPED_MEMORY_LIMITER)(" reason" , " allocation_cleaned_in_previous_scope_id_live" )(
115
+ " allocation_id" , allocationId)(" process_id" , ExternalProcessId)(" external_scope_id" , ExternalScopeId);
116
+ return true ;
117
+ }
110
118
bool waitFlag = false ;
111
119
const ui64 internalGroupId = it->second ->GetAllocationInternalGroupId ();
112
120
switch (it->second ->GetAllocationStatus ()) {
@@ -127,12 +135,15 @@ class TProcessMemoryScope {
127
135
}
128
136
129
137
void UnregisterGroup (const bool isPriorityProcess, const ui64 externalGroupId) {
130
- const ui64 internalGroupId = GroupIds.ExtractInternalIdVerified (externalGroupId);
131
- AFL_INFO (NKikimrServices::GROUPED_MEMORY_LIMITER)(" event" , " remove_group" )(" external_group_id" , externalGroupId)(
132
- " internal_group_id" , internalGroupId);
133
- UnregisterGroupImpl (internalGroupId);
134
- if (isPriorityProcess && (internalGroupId < GroupIds.GetMinInternalIdDef (internalGroupId))) {
135
- Y_UNUSED (TryAllocateWaiting (isPriorityProcess, 0 ));
138
+ if (auto internalGroupId = GroupIds.ExtractInternalIdOptional (externalGroupId)) {
139
+ AFL_INFO (NKikimrServices::GROUPED_MEMORY_LIMITER)(" event" , " remove_group" )(" external_group_id" , externalGroupId)(
140
+ " internal_group_id" , internalGroupId);
141
+ UnregisterGroupImpl (*internalGroupId);
142
+ if (isPriorityProcess && (*internalGroupId < GroupIds.GetMinInternalIdDef (*internalGroupId))) {
143
+ Y_UNUSED (TryAllocateWaiting (isPriorityProcess, 0 ));
144
+ }
145
+ } else {
146
+ AFL_WARN (NKikimrServices::GROUPED_MEMORY_LIMITER)(" event" , " remove_absent_group" )(" external_group_id" , externalGroupId);
136
147
}
137
148
}
138
149
@@ -141,7 +152,7 @@ class TProcessMemoryScope {
141
152
}
142
153
};
143
154
144
- class TProcessMemory {
155
+ class TProcessMemory : public NColumnShard ::TMonitoringObjectsCounter<TProcessMemory> {
145
156
private:
146
157
const ui64 ExternalProcessId;
147
158
@@ -214,7 +225,6 @@ class TProcessMemory {
214
225
if (it->second ->Unregister ()) {
215
226
AllocationScopes.erase (it);
216
227
}
217
-
218
228
}
219
229
220
230
void RegisterScope (const ui64 externalScopeId) {
@@ -224,7 +234,6 @@ class TProcessMemory {
224
234
} else {
225
235
it->second ->Register ();
226
236
}
227
-
228
237
}
229
238
230
239
void SetPriorityProcess () {
0 commit comments