Skip to content

Commit 116e217

Browse files
authored
Edit pq write actor logs (#15677)
1 parent 36d1878 commit 116e217

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

ydb/library/yql/providers/pq/async_io/dq_pq_write_actor.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ struct TEvPrivate {
8888
struct TEvPqEventsReady : public TEventLocal<TEvPqEventsReady, EvPqEventsReady> {};
8989
};
9090

91+
TString MakeStringForLog(const NDqProto::TCheckpoint& checkpoint) {
92+
return TStringBuilder() << "[Checkpoint " << checkpoint.GetGeneration() << "." << checkpoint.GetId() << "] ";
93+
}
94+
9195
} // namespace
9296

9397
class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqComputeActorAsyncOutput {
@@ -155,6 +159,7 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
155159
, LogPrefix(TStringBuilder() << "SelfId: " << this->SelfId() << ", TxId: " << TxId << ", TaskId: " << taskId << ", PQ sink. ")
156160
, FreeSpace(freeSpace)
157161
, PqGateway(pqGateway)
162+
, TaskId(taskId)
158163
{
159164
EgressStats.Level = statsLevel;
160165
}
@@ -215,11 +220,11 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
215220

216221
if (checkpoint) {
217222
if (Buffer.empty() && WaitingAcks.empty()) {
218-
SINK_LOG_D("Send checkpoint state immediately");
223+
SINK_LOG_D(MakeStringForLog(*checkpoint) << "Send checkpoint state immediately");
219224
Callbacks->OnAsyncOutputStateSaved(BuildState(*checkpoint), OutputIndex, *checkpoint);
220225
} else {
221226
ui64 seqNo = NextSeqNo + Buffer.size() - 1;
222-
SINK_LOG_D("Defer sending the checkpoint, seqNo: " << seqNo);
227+
SINK_LOG_D(MakeStringForLog(*checkpoint) << "Defer sending the checkpoint, seqNo: " << seqNo);
223228
Metrics.InFlyCheckpoints->Inc();
224229
DeferredCheckpoints.emplace(seqNo, *checkpoint);
225230
}
@@ -275,10 +280,18 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
275280
)
276281

277282
void Handle(TEvPrivate::TEvPqEventsReady::TPtr&) {
283+
if (!Inited) {
284+
Init();
285+
Inited = true;
286+
}
278287
while (HandleNewPQEvents()) { }
279288
SubscribeOnNextEvent();
280289
}
281290

291+
void Init() {
292+
LogPrefix = TStringBuilder() << "SelfId: " << this->SelfId() << ", TxId: " << TxId << ", TaskId: " << TaskId << ", PQ sink. ";
293+
}
294+
282295
// IActor & IDqComputeActorAsyncOutput
283296
void PassAway() override { // Is called from Compute Actor
284297
if (WriteSession) {
@@ -433,7 +446,7 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
433446
if (!Self.DeferredCheckpoints.empty() && std::get<0>(Self.DeferredCheckpoints.front()) == it->SeqNo) {
434447
Self.ConfirmedSeqNo = it->SeqNo;
435448
const auto& checkpoint = std::get<1>(Self.DeferredCheckpoints.front());
436-
LOG_D(Self.LogPrefix << "Send a deferred checkpoint, seqNo: " << it->SeqNo);
449+
LOG_D(Self.LogPrefix << MakeStringForLog(checkpoint) << "Send a deferred checkpoint, seqNo: " << it->SeqNo);
437450
Self.Callbacks->OnAsyncOutputStateSaved(Self.BuildState(checkpoint), Self.OutputIndex, checkpoint);
438451
Self.DeferredCheckpoints.pop();
439452
Self.Metrics.InFlyCheckpoints->Dec();
@@ -479,7 +492,7 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
479492
NYdb::TDriver Driver;
480493
std::shared_ptr<NYdb::ICredentialsProviderFactory> CredentialsProviderFactory;
481494
IDqComputeActorAsyncOutput::ICallbacks* const Callbacks;
482-
const TString LogPrefix;
495+
TString LogPrefix;
483496
i64 FreeSpace = 0;
484497
bool Finished = false;
485498

@@ -495,6 +508,8 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
495508
std::queue<TAckInfo> WaitingAcks; // Size of items which are waiting for acks (used to update free space)
496509
std::queue<std::tuple<ui64, NDqProto::TCheckpoint>> DeferredCheckpoints;
497510
IPqGateway::TPtr PqGateway;
511+
ui64 TaskId;
512+
bool Inited = false;
498513
};
499514

500515
std::pair<IDqComputeActorAsyncOutput*, NActors::IActor*> CreateDqPqWriteActor(

0 commit comments

Comments
 (0)