Skip to content

Commit 0c1dba6

Browse files
committed
fix
1 parent c4dac2b commit 0c1dba6

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

ydb/core/mind/hive/hive_impl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ void THive::FillTabletInfo(NKikimrHive::TEvResponseHiveInfo& response, ui64 tabl
19761976
}
19771977
tabletInfo.SetRestartsPerPeriod(follower.GetRestartsPerPeriod(restartsBarrierTime));
19781978
if (req.GetReturnMetrics()) {
1979-
//tabletInfo.MutableMetrics()->CopyFrom(follower.GetResourceValues());
1979+
follower.GetResourceValues().ToProto(tabletInfo.MutableMetrics());
19801980
}
19811981
}
19821982
}
@@ -2717,7 +2717,6 @@ static void AggregateDiff(TMetrics& aggregate, const TMetrics& before, const TMe
27172717
i64 newValue = oldValue + delta;
27182718
Y_ENSURE_LOG(newValue >= 0, "tablet " << tabletId << " name=" << name << " oldValue=" << oldValue << " delta=" << delta << " newValue=" << newValue);
27192719
newValue = Max(newValue, (i64)0);
2720-
//BLOG_D("AggregateDiff: " << name << " -> " << newValue);
27212720
aggregate.*field = newValue;
27222721
}
27232722

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "hive_impl.h"
2+
#include "hive_log.h"
3+
4+
namespace NKikimr {
5+
namespace NHive {
6+
7+
class TTxProcessMetrics : public TTransactionBase<THive> {
8+
TSideEffects SideEffects;
9+
10+
static constexpr size_t MAX_UPDATES_PROCESSED = 200;
11+
public:
12+
TTxProcessMetrics(THive* hive)
13+
: TBase(hive)
14+
{}
15+
16+
TTxType GetTxType() const override { return NHive::TXTYPE_PROCESS_METRICS; }
17+
18+
bool Execute(TTransactionContext& txc, const TActorContext&) override {
19+
BLOG_D("TTxProcessMetrics::Execute()");
20+
NIceDb::TNiceDb db(txc.DB);
21+
SideEffects.Reset(Self->SelfId());
22+
for (size_t i = 0; !Self->ProcessMetricsQueue.empty() && i < MAX_UPDATES_PROCESSED; ++i) {
23+
auto tabletId = Self->ProcessMetricsQueue.front();
24+
Self->ProcessMetricsQueue.pop();
25+
auto* tablet = Self->FindTablet(tabletId);
26+
if (tablet == nullptr) {
27+
continue;
28+
}
29+
tablet->UpdateMetricsEnqueued = false;
30+
NKikimrTabletBase::TMetrics protoMetrics;
31+
tablet->GetResourceValues().ToProto(&protoMetrics);
32+
db.Table<Schema::Metrics>().Key(tabletId).Update<Schema::Metrics::ProtoMetrics>(protoMetrics);
33+
}
34+
if (Self->ProcessMetricsQueue.empty()) {
35+
Self->ProcessMetricsScheduled = false;
36+
} else {
37+
SideEffects.Send(Self->SelfId(), new TEvPrivate::TEvProcessMetrics);
38+
}
39+
return true;
40+
}
41+
42+
void Complete(const TActorContext& ctx) override {
43+
SideEffects.Complete(ctx);
44+
}
45+
};
46+
47+
ITransaction* THive::CreateProcessMetrics() {
48+
return new TTxProcessMetrics(this);
49+
}
50+
51+
} // NHive
52+
} // NKikimr

0 commit comments

Comments
 (0)