Skip to content

Commit b933339

Browse files
authored
Merge 8e30a70 into f6729a6
2 parents f6729a6 + 8e30a70 commit b933339

File tree

8 files changed

+53
-18
lines changed

8 files changed

+53
-18
lines changed

ydb/core/tx/columnshard/engines/column_engine_logs.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,14 @@ const TColumnEngineStats& TColumnEngineForLogs::GetTotalStats() {
6060

6161
void TColumnEngineForLogs::UpdatePortionStats(const TPortionInfo& portionInfo, EStatsUpdateType updateType,
6262
const TPortionInfo* exPortionInfo) {
63-
UpdatePortionStats(Counters, portionInfo, updateType, exPortionInfo);
64-
63+
if (IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_DEBUG, NKikimrServices::TX_COLUMNSHARD)) {
64+
auto before = Counters.Active();
65+
UpdatePortionStats(Counters, portionInfo, updateType, exPortionInfo);
66+
auto after = Counters.Active();
67+
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("event", "portion_stats_updated")("type", updateType)("path_id", portionInfo.GetPathId())("portion", portionInfo.GetPortionId())("before_size", before.Bytes)("after_size", after.Bytes)("before_rows", before.Rows)("after_rows", after.Rows);
68+
} else {
69+
UpdatePortionStats(Counters, portionInfo, updateType, exPortionInfo);
70+
}
6571
const ui64 pathId = portionInfo.GetPathId();
6672
Y_ABORT_UNLESS(pathId);
6773
if (!PathStats.contains(pathId)) {

ydb/core/tx/columnshard/engines/ya.make

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ SRCS(
1616
defs.cpp
1717
)
1818

19+
GENERATE_ENUM_SERIALIZATION(column_engine_logs.h)
20+
1921
PEERDIR(
2022
contrib/libs/apache/arrow
2123
ydb/core/base

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
#include <ydb/core/tx/columnshard/counters/common/object_counter.h>
23
#include <ydb/core/tx/limiter/grouped_memory/usage/abstract.h>
34

45
namespace NKikimr::NOlap::NGroupedMemoryManager {
@@ -9,7 +10,7 @@ enum class EAllocationStatus {
910
Failed
1011
};
1112

12-
class TAllocationInfo {
13+
class TAllocationInfo: public NColumnShard::TMonitoringObjectsCounter<TAllocationInfo> {
1314
private:
1415
std::shared_ptr<IAllocation> Allocation;
1516
YDB_READONLY(ui64, AllocationInternalGroupId, 0);
@@ -25,7 +26,7 @@ class TAllocationInfo {
2526
if (GetAllocationStatus() != EAllocationStatus::Failed) {
2627
Stage->Free(AllocatedVolume, GetAllocationStatus() == EAllocationStatus::Allocated);
2728
}
28-
29+
2930
AFL_TRACE(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "destroy")("allocation_id", Identifier)("stage", Stage->GetName());
3031
}
3132

@@ -69,8 +70,8 @@ class TAllocationInfo {
6970
}
7071
}
7172

72-
TAllocationInfo(const ui64 processId, const ui64 scopeId, const ui64 allocationInternalGroupId, const std::shared_ptr<IAllocation>& allocation,
73-
const std::shared_ptr<TStageFeatures>& stage);
73+
TAllocationInfo(const ui64 processId, const ui64 scopeId, const ui64 allocationInternalGroupId,
74+
const std::shared_ptr<IAllocation>& allocation, const std::shared_ptr<TStageFeatures>& stage);
7475
};
7576

7677
} // namespace NKikimr::NOlap::NGroupedMemoryManager

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#pragma once
22
#include "allocation.h"
33

4+
#include <ydb/core/tx/columnshard/counters/common/object_counter.h>
5+
46
namespace NKikimr::NOlap::NGroupedMemoryManager {
57

68
class TProcessMemoryScope;
79

8-
class TGrouppedAllocations {
10+
class TGrouppedAllocations: public NColumnShard::TMonitoringObjectsCounter<TGrouppedAllocations> {
911
private:
1012
THashMap<ui64, std::shared_ptr<TAllocationInfo>> Allocations;
1113

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

+20-11
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#include "group.h"
33
#include "ids.h"
44

5+
#include <ydb/core/tx/columnshard/counters/common/object_counter.h>
6+
57
#include <ydb/library/accessor/validator.h>
68

79
namespace NKikimr::NOlap::NGroupedMemoryManager {
810

9-
class TProcessMemoryScope {
11+
class TProcessMemoryScope: public NColumnShard::TMonitoringObjectsCounter<TProcessMemoryScope> {
1012
private:
1113
const ui64 ExternalProcessId;
1214
const ui64 ExternalScopeId;
@@ -63,6 +65,8 @@ class TProcessMemoryScope {
6365
}
6466
GroupIds.Clear();
6567
AllocationInfo.clear();
68+
AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "scope_cleaned")("process_id", ExternalProcessId)(
69+
"external_scope_id", ExternalScopeId);
6670
return true;
6771
}
6872

@@ -106,7 +110,11 @@ class TProcessMemoryScope {
106110
bool UnregisterAllocation(const ui64 allocationId) {
107111
ui64 memoryAllocated = 0;
108112
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+
}
110118
bool waitFlag = false;
111119
const ui64 internalGroupId = it->second->GetAllocationInternalGroupId();
112120
switch (it->second->GetAllocationStatus()) {
@@ -127,12 +135,15 @@ class TProcessMemoryScope {
127135
}
128136

129137
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);
136147
}
137148
}
138149

@@ -141,7 +152,7 @@ class TProcessMemoryScope {
141152
}
142153
};
143154

144-
class TProcessMemory {
155+
class TProcessMemory: public NColumnShard::TMonitoringObjectsCounter<TProcessMemory> {
145156
private:
146157
const ui64 ExternalProcessId;
147158

@@ -214,7 +225,6 @@ class TProcessMemory {
214225
if (it->second->Unregister()) {
215226
AllocationScopes.erase(it);
216227
}
217-
218228
}
219229

220230
void RegisterScope(const ui64 externalScopeId) {
@@ -224,7 +234,6 @@ class TProcessMemory {
224234
} else {
225235
it->second->Register();
226236
}
227-
228237
}
229238

230239
void SetPriorityProcess() {

ydb/core/tx/schemeshard/schemeshard__table_stats.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ bool TTxStoreTableStats::PersistSingleStats(const TPathId& pathId,
246246
}
247247

248248
TShardIdx shardIdx = Self->TabletIdToShardIdx[datashardId];
249+
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
250+
"PersistSingleStats for pathId " << pathId.LocalPathId << " shard idx " << shardIdx << " data size " << dataSize << " row count " << rowCount
251+
);
249252
const auto* shardInfo = Self->ShardInfos.FindPtr(shardIdx);
250253
if (!shardInfo) {
251254
LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,

0 commit comments

Comments
 (0)