@@ -271,10 +271,14 @@ void TPartitionActor::Handle(TEvPQProxy::TEvDirectReadAck::TPtr& ev, const TActo
271
271
if (DirectReadRestoreStage != EDirectReadRestoreStage::None) {
272
272
if (RestoredDirectReadId == ev->Get ()->DirectReadId ) {
273
273
// This direct read is already being restored. Have to forget it later.
274
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Got ack for direct read " << ev->Get ()->DirectReadId
275
+ << " while restoring, store it to forget further" );
274
276
DirectReadsToForget.insert (ev->Get ()->DirectReadId );
275
277
return ;
276
278
}
277
279
if (DirectReadsToRestore.contains (ev->Get ()->DirectReadId )) {
280
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Got ack for direct read " << ev->Get ()->DirectReadId
281
+ << " while restoring, remove it from restore list" );
278
282
// This direct read is pending for restore. No need to foreget - not yet prepared, just erase it;
279
283
DirectReadsToRestore.erase (ev->Get ()->DirectReadId );
280
284
DirectReadsToPublish.erase (ev->Get ()->DirectReadId );
@@ -316,6 +320,7 @@ void TPartitionActor::Handle(const TEvPQProxy::TEvRestartPipe::TPtr&, const TAct
316
320
DirectReadsToRestore = DirectReadResults;
317
321
DirectReadsToPublish = PublishedDirectReads;
318
322
Y_ABORT_UNLESS (!DirectReadsToPublish.contains (DirectReadId));
323
+ RestoredDirectReadId = 0 ;
319
324
RestartDirectReadSession ();
320
325
return ;
321
326
}
@@ -634,6 +639,7 @@ void TPartitionActor::Handle(TEvPersQueue::TEvResponse::TPtr& ev, const TActorCo
634
639
break ;
635
640
case EDirectReadRestoreStage::Session:
636
641
Y_ABORT_UNLESS (result.HasCmdRestoreDirectReadResult ());
642
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Direct read - session restarted for partition " << Partition);
637
643
if (!SendNextRestorePrepareOrForget ()) {
638
644
OnDirectReadsRestored ();
639
645
}
@@ -654,6 +660,7 @@ void TPartitionActor::Handle(TEvPersQueue::TEvResponse::TPtr& ev, const TActorCo
654
660
return ;
655
661
case EDirectReadRestoreStage::Publish:
656
662
Y_ABORT_UNLESS (RestoredDirectReadId != 0 );
663
+
657
664
Y_ABORT_UNLESS (result.HasCmdPublishReadResult ());
658
665
Y_ABORT_UNLESS (*DirectReadsToPublish.begin () == result.GetCmdPublishReadResult ().GetDirectReadId ());
659
666
DirectReadsToPublish.erase (DirectReadsToPublish.begin ());
@@ -730,6 +737,8 @@ void TPartitionActor::Handle(TEvPersQueue::TEvResponse::TPtr& ev, const TActorCo
730
737
731
738
Y_ABORT_UNLESS (DirectRead);
732
739
Y_ABORT_UNLESS (res.GetDirectReadId () == DirectReadId);
740
+ if (!PipeClient)
741
+ return ; // Pipe was already destroyed, direct read session is being restored. Will resend this request afterwards;
733
742
734
743
EndOffset = res.GetEndOffset ();
735
744
SizeLag = res.GetSizeLag ();
@@ -1092,13 +1101,18 @@ bool TPartitionActor::SendNextRestorePrepareOrForget() {
1092
1101
if (shouldForget) {
1093
1102
// We have something to forget from what was already restored; Do NOT change RestoredDirectReadId
1094
1103
DirectReadRestoreStage = EDirectReadRestoreStage::Forget;
1104
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Restore direct read, forget id "
1105
+ << *DirectReadsToForget.begin () << " for partition " << Partition);
1095
1106
SendForgetDirectRead (*DirectReadsToForget.begin (), ctx);
1096
1107
return true ;
1097
1108
} else {
1098
- LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Resend prepare direct read id " << prepareId << " for partition " << Partition);
1109
+ auto & dr = DirectReadsToRestore.begin ()->second ;
1110
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Resend prepare direct read id " << prepareId
1111
+ << " (internal id: " << dr.GetDirectReadId () << " ) for partition " << Partition);
1099
1112
Y_ABORT_UNLESS (prepareId != 0 );
1113
+
1100
1114
// Restore;
1101
- auto & dr = DirectReadsToRestore. begin ()-> second ;
1115
+ Y_ABORT_UNLESS (prepareId == dr. GetDirectReadId ()) ;
1102
1116
1103
1117
Y_ABORT_UNLESS (RestoredDirectReadId < dr.GetDirectReadId ());
1104
1118
RestoredDirectReadId = dr.GetDirectReadId ();
@@ -1125,8 +1139,8 @@ bool TPartitionActor::SendNextRestorePublishRequest() {
1125
1139
return false ;
1126
1140
}
1127
1141
auto id = *DirectReadsToPublish.begin ();
1128
- LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " " << Partition
1129
- << " Resend publish direct read on restore, id: " << id );
1142
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " Resend publish direct read on restore, id: "
1143
+ << id << " for partition " << Partition );
1130
1144
1131
1145
Y_ABORT_UNLESS (RestoredDirectReadId == id);
1132
1146
DirectReadRestoreStage = EDirectReadRestoreStage::Publish;
@@ -1298,7 +1312,6 @@ void TPartitionActor::Handle(TEvPQProxy::TEvRead::TPtr& ev, const TActorContext&
1298
1312
1299
1313
Y_ABORT_UNLESS (ReadGuid.empty ());
1300
1314
Y_ABORT_UNLESS (!RequestInfly);
1301
- Y_ABORT_UNLESS (DirectReadRestoreStage == EDirectReadRestoreStage::None);
1302
1315
1303
1316
ReadGuid = ev->Get ()->Guid ;
1304
1317
@@ -1311,6 +1324,12 @@ void TPartitionActor::Handle(TEvPQProxy::TEvRead::TPtr& ev, const TActorContext&
1311
1324
if (!PipeClient) // Pipe will be recreated soon
1312
1325
return ;
1313
1326
1327
+ if (DirectReadRestoreStage != EDirectReadRestoreStage::None) {
1328
+ LOG_DEBUG_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " READ FROM " << Partition
1329
+ << " store this request utill direct read is restored" );
1330
+ return ;
1331
+ }
1332
+
1314
1333
TAutoPtr<TEvPersQueue::TEvRequest> event (new TEvPersQueue::TEvRequest);
1315
1334
event->Record .Swap (&request);
1316
1335
0 commit comments