@@ -146,7 +146,7 @@ class TPartitionActor : public NActors::TActorBootstrapped<TPartitionActor> {
146
146
public:
147
147
TPartitionActor (const TActorId& parentId, const TString& clientId, const ui64 cookie, const TString& session, const ui32 generation,
148
148
const ui32 step, const NPersQueue::TTopicConverterPtr& topic, const TString& database, const ui32 partition, const ui64 tabletID,
149
- const TReadSessionActor::TTopicCounters& counters, const TString& clientDC, std::set<NPQ::TPartitionGraph::Node*> parents );
149
+ const TReadSessionActor::TTopicCounters& counters, const TString& clientDC, const TTopicHolder::TPtr& topicHolder );
150
150
~TPartitionActor ();
151
151
152
152
void Bootstrap (const NActors::TActorContext& ctx);
@@ -212,6 +212,7 @@ class TPartitionActor : public NActors::TActorBootstrapped<TPartitionActor> {
212
212
void CommitDone (ui64 cookie, const TActorContext& ctx);
213
213
void SendPartitionReady (const TActorContext& ctx);
214
214
215
+ const std::set<NPQ::TPartitionGraph::Node*>& GetParents () const ;
215
216
private:
216
217
const TActorId ParentId;
217
218
const TString InternalClientId;
@@ -267,7 +268,7 @@ class TPartitionActor : public NActors::TActorBootstrapped<TPartitionActor> {
267
268
bool ReadingFinishedSent;
268
269
269
270
std::unordered_map<ui64, std::shared_ptr<NKikimr::NGRpcProxy::V1::TDistributedCommitHelper>> Kqps;
270
- std::set<NPQ::TPartitionGraph::Node*> Parents ;
271
+ const TTopicHolder::TPtr TopicHolder ;
271
272
};
272
273
273
274
@@ -347,8 +348,8 @@ void TReadSessionActor::Die(const TActorContext& ctx) {
347
348
}
348
349
349
350
for (auto & t : Topics) {
350
- if (t.second . PipeClient )
351
- NTabletPipe::CloseClient (ctx, t.second . PipeClient );
351
+ if (t.second -> PipeClient )
352
+ NTabletPipe::CloseClient (ctx, t.second -> PipeClient );
352
353
}
353
354
LOG_INFO_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " is DEAD" );
354
355
@@ -844,7 +845,7 @@ void TReadSessionActor::RegisterSessions(const TActorContext& ctx) {
844
845
845
846
for (auto & t : Topics) {
846
847
auto & topic = t.first ;
847
- RegisterSession (t.second . PipeClient , topic, ctx);
848
+ RegisterSession (t.second -> PipeClient , topic, ctx);
848
849
NumPartitionsFromTopic[topic] = 0 ;
849
850
}
850
851
}
@@ -978,14 +979,14 @@ void TReadSessionActor::Handle(V1::TEvPQProxy::TEvAuthResultOk::TPtr& ev, const
978
979
979
980
for (auto & [name, t] : ev->Get ()->TopicAndTablets ) {
980
981
auto & topicHolder = Topics[t.TopicNameConverter ->GetInternalName ()];
981
- topicHolder. TabletID = t.TabletID ;
982
- topicHolder. CloudId = t.CloudId ;
983
- topicHolder. DbId = t.DbId ;
984
- topicHolder. DbPath = t.DbPath ;
985
- topicHolder. IsServerless = t.IsServerless ;
986
- topicHolder. FolderId = t.FolderId ;
987
- topicHolder. FullConverter = t.TopicNameConverter ;
988
- topicHolder. PartitionGraph = t.PartitionGraph ;
982
+ topicHolder-> TabletID = t.TabletID ;
983
+ topicHolder-> CloudId = t.CloudId ;
984
+ topicHolder-> DbId = t.DbId ;
985
+ topicHolder-> DbPath = t.DbPath ;
986
+ topicHolder-> IsServerless = t.IsServerless ;
987
+ topicHolder-> FolderId = t.FolderId ;
988
+ topicHolder-> FullConverter = t.TopicNameConverter ;
989
+ topicHolder-> PartitionGraph = t.PartitionGraph ;
989
990
FullPathToConverter[t.TopicNameConverter ->GetPrimaryPath ()] = t.TopicNameConverter ;
990
991
const auto & second = t.TopicNameConverter ->GetSecondaryPath ();
991
992
if (!second.empty ()) {
@@ -999,7 +1000,7 @@ void TReadSessionActor::Handle(V1::TEvPQProxy::TEvAuthResultOk::TPtr& ev, const
999
1000
clientConfig.CheckAliveness = false ;
1000
1001
1001
1002
clientConfig.RetryPolicy = RetryPolicyForPipes;
1002
- t.second . PipeClient = ctx.RegisterWithSameMailbox (NTabletPipe::CreateClient (ctx.SelfID , t.second . TabletID , clientConfig));
1003
+ t.second -> PipeClient = ctx.RegisterWithSameMailbox (NTabletPipe::CreateClient (ctx.SelfID , t.second -> TabletID , clientConfig));
1003
1004
}
1004
1005
1005
1006
RegisterSessions (ctx);
@@ -1014,7 +1015,7 @@ void TReadSessionActor::Handle(V1::TEvPQProxy::TEvAuthResultOk::TPtr& ev, const
1014
1015
NPersQueue::NErrorCode::BAD_REQUEST, ctx);
1015
1016
return ;
1016
1017
}
1017
- it->second . PartitionGraph = t.PartitionGraph ;
1018
+ it->second -> PartitionGraph = t.PartitionGraph ;
1018
1019
}
1019
1020
}
1020
1021
@@ -1054,7 +1055,7 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvLockPartition::TPtr& ev, const T
1054
1055
Y_ABORT_UNLESS (!intName.empty ());
1055
1056
auto jt = Topics.find (intName);
1056
1057
1057
- if (jt == Topics.end () || pipe != jt->second . PipeClient ) { // this is message from old version of pipe
1058
+ if (jt == Topics.end () || pipe != jt->second -> PipeClient ) { // this is message from old version of pipe
1058
1059
LOG_DEBUG_S (
1059
1060
ctx, NKikimrServices::PQ_READ_PROXY,
1060
1061
PQ_LOG_PREFIX << " ignored ev lock for topic = " << converterIter->second ->GetPrintableString ()
@@ -1063,7 +1064,7 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvLockPartition::TPtr& ev, const T
1063
1064
return ;
1064
1065
}
1065
1066
1066
- auto * partitionNode = jt->second . PartitionGraph ->GetPartition (record.GetPartition ());
1067
+ auto * partitionNode = jt->second -> PartitionGraph ->GetPartition (record.GetPartition ());
1067
1068
if (!partitionNode) {
1068
1069
LOG_DEBUG_S (
1069
1070
ctx, NKikimrServices::PQ_READ_PROXY,
@@ -1079,7 +1080,7 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvLockPartition::TPtr& ev, const T
1079
1080
// ToDo[counters]
1080
1081
if (NumPartitionsFromTopic[intName]++ == 0 ) {
1081
1082
if (AppData (ctx)->PQConfig .GetTopicsAreFirstClassCitizen ()) {
1082
- SetupTopicCounters (converterIter->second , jt->second . CloudId , jt->second . DbId , jt->second . DbPath , jt->second . IsServerless , jt->second . FolderId );
1083
+ SetupTopicCounters (converterIter->second , jt->second -> CloudId , jt->second -> DbId , jt->second -> DbPath , jt->second -> IsServerless , jt->second -> FolderId );
1083
1084
} else {
1084
1085
SetupTopicCounters (converterIter->second );
1085
1086
}
@@ -1088,11 +1089,11 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvLockPartition::TPtr& ev, const T
1088
1089
auto it = TopicCounters.find (intName);
1089
1090
Y_ABORT_UNLESS (it != TopicCounters.end ());
1090
1091
1091
- auto database = jt->second . DbPath ;
1092
+ auto database = jt->second -> DbPath ;
1092
1093
IActor* partitionActor = new TPartitionActor (
1093
1094
ctx.SelfID , InternalClientId, Cookie, Session, record.GetGeneration (),
1094
- record.GetStep (), jt->second . FullConverter , database, record.GetPartition (), record.GetTabletId (), it->second ,
1095
- ClientDC, jt->second . PartitionGraph -> GetPartition (record. GetPartition ())-> AllParents
1095
+ record.GetStep (), jt->second -> FullConverter , database, record.GetPartition (), record.GetTabletId (), it->second ,
1096
+ ClientDC, jt->second
1096
1097
);
1097
1098
1098
1099
TActorId actorId = ctx.Register (partitionActor);
@@ -1102,8 +1103,8 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvLockPartition::TPtr& ev, const T
1102
1103
Y_ABORT_UNLESS (record.GetGeneration () > 0 );
1103
1104
// Partitions use clientside name !
1104
1105
auto pp = Partitions.insert ({
1105
- std::make_pair (jt->second . FullConverter ->GetClientsideName (), record.GetPartition ()),
1106
- TPartitionActorInfo{actorId, (((ui64)record.GetGeneration ()) << 32 ) + record.GetStep (), jt->second . FullConverter }
1106
+ std::make_pair (jt->second -> FullConverter ->GetClientsideName (), record.GetPartition ()),
1107
+ TPartitionActorInfo{actorId, (((ui64)record.GetGeneration ()) << 32 ) + record.GetStep (), jt->second -> FullConverter }
1107
1108
});
1108
1109
Y_ABORT_UNLESS (pp.second );
1109
1110
if (SessionsActive) {
@@ -1142,7 +1143,7 @@ void TReadSessionActor::Handle(TEvPQProxy::TEvPartitionStatus::TPtr& ev, const T
1142
1143
Y_ABORT_UNLESS (ClientsideLocksAllowed);
1143
1144
TReadResponse result;
1144
1145
auto lock = result.MutableLock ();
1145
- lock->SetTopic (topicIter->second . FullConverter ->GetClientsideName ());
1146
+ lock->SetTopic (topicIter->second -> FullConverter ->GetClientsideName ());
1146
1147
lock->SetPartition (ev->Get ()->Partition );
1147
1148
lock->SetReadOffset (ev->Get ()->Offset );
1148
1149
lock->SetEndOffset (ev->Get ()->EndOffset );
@@ -1211,7 +1212,7 @@ void TReadSessionActor::Handle(TEvPersQueue::TEvReleasePartition::TPtr& ev, cons
1211
1212
1212
1213
TActorId pipe = ActorIdFromProto (record.GetPipeClient ());
1213
1214
1214
- if (pipe != it->second . PipeClient ) { // this is message from old version of pipe
1215
+ if (pipe != it->second -> PipeClient ) { // this is message from old version of pipe
1215
1216
return ;
1216
1217
}
1217
1218
@@ -1286,14 +1287,14 @@ void TReadSessionActor::InformBalancerAboutRelease(const THashMap<std::pair<TStr
1286
1287
Y_ABORT_UNLESS (jt != Topics.end ());
1287
1288
1288
1289
req.SetSession (Session);
1289
- ActorIdToProto (jt->second . PipeClient , req.MutablePipeClient ());
1290
+ ActorIdToProto (jt->second -> PipeClient , req.MutablePipeClient ());
1290
1291
req.SetClientId (InternalClientId);
1291
1292
req.SetTopic (it->first .first );
1292
1293
req.SetPartition (it->first .second );
1293
1294
1294
1295
LOG_INFO_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " released: " << it->first .first << " :" << it->first .second );
1295
1296
1296
- NTabletPipe::SendData (ctx, jt->second . PipeClient , request.Release ());
1297
+ NTabletPipe::SendData (ctx, jt->second -> PipeClient , request.Release ());
1297
1298
}
1298
1299
1299
1300
@@ -1428,7 +1429,7 @@ bool TReadSessionActor::ProcessReleasePartition(const THashMap<std::pair<TString
1428
1429
1429
1430
bool TReadSessionActor::ProcessBalancerDead (const ui64 tablet, const TActorContext& ctx) {
1430
1431
for (auto & t : Topics) {
1431
- if (t.second . TabletID == tablet) {
1432
+ if (t.second -> TabletID == tablet) {
1432
1433
LOG_INFO_S (ctx, NKikimrServices::PQ_READ_PROXY, PQ_LOG_PREFIX << " balancer for topic " << t.first << " is dead, restarting all from this topic" );
1433
1434
1434
1435
// Drop all partitions from this topic
@@ -1451,14 +1452,14 @@ bool TReadSessionActor::ProcessBalancerDead(const ui64 tablet, const TActorConte
1451
1452
NTabletPipe::TClientConfig clientConfig;
1452
1453
clientConfig.CheckAliveness = false ;
1453
1454
clientConfig.RetryPolicy = RetryPolicyForPipes;
1454
- t.second . PipeClient = ctx.RegisterWithSameMailbox (NTabletPipe::CreateClient (ctx.SelfID , t.second . TabletID , clientConfig));
1455
+ t.second -> PipeClient = ctx.RegisterWithSameMailbox (NTabletPipe::CreateClient (ctx.SelfID , t.second -> TabletID , clientConfig));
1455
1456
if (InitDone) {
1456
1457
if (PipeReconnects) {
1457
1458
++(*PipeReconnects);
1458
1459
++(*Errors);
1459
1460
}
1460
1461
1461
- RegisterSession (t.second . PipeClient , t.first , ctx);
1462
+ RegisterSession (t.second -> PipeClient , t.first , ctx);
1462
1463
}
1463
1464
}
1464
1465
}
@@ -1833,7 +1834,7 @@ void TReadSessionActor::Handle(TEvPQProxy::TEvReadingStarted::TPtr& ev, const TA
1833
1834
}
1834
1835
1835
1836
auto & topic = it->second ;
1836
- NTabletPipe::SendData (ctx, topic. PipeClient , new TEvPersQueue::TEvReadingPartitionStartedRequest (InternalClientId, msg->PartitionId ));
1837
+ NTabletPipe::SendData (ctx, topic-> PipeClient , new TEvPersQueue::TEvReadingPartitionStartedRequest (InternalClientId, msg->PartitionId ));
1837
1838
}
1838
1839
1839
1840
void TReadSessionActor::Handle (TEvPQProxy::TEvReadingFinished::TPtr& ev, const TActorContext& ctx) {
@@ -1845,7 +1846,7 @@ void TReadSessionActor::Handle(TEvPQProxy::TEvReadingFinished::TPtr& ev, const T
1845
1846
}
1846
1847
1847
1848
auto & topic = it->second ;
1848
- NTabletPipe::SendData (ctx, topic. PipeClient , new TEvPersQueue::TEvReadingPartitionFinishedRequest (InternalClientId, msg->PartitionId , false , msg->FirstMessage ));
1849
+ NTabletPipe::SendData (ctx, topic-> PipeClient , new TEvPersQueue::TEvReadingPartitionFinishedRequest (InternalClientId, msg->PartitionId , false , msg->FirstMessage ));
1849
1850
}
1850
1851
1851
1852
@@ -1854,7 +1855,7 @@ void TReadSessionActor::Handle(TEvPQProxy::TEvReadingFinished::TPtr& ev, const T
1854
1855
TPartitionActor::TPartitionActor (
1855
1856
const TActorId& parentId, const TString& internalClientId, const ui64 cookie, const TString& session,
1856
1857
const ui32 generation, const ui32 step, const NPersQueue::TTopicConverterPtr& topic, const TString& database, const ui32 partition,
1857
- const ui64 tabletID, const TReadSessionActor::TTopicCounters& counters, const TString& clientDC, std::set<NPQ::TPartitionGraph::Node*> parents
1858
+ const ui64 tabletID, const TReadSessionActor::TTopicCounters& counters, const TString& clientDC, const TTopicHolder::TPtr& topicHolder
1858
1859
)
1859
1860
: ParentId(parentId)
1860
1861
, InternalClientId(internalClientId)
@@ -1891,7 +1892,7 @@ TPartitionActor::TPartitionActor(
1891
1892
, Counters(counters)
1892
1893
, FirstRead(true )
1893
1894
, ReadingFinishedSent(false )
1894
- , Parents(parents )
1895
+ , TopicHolder(topicHolder )
1895
1896
{
1896
1897
}
1897
1898
@@ -1922,11 +1923,21 @@ void TPartitionActor::CheckRelease(const TActorContext& ctx) {
1922
1923
}
1923
1924
}
1924
1925
1926
+ const std::set<NPQ::TPartitionGraph::Node*>& TPartitionActor::GetParents () const {
1927
+ const auto * partition = TopicHolder->PartitionGraph ->GetPartition (Partition);
1928
+ if (partition) {
1929
+ return partition->AllParents ;
1930
+ }
1931
+
1932
+ static std::set<NPQ::TPartitionGraph::Node*> empty;
1933
+ return empty;
1934
+ }
1925
1935
1926
1936
void TPartitionActor::SendCommit (const ui64 readId, const ui64 offset, const TActorContext& ctx) {
1927
- if (!ClientHasAnyCommits && Parents.size () != 0 ) {
1937
+ const auto & parents = GetParents ();
1938
+ if (!ClientHasAnyCommits && parents.size () != 0 ) {
1928
1939
std::vector<NKikimr::NGRpcProxy::V1::TDistributedCommitHelper::TCommitInfo> commits;
1929
- for (auto & parent: Parents ) {
1940
+ for (auto & parent: parents ) {
1930
1941
NKikimr::NGRpcProxy::V1::TDistributedCommitHelper::TCommitInfo commit {.PartitionId = parent->Id , .Offset = Max<i64 >(), .KillReadSession = false , .OnlyCheckCommitedToFinish = true , .ReadSessionId = Session};
1931
1942
commits.push_back (commit);
1932
1943
}
0 commit comments