Skip to content

Commit 12a6cb7

Browse files
authored
Support batch/scan mode for TEvRead (#11201)
1 parent 3a6411f commit 12a6cb7

File tree

9 files changed

+1031
-334
lines changed

9 files changed

+1031
-334
lines changed

ydb/core/tablet_flat/flat_scan_actor.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ namespace NOps {
314314
}
315315

316316
bool MayProgress() noexcept {
317-
return Cache->MayProgress() && ColdPartLoaders.empty();
317+
return !IsPaused() && Cache->MayProgress() && ColdPartLoaders.empty();
318318
}
319319

320320
void Touch(EScan scan) noexcept override
@@ -336,7 +336,9 @@ namespace NOps {
336336
return Terminate(EAbort::None);
337337

338338
case EScan::Sleep:
339-
Y_ABORT("Scan actor got an unexpected EScan::Sleep");
339+
Pause();
340+
341+
return Spent->Alter(/* resources not available */ false);
340342
}
341343

342344
Y_ABORT("Scan actor got an unexpected EScan value");
@@ -521,7 +523,7 @@ namespace NOps {
521523

522524
ContinueInFly = false;
523525

524-
if (!IsPaused() && MayProgress()) {
526+
if (MayProgress()) {
525527
React();
526528
}
527529
}

ydb/core/tablet_flat/flat_scan_feed.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ namespace NTable {
2020

2121
}
2222

23+
void Pause() noexcept {
24+
OnPause = true;
25+
}
26+
2327
void Resume(EScan op) noexcept
2428
{
2529
Y_DEBUG_ABORT_UNLESS(op == EScan::Feed || op == EScan::Reset);

ydb/core/tx/datashard/datashard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4393,7 +4393,7 @@ void TDataShard::ScanComplete(NTable::EAbort,
43934393

43944394
noTxScan->OnFinished(this);
43954395
prod.Destroy();
4396-
} else {
4396+
} else if (cookie != 0 && cookie != Max<ui64>()) {
43974397
LOG_DEBUG_S(ctx, NKikimrServices::TX_DATASHARD,
43984398
"FullScan complete at " << TabletID());
43994399

ydb/core/tx/datashard/datashard.h

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ namespace TEvDataShard {
338338
EvReshuffleKMeansRequest,
339339
EvReshuffleKMeansResponse,
340340

341+
// Sent by the scan actor when EvRead uses a scan
342+
EvReadScanStarted,
343+
EvReadScanFinished,
344+
341345
EvEnd
342346
};
343347

@@ -924,6 +928,9 @@ namespace TEvDataShard {
924928
NKikimrTxDataShard::TEvRead,
925929
TEvDataShard::EvRead>;
926930

931+
static constexpr ui32 HINT_BATCH = NKikimrTxDataShard::TEvRead::HINT_BATCH;
932+
static constexpr ui32 HINT_LOW_PRIORITY = NKikimrTxDataShard::TEvRead::HINT_LOW_PRIORITY;
933+
927934
TEvRead() = default;
928935

929936
TString ToString() const override;
@@ -1042,12 +1049,10 @@ namespace TEvDataShard {
10421049
};
10431050

10441051
struct TEvReadContinue : public TEventLocal<TEvReadContinue, TEvDataShard::EvReadContinue> {
1045-
TActorId Reader;
1046-
ui64 ReadId;
1052+
const ui64 LocalReadId;
10471053

1048-
TEvReadContinue(TActorId reader, ui64 readId)
1049-
: Reader(reader)
1050-
, ReadId(readId)
1054+
explicit TEvReadContinue(ui64 localReadId)
1055+
: LocalReadId(localReadId)
10511056
{}
10521057
};
10531058

@@ -1063,6 +1068,24 @@ namespace TEvDataShard {
10631068
TEvReadCancel() = default;
10641069
};
10651070

1071+
struct TEvReadScanStarted : public TEventLocal<TEvReadScanStarted, EvReadScanStarted> {
1072+
const ui64 LocalReadId;
1073+
1074+
// Event sender is the scan actor
1075+
explicit TEvReadScanStarted(ui64 localReadId)
1076+
: LocalReadId(localReadId)
1077+
{}
1078+
};
1079+
1080+
struct TEvReadScanFinished : public TEventLocal<TEvReadScanFinished, EvReadScanFinished> {
1081+
const ui64 LocalReadId;
1082+
1083+
// Event sender is the scan actor
1084+
explicit TEvReadScanFinished(ui64 localReadId)
1085+
: LocalReadId(localReadId)
1086+
{}
1087+
};
1088+
10661089
struct TEvReadColumnsRequest : public TEventPB<TEvReadColumnsRequest,
10671090
NKikimrTxDataShard::TEvReadColumnsRequest,
10681091
TEvDataShard::EvReadColumnsRequest> {

0 commit comments

Comments
 (0)