@@ -324,10 +324,14 @@ void TPartitionActor::Handle(TEvPQProxy::TEvDirectReadAck::TPtr& ev, const TActo
324
324
if (DirectReadRestoreStage != EDirectReadRestoreStage::None) {
325
325
if (RestoredDirectReadId == ev->Get ()->DirectReadId ) {
326
326
// This direct read is already being restored. Have to forget it later.
327
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Got ack for direct read " << ev->Get ()->DirectReadId
328
+ << " while restoring, store it to forget further" );
327
329
DirectReadsToForget.insert (ev->Get ()->DirectReadId );
328
330
return ;
329
331
}
330
332
if (DirectReadsToRestore.contains (ev->Get ()->DirectReadId )) {
333
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Got ack for direct read " << ev->Get ()->DirectReadId
334
+ << " while restoring, remove it from restore list" );
331
335
// This direct read is pending for restore. No need to foreget - not yet prepared, just erase it;
332
336
DirectReadsToRestore.erase (ev->Get ()->DirectReadId );
333
337
DirectReadsToPublish.erase (ev->Get ()->DirectReadId );
@@ -367,6 +371,7 @@ void TPartitionActor::Handle(const TEvPQProxy::TEvRestartPipe::TPtr&, const TAct
367
371
DirectReadsToRestore = DirectReadResults;
368
372
DirectReadsToPublish = PublishedDirectReads;
369
373
Y_ABORT_UNLESS (!DirectReadsToPublish.contains (DirectReadId));
374
+ RestoredDirectReadId = 0 ;
370
375
RestartDirectReadSession ();
371
376
return ;
372
377
}
@@ -700,6 +705,7 @@ void TPartitionActor::Handle(TEvPersQueue::TEvResponse::TPtr& ev, const TActorCo
700
705
break ;
701
706
case EDirectReadRestoreStage::Session:
702
707
Y_ABORT_UNLESS (result.HasCmdRestoreDirectReadResult ());
708
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Direct read - session restarted for partition " << Partition);
703
709
if (!SendNextRestorePrepareOrForget ()) {
704
710
OnDirectReadsRestored ();
705
711
}
@@ -725,6 +731,7 @@ void TPartitionActor::Handle(TEvPersQueue::TEvResponse::TPtr& ev, const TActorCo
725
731
return ;
726
732
case EDirectReadRestoreStage::Publish:
727
733
Y_ABORT_UNLESS (RestoredDirectReadId != 0 );
734
+
728
735
Y_ABORT_UNLESS (result.HasCmdPublishReadResult ());
729
736
Y_ABORT_UNLESS (*DirectReadsToPublish.begin () == result.GetCmdPublishReadResult ().GetDirectReadId ());
730
737
DirectReadsToPublish.erase (DirectReadsToPublish.begin ());
@@ -762,6 +769,8 @@ void TPartitionActor::Handle(TEvPersQueue::TEvResponse::TPtr& ev, const TActorCo
762
769
763
770
Y_ABORT_UNLESS (DirectRead);
764
771
Y_ABORT_UNLESS (res.GetDirectReadId () == DirectReadId);
772
+ if (!PipeClient)
773
+ return ; // Pipe was already destroyed, direct read session is being restored. Will resend this request afterwards;
765
774
766
775
EndOffset = res.GetEndOffset ();
767
776
SizeLag = res.GetSizeLag ();
@@ -1157,13 +1166,18 @@ bool TPartitionActor::SendNextRestorePrepareOrForget() {
1157
1166
if (shouldForget) {
1158
1167
// We have something to forget from what was already restored; Do NOT change RestoredDirectReadId
1159
1168
DirectReadRestoreStage = EDirectReadRestoreStage::Forget;
1169
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Restore direct read, forget id "
1170
+ << *DirectReadsToForget.begin () << " for partition " << Partition);
1160
1171
SendForgetDirectRead (*DirectReadsToForget.begin (), ctx);
1161
1172
return true ;
1162
1173
} else {
1163
- LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Resend prepare direct read id " << prepareId << " for partition " << Partition);
1174
+ auto & dr = DirectReadsToRestore.begin ()->second ;
1175
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Resend prepare direct read id " << prepareId
1176
+ << " (internal id: " << dr.GetDirectReadId () << " ) for partition " << Partition);
1164
1177
Y_ABORT_UNLESS (prepareId != 0 );
1178
+
1165
1179
// Restore;
1166
- auto & dr = DirectReadsToRestore. begin ()-> second ;
1180
+ Y_ABORT_UNLESS (prepareId == dr. GetDirectReadId ()) ;
1167
1181
1168
1182
Y_ABORT_UNLESS (RestoredDirectReadId < dr.GetDirectReadId ());
1169
1183
RestoredDirectReadId = dr.GetDirectReadId ();
@@ -1190,8 +1204,8 @@ bool TPartitionActor::SendNextRestorePublishRequest() {
1190
1204
return false ;
1191
1205
}
1192
1206
auto id = *DirectReadsToPublish.begin ();
1193
- LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " " << Partition
1194
- << " Resend publish direct read on restore, id: " << id );
1207
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Resend publish direct read on restore, id: "
1208
+ << id << " for partition " << Partition );
1195
1209
1196
1210
Y_ABORT_UNLESS (RestoredDirectReadId == id);
1197
1211
DirectReadRestoreStage = EDirectReadRestoreStage::Publish;
@@ -1373,7 +1387,6 @@ void TPartitionActor::Handle(TEvPQProxy::TEvRead::TPtr& ev, const TActorContext&
1373
1387
1374
1388
Y_ABORT_UNLESS (ReadGuid.empty ());
1375
1389
Y_ABORT_UNLESS (!RequestInfly);
1376
- Y_ABORT_UNLESS (DirectReadRestoreStage == EDirectReadRestoreStage::None);
1377
1390
1378
1391
ReadGuid = ev->Get ()->Guid ;
1379
1392
@@ -1386,6 +1399,12 @@ void TPartitionActor::Handle(TEvPQProxy::TEvRead::TPtr& ev, const TActorContext&
1386
1399
if (!PipeClient) // Pipe will be recreated soon
1387
1400
return ;
1388
1401
1402
+ if (DirectReadRestoreStage != EDirectReadRestoreStage::None) {
1403
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " READ FROM " << Partition
1404
+ << " store this request utill direct read is restored" );
1405
+ return ;
1406
+ }
1407
+
1389
1408
TAutoPtr<TEvPersQueue::TEvRequest> event (new TEvPersQueue::TEvRequest);
1390
1409
event->Record .Swap (&request);
1391
1410
0 commit comments