Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix allocations manager limits control #12622

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/core/tx/limiter/grouped_memory/service/allocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ TAllocationInfo::TAllocationInfo(const ui64 processId, const ui64 scopeId, const
AFL_VERIFY(Allocation);
AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "add")("id", Allocation->GetIdentifier())("stage", Stage->GetName());
AllocatedVolume = Allocation->GetMemory();
Stage->Add(AllocatedVolume, Allocation->IsAllocated());
if (allocation->IsAllocated()) {
AFL_INFO(NKikimrServices::GROUPED_MEMORY_LIMITER)("event", "allocated_on_add")("allocation_id", Identifier)("stage", Stage->GetName());
Allocation = nullptr;
}
Stage->Add(AllocatedVolume, GetAllocationStatus() == EAllocationStatus::Allocated);
}

} // namespace NKikimr::NOlap::NGroupedMemoryManager
3 changes: 2 additions & 1 deletion ydb/core/tx/limiter/grouped_memory/service/allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TAllocationInfo: public NColumnShard::TMonitoringObjectsCounter<TAllocatio

public:
~TAllocationInfo() {
if (GetAllocationStatus() == EAllocationStatus::Allocated) {
if (GetAllocationStatus() != EAllocationStatus::Failed) {
Stage->Free(AllocatedVolume, GetAllocationStatus() == EAllocationStatus::Allocated);
}

Expand Down Expand Up @@ -52,6 +52,7 @@ class TAllocationInfo: public NColumnShard::TMonitoringObjectsCounter<TAllocatio
if (allocationResult.IsFail()) {
AllocationFailed = true;
Allocation->OnAllocationImpossible(allocationResult.GetErrorMessage());
Allocation = nullptr;
return false;
}
const bool result = Allocation->OnAllocated(
Expand Down
12 changes: 6 additions & 6 deletions ydb/core/tx/limiter/grouped_memory/usage/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TPositiveControlInteger {
Value += value;
}
void Sub(const ui64 value) {
AFL_VERIFY(value <= Value);
AFL_VERIFY(value <= Value)("base", Value)("delta", value);
Value -= value;
}
ui64 Val() const {
Expand Down Expand Up @@ -126,11 +126,11 @@ class TStageFeatures {
}

[[nodiscard]] TConclusionStatus Allocate(const ui64 volume) {
Waiting.Sub(volume);
if (HardLimit < Usage.Val() + volume) {
Counters->OnCannotAllocate();
return TConclusionStatus::Fail(TStringBuilder() << "limit:" << HardLimit << ";val:" << Usage.Val() << ";delta=" << volume << ";");
return TConclusionStatus::Fail(TStringBuilder() << Name << "::(limit:" << HardLimit << ";val:" << Usage.Val() << ";delta=" << volume << ");");
}
Waiting.Sub(volume);
Usage.Add(volume);
if (Counters) {
Counters->Add(volume, true);
Expand All @@ -139,14 +139,14 @@ class TStageFeatures {
if (Owner) {
const auto ownerResult = Owner->Allocate(volume);
if (ownerResult.IsFail()) {
Free(volume, true);
Free(volume, true, false);
return ownerResult;
}
}
return TConclusionStatus::Success();
}

void Free(const ui64 volume, const bool allocated) {
void Free(const ui64 volume, const bool allocated, const bool withOwner = true) {
if (Counters) {
Counters->Sub(volume, allocated);
}
Expand All @@ -156,7 +156,7 @@ class TStageFeatures {
Waiting.Sub(volume);
}

if (Owner) {
if (withOwner && Owner) {
Owner->Free(volume, allocated);
}
}
Expand Down
Loading