Skip to content

add missing table stats for column shards #7140

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 19 commits into from
Aug 1, 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/protos/counters_columnshard.proto
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ enum ECumulativeCounters {
COUNTER_READING_EXPORTED_BLOBS = 79 [(CounterOpts) = {Name: "ReadingExportedBlobs"}];
COUNTER_READING_EXPORTED_BYTES = 80 [(CounterOpts) = {Name: "ReadingExportedBytes"}];
COUNTER_READING_EXPORTED_RANGES = 81 [(CounterOpts) = {Name: "ReadingExportedRanges"}];
COUNTER_PLANNED_TX_COMPLETED = 82 [(CounterOpts) = {Name: "PlannedTxCompleted"}];
COUNTER_IMMEDIATE_TX_COMPLETED = 83 [(CounterOpts) = {Name: "ImmediateTxCompleted"}];
}

enum EPercentileCounters {
Expand Down
7 changes: 7 additions & 0 deletions ydb/core/tx/columnshard/background_controller.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "engines/changes/abstract/compaction_info.h"
#include "engines/portions/meta.h"
#include <ydb/core/tx/columnshard/counters/counters_manager.h>

namespace NKikimr::NOlap {
class TColumnEngineChanges;
Expand All @@ -15,11 +16,16 @@ class TBackgroundController {
using TCurrentCompaction = THashMap<ui64, NOlap::TPlanCompactionInfo>;
TCurrentCompaction ActiveCompactionInfo;

std::shared_ptr<TBackgroundControllerCounters> Counters;
bool ActiveCleanupPortions = false;
bool ActiveCleanupTables = false;
bool ActiveCleanupInsertTable = false;
YDB_READONLY(TMonotonic, LastIndexationInstant, TMonotonic::Zero());
public:
TBackgroundController(std::shared_ptr<TBackgroundControllerCounters> counters)
: Counters(std::move(counters)) {
}

THashSet<NOlap::TPortionAddress> GetConflictTTLPortions() const;
THashSet<NOlap::TPortionAddress> GetConflictCompactionPortions() const;

Expand All @@ -29,6 +35,7 @@ class TBackgroundController {
bool StartCompaction(const NOlap::TPlanCompactionInfo& info);
void FinishCompaction(const NOlap::TPlanCompactionInfo& info) {
Y_ABORT_UNLESS(ActiveCompactionInfo.erase(info.GetPathId()));
Counters->OnCompactionFinish(info.GetPathId());
}
const TCurrentCompaction& GetActiveCompaction() const {
return ActiveCompactionInfo;
Expand Down
7 changes: 2 additions & 5 deletions ydb/core/tx/columnshard/blobs_action/bs/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ void TWriteAction::DoOnCompleteTxAfterWrite(NColumnShard::TColumnShard& self, co
ui64 blobsWritten = BlobBatch.GetBlobCount();
ui64 bytesWritten = BlobBatch.GetTotalSize();
if (blobsWroteSuccessfully) {
self.IncCounter(NColumnShard::COUNTER_UPSERT_BLOBS_WRITTEN, blobsWritten);
self.IncCounter(NColumnShard::COUNTER_UPSERT_BYTES_WRITTEN, bytesWritten);
// self.IncCounter(NColumnShard::COUNTER_RAW_BYTES_UPSERTED, insertedBytes);
self.IncCounter(NColumnShard::COUNTER_WRITE_SUCCESS);
self.Counters.GetTabletCounters()->OnWriteSuccess(blobsWritten, bytesWritten);
Manager->SaveBlobBatchOnComplete(std::move(BlobBatch));
} else {
self.IncCounter(NColumnShard::COUNTER_WRITE_FAIL);
self.Counters.GetTabletCounters()->OnWriteFailure();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool TTxWrite::Execute(TTransactionContext& txc, const TActorContext&) {

if (!InsertOneBlob(txc, i, writeId)) {
LOG_S_DEBUG(TxPrefix() << "duplicate writeId " << (ui64)writeId << TxSuffix());
Self->IncCounter(COUNTER_WRITE_DUPLICATE);
Self->Counters.GetTabletCounters()->IncCounter(COUNTER_WRITE_DUPLICATE);
}
}
}
Expand Down Expand Up @@ -140,10 +140,10 @@ void TTxWrite::Complete(const TActorContext& ctx) {
}
for (ui32 i = 0; i < buffer.GetAggregations().size(); ++i) {
const auto& writeMeta = buffer.GetAggregations()[i]->GetWriteMeta();
Self->CSCounters.OnWriteTxComplete(now - writeMeta.GetWriteStartInstant());
Self->CSCounters.OnSuccessWriteResponse();
Self->Counters.GetCSCounters().OnWriteTxComplete(now - writeMeta.GetWriteStartInstant());
Self->Counters.GetCSCounters().OnSuccessWriteResponse();
}

Self->Counters.GetTabletCounters()->IncCounter(COUNTER_IMMEDIATE_TX_COMPLETED);
}

}
182 changes: 83 additions & 99 deletions ydb/core/tx/columnshard/columnshard.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions ydb/core/tx/columnshard/columnshard__init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx)
}
Self->TablesManager = std::move(tManagerLocal);

Self->SetCounter(COUNTER_TABLES, Self->TablesManager.GetTables().size());
Self->SetCounter(COUNTER_TABLE_PRESETS, Self->TablesManager.GetSchemaPresets().size());
Self->SetCounter(COUNTER_TABLE_TTLS, Self->TablesManager.GetTtl().PathsCount());
Self->Counters.GetTabletCounters()->SetCounter(COUNTER_TABLES, Self->TablesManager.GetTables().size());
Self->Counters.GetTabletCounters()->SetCounter(COUNTER_TABLE_PRESETS, Self->TablesManager.GetSchemaPresets().size());
Self->Counters.GetTabletCounters()->SetCounter(COUNTER_TABLE_TTLS, Self->TablesManager.GetTtl().PathsCount());
ACFL_DEBUG("step", "TTablesManager::Load_Finish");
}

Expand Down Expand Up @@ -253,7 +253,7 @@ bool TTxInit::Execute(TTransactionContext& txc, const TActorContext& ctx) {
}

void TTxInit::Complete(const TActorContext& ctx) {
Self->CSCounters.Initialization.OnTxInitFinished(TMonotonic::Now() - StartInstant);
Self->Counters.GetCSCounters().Initialization.OnTxInitFinished(TMonotonic::Now() - StartInstant);
Self->ProgressTxController->OnTabletInit();
Self->SwitchToWork(ctx);
NYDBTest::TControllers::GetColumnShardController()->OnTabletInitCompleted(*Self);
Expand Down Expand Up @@ -301,7 +301,7 @@ bool TTxUpdateSchema::Execute(TTransactionContext& txc, const TActorContext&) {

void TTxUpdateSchema::Complete(const TActorContext& ctx) {
AFL_INFO(NKikimrServices::TX_COLUMNSHARD)("step", "TTxUpdateSchema.Complete");
Self->CSCounters.Initialization.OnTxUpdateSchemaFinished(TMonotonic::Now() - StartInstant);
Self->Counters.GetCSCounters().Initialization.OnTxUpdateSchemaFinished(TMonotonic::Now() - StartInstant);
if (NormalizerTasks.empty()) {
AFL_VERIFY(Self->NormalizerController.IsNormalizationFinished())("details", Self->NormalizerController.DebugString());
Self->Execute(new TTxInit(Self), ctx);
Expand Down Expand Up @@ -432,7 +432,7 @@ bool TTxInitSchema::Execute(TTransactionContext& txc, const TActorContext&) {
}

void TTxInitSchema::Complete(const TActorContext& ctx) {
Self->CSCounters.Initialization.OnTxInitSchemaFinished(TMonotonic::Now() - StartInstant);
Self->Counters.GetCSCounters().Initialization.OnTxInitSchemaFinished(TMonotonic::Now() - StartInstant);
LOG_S_DEBUG("TxInitSchema.Complete at tablet " << Self->TabletID(););
Self->Execute(new TTxUpdateSchema(Self), ctx);
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/columnshard__plan_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool TTxPlanStep::Execute(TTransactionContext& txc, const TActorContext& ctx) {

Result = std::make_unique<TEvTxProcessing::TEvPlanStepAccepted>(Self->TabletID(), step);

Self->IncCounter(COUNTER_PLAN_STEP_ACCEPTED);
Self->Counters.GetTabletCounters()->IncCounter(COUNTER_PLAN_STEP_ACCEPTED);

if (plannedCount > 0 || Self->ProgressTxController->HaveOutdatedTxs()) {
Self->EnqueueProgressTx(ctx);
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/tx/columnshard/columnshard__progress_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
bool Execute(TTransactionContext& txc, const TActorContext& ctx) override {
NActors::TLogContextGuard logGuard = NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD)("tablet_id", Self->TabletID())("tx_state", "execute");
Y_ABORT_UNLESS(Self->ProgressTxInFlight);
Self->TabletCounters->Simple()[COUNTER_TX_COMPLETE_LAG].Set(Self->GetTxCompleteLag().MilliSeconds());
Self->Counters.GetTabletCounters()->SetCounter(COUNTER_TX_COMPLETE_LAG, Self->GetTxCompleteLag().MilliSeconds());

const size_t removedCount = Self->ProgressTxController->CleanExpiredTxs(txc);
if (removedCount > 0) {
Expand All @@ -43,6 +43,7 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
TxOperator = Self->ProgressTxController->GetVerifiedTxOperator(txId);
AFL_VERIFY(TxOperator->ProgressOnExecute(*Self, NOlap::TSnapshot(step, txId), txc));
Self->ProgressTxController->FinishPlannedTx(txId, txc);
Self->Counters.GetTabletCounters()->IncCounter(COUNTER_PLANNED_TX_COMPLETED);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TTxProposeTransaction: public NTabletFlatExecutor::TTransactionBase<TColum
txc.DB.NoMoreReadsForTx();
NIceDb::TNiceDb db(txc.DB);

Self->IncCounter(COUNTER_PREPARE_REQUEST);
Self->Counters.GetTabletCounters()->IncCounter(COUNTER_PREPARE_REQUEST);

auto& record = Proto(Ev->Get());
const auto txKind = record.GetTxKind();
Expand Down
7 changes: 4 additions & 3 deletions ydb/core/tx/columnshard/columnshard__scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "engines/reader/transaction/tx_internal_scan.h"

#include <ydb/core/protos/kqp.pb.h>
#include <ydb/core/base/appdata_fwd.h>

namespace NKikimr::NColumnShard {

Expand All @@ -29,9 +30,9 @@ void TColumnShard::Handle(TEvColumnShard::TEvScan::TPtr& ev, const TActorContext
return;
}

LastAccessTime = TAppData::TimeProvider->Now();
ScanTxInFlight.insert({txId, LastAccessTime});
SetCounter(COUNTER_SCAN_IN_FLY, ScanTxInFlight.size());
Counters.GetColumnTablesCounters()->GetPathIdCounter(record.GetLocalPathId())->OnAccess();
ScanTxInFlight.insert({txId, TAppData::TimeProvider->Now()});
Counters.GetTabletCounters()->SetCounter(COUNTER_SCAN_IN_FLY, ScanTxInFlight.size());
Execute(new NOlap::NReader::TTxScan(this, ev), ctx);
}

Expand Down
Loading
Loading