@@ -150,34 +150,31 @@ bool TTxScan::Execute(TTransactionContext& /*txc*/, const TActorContext& /*ctx*/
150
150
if (!record.RangesSize ()) {
151
151
auto range = scannerConstructor->BuildReadMetadata (Self, read );
152
152
if (range) {
153
- ReadMetadataRanges = { range.DetachResult ()} ;
153
+ ReadMetadataRange = range.DetachResult ();
154
154
} else {
155
155
ErrorDescription = range.GetErrorMessage ();
156
156
}
157
157
return true ;
158
158
}
159
159
160
- ReadMetadataRanges.reserve (1 );
161
-
162
160
auto ydbKey = scannerConstructor->GetPrimaryKeyScheme (Self);
163
161
auto * indexInfo = (vIndex && isIndex) ? &vIndex->GetSchema (snapshot)->GetIndexInfo () : nullptr ;
164
162
for (auto & range : record.GetRanges ()) {
165
163
if (!FillPredicatesFromRange (read , range, ydbKey, Self->TabletID (), indexInfo, ErrorDescription)) {
166
- ReadMetadataRanges. clear () ;
164
+ ReadMetadataRange = nullptr ;
167
165
return true ;
168
166
}
169
167
}
170
168
{
171
169
auto newRange = scannerConstructor->BuildReadMetadata (Self, read );
172
170
if (!newRange) {
173
171
ErrorDescription = newRange.GetErrorMessage ();
174
- ReadMetadataRanges. clear () ;
172
+ ReadMetadataRange = nullptr ;
175
173
return true ;
176
174
}
177
- ReadMetadataRanges. emplace_back ( newRange.DetachResult () );
175
+ ReadMetadataRange = newRange.DetachResult ();
178
176
}
179
- Y_ABORT_UNLESS (ReadMetadataRanges.size () == 1 );
180
-
177
+ AFL_VERIFY (ReadMetadataRange);
181
178
return true ;
182
179
}
183
180
@@ -198,6 +195,7 @@ struct TContainerPrinter {
198
195
};
199
196
200
197
void TTxScan::Complete (const TActorContext& ctx) {
198
+
201
199
auto & request = Ev->Get ()->Record ;
202
200
auto scanComputeActor = Ev->Sender ;
203
201
const auto & snapshot = request.GetSnapshot ();
@@ -210,38 +208,43 @@ void TTxScan::Complete(const TActorContext& ctx) {
210
208
if (scanGen > 1 ) {
211
209
Self->IncCounter (NColumnShard::COUNTER_SCAN_RESTARTED);
212
210
}
211
+ const NActors::TLogContextGuard gLogging = NActors::TLogContextBuilder::Build ()
212
+ (" tx_id" , txId)(" scan_id" , scanId)(" gen" , scanGen)(" table" , table)(" snapshot" , snapshot)(" tablet" , Self->TabletID ())(" timeout" , timeout);
213
213
214
- TStringStream detailedInfo;
215
- if (IS_LOG_PRIORITY_ENABLED (NActors::NLog::PRI_TRACE, NKikimrServices::TX_COLUMNSHARD)) {
216
- detailedInfo << " read metadata: (" << TContainerPrinter (ReadMetadataRanges) << " )" << " req: " << request;
217
- }
218
- if (ReadMetadataRanges.empty ()) {
219
- LOG_S_DEBUG (" TTxScan failed "
220
- << " txId: " << txId
221
- << " scanId: " << scanId
222
- << " gen: " << scanGen
223
- << " table: " << table
224
- << " snapshot: " << snapshot
225
- << " timeout: " << timeout
226
- << detailedInfo.Str ()
227
- << " at tablet " << Self->TabletID ());
214
+ if (!ReadMetadataRange) {
215
+ AFL_WARN (NKikimrServices::TX_COLUMNSHARD_SCAN)(" event" , " TTxScan failed" )(" reason" , " no metadata" );
228
216
229
217
auto ev = MakeHolder<NKqp::TEvKqpCompute::TEvScanError>(scanGen, Self->TabletID ());
230
-
231
218
ev->Record .SetStatus (Ydb::StatusIds::BAD_REQUEST);
232
219
auto issue = NYql::YqlIssue ({}, NYql::TIssuesIds::KIKIMR_BAD_REQUEST, TStringBuilder ()
233
- << " Table " << table << " (shard " << Self->TabletID () << " ) scan failed, reason: " << ErrorDescription ? ErrorDescription : " unknown error " );
220
+ << " Table " << table << " (shard " << Self->TabletID () << " ) scan failed, reason: " << ErrorDescription ? ErrorDescription : " no metadata ranges " );
234
221
NYql::IssueToMessage (issue, ev->Record .MutableIssues ()->Add ());
235
222
236
223
ctx.Send (scanComputeActor, ev.Release ());
237
224
return ;
238
225
}
226
+ TStringBuilder detailedInfo;
227
+ if (IS_LOG_PRIORITY_ENABLED (NActors::NLog::PRI_TRACE, NKikimrServices::TX_COLUMNSHARD)) {
228
+ detailedInfo << " read metadata: (" << *ReadMetadataRange << " )" << " req: " << request;
229
+ }
239
230
240
231
const TVersionedIndex* index = nullptr ;
241
232
if (Self->HasIndex ()) {
242
233
index = &Self->GetIndexAs <TColumnEngineForLogs>().GetVersionedIndex ();
243
234
}
244
- ui64 requestCookie = Self->InFlightReadsTracker .AddInFlightRequest (ReadMetadataRanges, index );
235
+ const TConclusion<ui64> requestCookie = Self->InFlightReadsTracker .AddInFlightRequest (ReadMetadataRange, index );
236
+ if (!requestCookie) {
237
+ AFL_ERROR (NKikimrServices::TX_COLUMNSHARD_SCAN)(" event" , " TTxScan failed" )(" reason" , requestCookie.GetErrorMessage ())(" trace_details" , detailedInfo);
238
+ auto ev = MakeHolder<NKqp::TEvKqpCompute::TEvScanError>(scanGen, Self->TabletID ());
239
+
240
+ ev->Record .SetStatus (Ydb::StatusIds::INTERNAL_ERROR);
241
+ auto issue = NYql::YqlIssue ({}, NYql::TIssuesIds::KIKIMR_TEMPORARILY_UNAVAILABLE, TStringBuilder ()
242
+ << " Table " << table << " (shard " << Self->TabletID () << " ) scan failed, reason: " << requestCookie.GetErrorMessage ());
243
+ NYql::IssueToMessage (issue, ev->Record .MutableIssues ()->Add ());
244
+ Self->ScanCounters .OnScanDuration (NColumnShard::TScanCounters::EStatusFinish::CannotAddInFlight, TDuration::Zero ());
245
+ ctx.Send (scanComputeActor, ev.Release ());
246
+ return ;
247
+ }
245
248
auto statsDelta = Self->InFlightReadsTracker .GetSelectStatsDelta ();
246
249
247
250
Self->IncCounter (NColumnShard::COUNTER_READ_INDEX_PORTIONS, statsDelta.Portions );
@@ -253,17 +256,9 @@ void TTxScan::Complete(const TActorContext& ctx) {
253
256
AFL_VERIFY (shardingPolicy.DeserializeFromProto (request.GetComputeShardingPolicy ()));
254
257
255
258
auto scanActor = ctx.Register (new TColumnShardScan (Self->SelfId (), scanComputeActor, Self->GetStoragesManager (),
256
- shardingPolicy, scanId, txId, scanGen, requestCookie, Self->TabletID (), timeout, std::move (ReadMetadataRanges), dataFormat, Self->ScanCounters ));
257
-
258
- LOG_S_DEBUG (" TTxScan starting " << scanActor
259
- << " txId: " << txId
260
- << " scanId: " << scanId
261
- << " gen: " << scanGen
262
- << " table: " << table
263
- << " snapshot: " << snapshot
264
- << " timeout: " << timeout
265
- << detailedInfo.Str ()
266
- << " at tablet " << Self->TabletID ());
259
+ shardingPolicy, scanId, txId, scanGen, *requestCookie, Self->TabletID (), timeout, ReadMetadataRange, dataFormat, Self->ScanCounters ));
260
+
261
+ AFL_DEBUG (NKikimrServices::TX_COLUMNSHARD_SCAN)(" event" , " TTxScan started" )(" actor_id" , scanActor)(" trace_detailed" , detailedInfo);
267
262
}
268
263
269
264
}
0 commit comments