Skip to content

Commit 71f2cff

Browse files
authored
Logging & tagging KIKIMR-21006 (#1881)
1 parent 804dc05 commit 71f2cff

File tree

4 files changed

+63
-7
lines changed

4 files changed

+63
-7
lines changed

ydb/core/tx/replication/service/table_writer.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
#include <ydb/core/tx/datashard/datashard.h>
1010
#include <ydb/core/tx/scheme_cache/helpers.h>
1111
#include <ydb/core/tx/tx_proxy/proxy.h>
12+
#include <ydb/library/actors/core/actor_bootstrapped.h>
1213
#include <ydb/library/actors/core/actor.h>
1314
#include <ydb/library/actors/core/hfunc.h>
15+
#include <ydb/library/services/services.pb.h>
1416

1517
#include <util/generic/map.h>
18+
#include <util/generic/maybe.h>
19+
#include <util/string/builder.h>
1620

1721
namespace NKikimr::NReplication::NService {
1822

@@ -128,6 +132,10 @@ class TTablePartitionWriter: public TActorBootstrapped<TTablePartitionWriter> {
128132
}
129133

130134
public:
135+
static constexpr NKikimrServices::TActivity::EType ActorActivityType() {
136+
return NKikimrServices::TActivity::REPLICATION_TABLE_PARTITION_WRITER;
137+
}
138+
131139
explicit TTablePartitionWriter(const TActorId& parent, ui64 tabletId, const TPathId& tablePathId)
132140
: Parent(parent)
133141
, TabletId(tabletId)
@@ -461,6 +469,10 @@ class TLocalTableWriter
461469
}
462470

463471
public:
472+
static constexpr NKikimrServices::TActivity::EType ActorActivityType() {
473+
return NKikimrServices::TActivity::REPLICATION_LOCAL_TABLE_WRITER;
474+
}
475+
464476
explicit TLocalTableWriter(const TPathId& tablePathId)
465477
: TActor(&TThis::StateWork)
466478
, TBaseChangeSender(this, this, tablePathId)

ydb/core/tx/replication/service/topic_reader.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include <ydb/core/tx/replication/ydb_proxy/ydb_proxy.h>
66
#include <ydb/library/actors/core/actor.h>
77
#include <ydb/library/actors/core/hfunc.h>
8+
#include <ydb/library/services/services.pb.h>
9+
10+
#include <util/generic/maybe.h>
11+
#include <util/string/builder.h>
812

913
namespace NKikimr::NReplication::NService {
1014

@@ -64,7 +68,7 @@ class TRemoteTopicReader: public TActor<TRemoteTopicReader> {
6468
LOG_D("Handle " << ev->Get()->ToString());
6569

6670
auto& result = ev->Get()->Result;
67-
TVector<TEvWorker::TEvData::TRecord> records(Reserve(result.Messages.size()));
71+
TVector<TEvWorker::TEvData::TRecord> records(::Reserve(result.Messages.size()));
6872

6973
for (auto& msg : result.Messages) {
7074
Y_ABORT_UNLESS(msg.GetCodec() == NYdb::NTopic::ECodec::RAW);
@@ -100,6 +104,10 @@ class TRemoteTopicReader: public TActor<TRemoteTopicReader> {
100104
}
101105

102106
public:
107+
static constexpr NKikimrServices::TActivity::EType ActorActivityType() {
108+
return NKikimrServices::TActivity::REPLICATION_REMOTE_TOPIC_READER;
109+
}
110+
103111
explicit TRemoteTopicReader(const TActorId& ydbProxy, const TReadSessionSettings& opts)
104112
: TActor(&TThis::StateWork)
105113
, YdbProxy(ydbProxy)

ydb/core/tx/replication/service/worker.cpp

+39-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#include "logging.h"
12
#include "worker.h"
23

34
#include <ydb/library/actors/core/actor_bootstrapped.h>
45
#include <ydb/library/actors/core/hfunc.h>
56
#include <ydb/library/services/services.pb.h>
67

8+
#include <util/generic/maybe.h>
79
#include <util/string/builder.h>
810
#include <util/string/join.h>
911

@@ -60,6 +62,16 @@ class TWorker: public TActorBootstrapped<TWorker> {
6062
}
6163
};
6264

65+
TStringBuf GetLogPrefix() const {
66+
if (!LogPrefix) {
67+
LogPrefix = TStringBuilder()
68+
<< "[Worker]"
69+
<< SelfId() << " ";
70+
}
71+
72+
return LogPrefix.GetRef();
73+
}
74+
6375
TActorId RegisterActor(TActorInfo& info) {
6476
Y_ABORT_UNLESS(info.Actor);
6577
info.ActorId = RegisterWithSameMailbox(info.Actor.Release());
@@ -73,31 +85,46 @@ class TWorker: public TActorBootstrapped<TWorker> {
7385
}
7486

7587
void Handle(TEvWorker::TEvHandshake::TPtr& ev) {
88+
LOG_D("Handle " << ev->Get()->ToString());
89+
7690
if (ev->Sender == Reader) {
91+
LOG_I("Handshake with reader"
92+
<< ": sender# " << ev->Sender);
7793
Reader.InitDone = true;
7894
} else if (ev->Sender == Writer) {
95+
LOG_I("Handshake with writer"
96+
<< ": sender# " << ev->Sender);
7997
Writer.InitDone = true;
8098
} else {
81-
// TODO: log warn
99+
LOG_W("Handshake from unknown actor"
100+
<< ": sender# " << ev->Sender);
101+
return;
82102
}
83103

84104
if (Reader && Writer) {
105+
LOG_N("Start working");
85106
Send(Reader, new TEvWorker::TEvPoll());
86107
}
87108
}
88109

89110
void Handle(TEvWorker::TEvPoll::TPtr& ev) {
111+
LOG_D("Handle " << ev->Get()->ToString());
112+
90113
if (ev->Sender != Writer) {
91-
// TODO: log warn
114+
LOG_W("Poll from unknown actor"
115+
<< ": sender# " << ev->Sender);
92116
return;
93117
}
94118

95119
Send(ev->Forward(Reader));
96120
}
97121

98122
void Handle(TEvWorker::TEvData::TPtr& ev) {
123+
LOG_D("Handle " << ev->Get()->ToString());
124+
99125
if (ev->Sender != Reader) {
100-
// TODO: log warn
126+
LOG_W("Data from unknown actor"
127+
<< ": sender# " << ev->Sender);
101128
return;
102129
}
103130

@@ -106,11 +133,16 @@ class TWorker: public TActorBootstrapped<TWorker> {
106133

107134
void Handle(TEvents::TEvGone::TPtr& ev) {
108135
if (ev->Sender == Reader) {
109-
// TODO
136+
LOG_I("Reader has gone"
137+
<< ": sender# " << ev->Sender);
138+
// TODO: handle
110139
} else if (ev->Sender == Writer) {
111-
// TODO
140+
LOG_I("Writer has gone"
141+
<< ": sender# " << ev->Sender);
142+
// TODO: handle
112143
} else {
113-
// TODO: log warn
144+
LOG_W("Unknown actor has gone"
145+
<< ": sender# " << ev->Sender);
114146
}
115147
}
116148

@@ -153,6 +185,7 @@ class TWorker: public TActorBootstrapped<TWorker> {
153185
}
154186

155187
private:
188+
mutable TMaybe<TString> LogPrefix;
156189
TActorInfo Reader;
157190
TActorInfo Writer;
158191
};

ydb/library/services/services.proto

+3
Original file line numberDiff line numberDiff line change
@@ -1019,5 +1019,8 @@ message TActivity {
10191019
REPLICATION_WORKER = 625;
10201020
SCHEMESHARD_BACKGROUND_CLEANING = 626;
10211021
JAEGER_TRACING_CONFIGURATOR = 627;
1022+
REPLICATION_REMOTE_TOPIC_READER = 628;
1023+
REPLICATION_LOCAL_TABLE_WRITER = 629;
1024+
REPLICATION_TABLE_PARTITION_WRITER = 630;
10221025
};
10231026
};

0 commit comments

Comments
 (0)