@@ -99,22 +99,16 @@ class TTableStatsCoroBuilder : public TActorCoroImpl, private IPages, TTableStat
99
99
PagesSize += info->GetPageSize (pageId);
100
100
Send (MakeSharedPageCacheId (), new NSharedCache::TEvRequest (NSharedCache::EPriority::Bkgr, info->PageCollection , { pageId }));
101
101
102
- Spent->Alter (false ); // pause measurement
103
- ReleaseResources ();
104
-
102
+ Interrupt ();
105
103
auto ev = WaitForSpecificEvent<NSharedCache::TEvResult>(&TTableStatsCoroBuilder::ProcessUnexpectedEvent);
106
- auto msg = ev->Get ();
107
-
108
- if (msg->Status != NKikimrProto::OK) {
104
+ if (auto status = ev->Get ()->Status ; status != NKikimrProto::OK) {
109
105
LOG_ERROR_S (GetActorContext (), NKikimrServices::TABLET_STATS_BUILDER, " Failed to build at datashard "
110
- << TabletId << " , for tableId " << TableId << " requested pages but got " << msg-> Status );
111
- throw TExTableStatsError (ECode::FETCH_PAGE_FAILED, NKikimrProto::EReplyStatus_Name (msg-> Status ));
106
+ << TabletId << " , for tableId " << TableId << " requested pages but got " << status );
107
+ throw TExTableStatsError (ECode::FETCH_PAGE_FAILED, NKikimrProto::EReplyStatus_Name (status ));
112
108
}
109
+ Resume ();
113
110
114
- ObtainResources ();
115
- Spent->Alter (true ); // resume measurement
116
-
117
- for (auto & loaded : msg->Pages ) {
111
+ for (auto & loaded : ev->Get ()->Pages ) {
118
112
partPages.emplace (pageId, TPinnedPageRef (loaded.Page ).GetData ());
119
113
PageRefs.emplace_back (std::move (loaded.Page ));
120
114
}
@@ -142,21 +136,19 @@ class TTableStatsCoroBuilder : public TActorCoroImpl, private IPages, TTableStat
142
136
143
137
Subset->ColdParts .clear (); // stats won't include cold parts, if any
144
138
Spent = new TSpent (TAppData::TimeProvider.Get ());
139
+ CoroutineDeadline = GetCycleCountFast () + DurationToCycles (MaxCoroutineExecutionTime);
145
140
146
141
BuildStats (*Subset, ev->Stats , RowCountResolution, DataSizeResolution, HistogramBucketsCount, this , [this ](){
147
142
const auto now = GetCycleCountFast ();
148
143
149
144
if (now > CoroutineDeadline) {
150
- Spent->Alter (false ); // pause measurement
151
- ReleaseResources ();
152
-
153
145
Send (new IEventHandle (EvResume, 0 , SelfActorId, {}, nullptr , 0 ));
146
+
147
+ Interrupt ();
154
148
WaitForSpecificEvent ([](IEventHandle& ev) {
155
149
return ev.Type == EvResume;
156
150
}, &TTableStatsCoroBuilder::ProcessUnexpectedEvent);
157
-
158
- ObtainResources ();
159
- Spent->Alter (true ); // resume measurement
151
+ Resume ();
160
152
}
161
153
}, TStringBuilder () << " Building stats at datashard " << TabletId << " , for tableId " << TableId << " : " );
162
154
@@ -170,8 +162,6 @@ class TTableStatsCoroBuilder : public TActorCoroImpl, private IPages, TTableStat
170
162
<< " , LoadedSize " << PagesSize << " , " << NFmt::Do (*Spent));
171
163
172
164
Send (ReplyTo, ev.Release ());
173
-
174
- ReleaseResources ();
175
165
}
176
166
177
167
void ProcessUnexpectedEvent (TAutoPtr<IEventHandle> ev) {
@@ -217,12 +207,15 @@ class TTableStatsCoroBuilder : public TActorCoroImpl, private IPages, TTableStat
217
207
auto msg = ev->Get ();
218
208
Y_ENSURE (!msg->Cookie .Get (), " Unexpected cookie in TEvResourceAllocated" );
219
209
Y_ENSURE (msg->TaskId == 1 , " Unexpected task id in TEvResourceAllocated" );
210
+ }
220
211
221
- CoroutineDeadline = GetCycleCountFast () + DurationToCycles (MaxCoroutineExecutionTime);
212
+ void Interrupt () {
213
+ Spent->Alter (false ); // pause measurement
222
214
}
223
215
224
- void ReleaseResources () {
225
- Send (MakeResourceBrokerID (), new TEvResourceBroker::TEvFinishTask (/* task id */ 1 , /* cancelled */ false ));
216
+ void Resume () {
217
+ Spent->Alter (true ); // resume measurement
218
+ CoroutineDeadline = GetCycleCountFast () + DurationToCycles (MaxCoroutineExecutionTime);
226
219
}
227
220
228
221
THashMap<const TPart*, THashMap<TPageId, TSharedData>> Pages;
0 commit comments