1
1
#pragma once
2
2
3
- #include " common/modification_type.h"
4
3
#include " events.h"
5
4
#include " shards_splitter.h"
6
5
7
- #include < ydb/library/accessor/accessor.h>
6
+ #include " common/modification_type.h"
7
+
8
8
#include < ydb/core/base/tablet_pipecache.h>
9
+ #include < ydb/core/tx/columnshard/counters/common/owner.h>
9
10
#include < ydb/core/tx/long_tx_service/public/events.h>
11
+
12
+ #include < ydb/library/accessor/accessor.h>
10
13
#include < ydb/library/actors/core/actor_bootstrapped.h>
11
14
#include < ydb/library/actors/wilson/wilson_profile_span.h>
12
- #include < ydb/core/tx/columnshard/counters/common/owner.h>
13
-
14
15
15
16
namespace NKikimr ::NEvWrite {
16
17
@@ -19,6 +20,7 @@ class TWriteIdForShard {
19
20
YDB_READONLY (ui64, ShardId, 0 );
20
21
YDB_READONLY (ui64, WriteId, 0 );
21
22
YDB_READONLY (ui64, WritePartId, 0 );
23
+
22
24
public:
23
25
TWriteIdForShard () = default ;
24
26
TWriteIdForShard (const ui64 shardId, const ui64 writeId, const ui32 writePartId)
@@ -40,6 +42,9 @@ class TCSUploadCounters: public NColumnShard::TCommonCountersOwner {
40
42
NMonitoring::TDynamicCounters::TCounterPtr RowsCount;
41
43
NMonitoring::TDynamicCounters::TCounterPtr BytesCount;
42
44
NMonitoring::TDynamicCounters::TCounterPtr FailsCount;
45
+ NMonitoring::TDynamicCounters::TCounterPtr GlobalTimeoutCount;
46
+ NMonitoring::TDynamicCounters::TCounterPtr RetryTimeoutCount;
47
+
43
48
public:
44
49
TCSUploadCounters ()
45
50
: TBase(" CSUpload" )
@@ -51,8 +56,18 @@ class TCSUploadCounters: public NColumnShard::TCommonCountersOwner {
51
56
, RowsDistribution(TBase::GetHistogram(" Requests/Rows" , NMonitoring::ExponentialHistogram(15 , 2 , 16 )))
52
57
, RowsCount(TBase::GetDeriviative(" Rows" ))
53
58
, BytesCount(TBase::GetDeriviative(" Bytes" ))
54
- , FailsCount(TBase::GetDeriviative(" Fails" )) {
59
+ , FailsCount(TBase::GetDeriviative(" Fails" ))
60
+ , GlobalTimeoutCount(TBase::GetDeriviative(" GlobalTimeouts" ))
61
+ , RetryTimeoutCount(TBase::GetDeriviative(" RetryTimeouts" ))
62
+ {
63
+ }
64
+
65
+ void OnGlobalTimeout () const {
66
+ GlobalTimeoutCount->Inc ();
67
+ }
55
68
69
+ void OnRetryTimeout () const {
70
+ RetryTimeoutCount->Inc ();
56
71
}
57
72
58
73
void OnRequest (const ui64 rows, const ui64 bytes) const {
@@ -110,6 +125,7 @@ class TWritersController {
110
125
LongTxActorId.Send (NLongTxService::MakeLongTxServiceID (LongTxActorId.NodeId ()), req.Release ());
111
126
}
112
127
}
128
+
113
129
public:
114
130
using TPtr = std::shared_ptr<TWritersController>;
115
131
@@ -131,10 +147,10 @@ class TWritersController {
131
147
, Issues(issues) {
132
148
}
133
149
};
134
-
135
150
};
136
151
137
- TWritersController (const ui32 writesCount, const NActors::TActorIdentity& longTxActorId, const NLongTxService::TLongTxId& longTxId, const bool immediateWrite);
152
+ TWritersController (const ui32 writesCount, const NActors::TActorIdentity& longTxActorId, const NLongTxService::TLongTxId& longTxId,
153
+ const bool immediateWrite);
138
154
void OnSuccess (const ui64 shardId, const ui64 writeId, const ui32 writePartId);
139
155
void OnFail (const Ydb::StatusIds::StatusCode code, const TString& message);
140
156
};
@@ -158,40 +174,43 @@ class TShardWriter: public NActors::TActorBootstrapped<TShardWriter> {
158
174
NWilson::TProfileSpan ActorSpan;
159
175
EModificationType ModificationType;
160
176
const bool ImmediateWrite = false ;
177
+ const std::optional<TDuration> Timeout;
161
178
162
179
void SendWriteRequest ();
163
180
static TDuration OverloadTimeout () {
164
181
return TDuration::MilliSeconds (OverloadedDelayMs);
165
182
}
166
183
void SendToTablet (THolder<IEventBase> event) {
167
- Send (LeaderPipeCache, new TEvPipeCache::TEvForward (event.Release (), ShardId, true ),
168
- IEventHandle::FlagTrackDelivery, 0 , ActorSpan.GetTraceId ());
184
+ Send (LeaderPipeCache, new TEvPipeCache::TEvForward (event.Release (), ShardId, true ), IEventHandle::FlagTrackDelivery, 0 ,
185
+ ActorSpan.GetTraceId ());
169
186
}
170
187
virtual void PassAway () override {
171
188
Send (LeaderPipeCache, new TEvPipeCache::TEvUnlink (0 ));
172
189
TBase::PassAway ();
173
190
}
191
+
174
192
public:
175
193
TShardWriter (const ui64 shardId, const ui64 tableId, const ui64 schemaVersion, const TString& dedupId, const IShardInfo::TPtr& data,
176
194
const NWilson::TProfileSpan& parentSpan, TWritersController::TPtr externalController, const ui32 writePartIdx,
177
- const EModificationType mType , const bool immediateWrite);
195
+ const EModificationType mType , const bool immediateWrite, const std::optional<TDuration> timeout = std::nullopt );
178
196
179
197
STFUNC (StateMain) {
180
198
switch (ev->GetTypeRewrite ()) {
181
199
hFunc (TEvColumnShard::TEvWriteResult, Handle);
182
200
hFunc (TEvPipeCache::TEvDeliveryProblem, Handle);
183
201
hFunc (NEvents::TDataEvents::TEvWriteResult, Handle);
184
- CFunc (TEvents::TSystem::Wakeup, HandleTimeout );
202
+ hFunc (NActors::TEvents::TEvWakeup, Handle );
185
203
}
186
204
}
187
205
188
206
void Bootstrap ();
189
207
208
+ void Handle (NActors::TEvents::TEvWakeup::TPtr& ev);
190
209
void Handle (TEvColumnShard::TEvWriteResult::TPtr& ev);
191
210
void Handle (TEvPipeCache::TEvDeliveryProblem::TPtr& ev);
192
211
void Handle (NEvents::TDataEvents::TEvWriteResult::TPtr& ev);
193
- void HandleTimeout ( const TActorContext& ctx);
212
+
194
213
private:
195
214
bool RetryWriteRequest (const bool delayed = true );
196
215
};
197
- }
216
+ } // namespace NKikimr::NEvWrite
0 commit comments