Skip to content

extra details added to error message #9539

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

Merged
merged 1 commit into from
Sep 20, 2024
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: 2 additions & 0 deletions ydb/core/kqp/rm_service/kqp_rm_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class TKqpResourceManager : public IKqpResourceManager {

if (!hasScanQueryMemory) {
Counters->RmNotEnoughMemory->Inc();
tx->AckFailedMemoryAlloc(resources.Memory);
TStringBuilder reason;
reason << "TxId: " << txId << ", taskId: " << taskId << ". Not enough memory for query, requested: " << resources.Memory
<< ". " << tx->ToString();
Expand All @@ -302,6 +303,7 @@ class TKqpResourceManager : public IKqpResourceManager {
Y_DEFER {
if (!result) {
Counters->RmNotEnoughMemory->Inc();
tx->AckFailedMemoryAlloc(resources.Memory);
with_lock (Lock) {
TotalMemoryResource->Release(resources.Memory);
if (!tx->PoolId.empty()) {
Expand Down
21 changes: 17 additions & 4 deletions ydb/core/kqp/rm_service/kqp_rm_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <util/datetime/base.h>
#include <util/string/builder.h>
#include <util/stream/format.h>

#include "kqp_resource_estimation.h"

Expand Down Expand Up @@ -122,6 +123,8 @@ class TTxState : public TAtomicRefCount<TTxState> {
std::atomic<ui64> TxScanQueryMemory = 0;
std::atomic<ui64> TxExternalDataQueryMemory = 0;
std::atomic<ui32> TxExecutionUnits = 0;
std::atomic<ui64> TxMaxAllocation = 0;
std::atomic<ui64> TxFailedAllocation = 0;

public:
explicit TTxState(ui64 txId, TInstant now, TIntrusivePtr<TKqpCounters> counters, const TString& poolId, const double memoryPoolPercent,
Expand All @@ -145,12 +148,14 @@ class TTxState : public TAtomicRefCount<TTxState> {

if (!PoolId.empty()) {
res << ", PoolId: " << PoolId
<< ", MemoryPoolPercent: " << Sprintf("%.2f", MemoryPoolPercent);
<< ", MemoryPoolPercent: " << Sprintf("%.2f", MemoryPoolPercent > 0 ? MemoryPoolPercent : 100);
}

res << ", memory initially granted resources: " << TxExternalDataQueryMemory.load()
<< ", tx total allocations " << TxScanQueryMemory.load()
<< ", execution units: " << TxExecutionUnits.load()
res << ", tx initially granted memory: " << HumanReadableSize(TxExternalDataQueryMemory.load(), SF_BYTES)
<< ", tx total memory allocations: " << HumanReadableSize(TxScanQueryMemory.load(), SF_BYTES)
<< ", tx largest successful memory allocation: " << HumanReadableSize(TxMaxAllocation.load(), SF_BYTES)
<< ", tx largest failed memory allocation: " << HumanReadableSize(TxFailedAllocation.load(), SF_BYTES)
<< ", tx total execution units: " << TxExecutionUnits.load()
<< ", started at: " << CreatedAt
<< " }";

Expand All @@ -161,6 +166,11 @@ class TTxState : public TAtomicRefCount<TTxState> {
return TxScanQueryMemory.load();
}

void AckFailedMemoryAlloc(ui64 memory) {
ui64 maxAlloc = TxFailedAllocation.load();
while(maxAlloc < memory && !TxFailedAllocation.compare_exchange_weak(maxAlloc, memory));
}

void Released(TIntrusivePtr<TTaskState>& taskState, const TKqpResourcesRequest& resources) {
if (resources.ExecutionUnits) {
Counters->RmOnCompleteFree->Inc();
Expand All @@ -176,6 +186,9 @@ class TTxState : public TAtomicRefCount<TTxState> {
taskState->ScanQueryMemory -= resources.Memory;
Counters->RmMemory->Sub(resources.Memory);

ui64 maxAlloc = TxMaxAllocation.load();
while(maxAlloc < resources.Memory && !TxMaxAllocation.compare_exchange_weak(maxAlloc, resources.Memory));

TxExecutionUnits.fetch_sub(resources.ExecutionUnits);
taskState->ExecutionUnits -= resources.ExecutionUnits;
Counters->RmComputeActors->Sub(resources.ExecutionUnits);
Expand Down
Loading