Skip to content

Commit cced90c

Browse files
The TEvProposePartitionConfig message is sent only to the main partitions (ydb-platform#9599)
1 parent 6c22e9c commit cced90c

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

ydb/core/persqueue/pq_impl.cpp

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class TMonitoringProxy : public TActorBootstrapped<TMonitoringProxy> {
554554
, TabletID(tabletId)
555555
, Inflight(inflight)
556556
{
557-
for (auto& p: Partitions) {
557+
for (auto& p : Partitions) {
558558
Results[p.first].push_back(Sprintf("Partition %u: NO DATA", p.first));
559559
}
560560
}
@@ -691,6 +691,10 @@ void TPersQueue::ApplyNewConfigAndReply(const TActorContext& ctx)
691691
ClearNewConfig();
692692

693693
for (auto& p : Partitions) { //change config for already created partitions
694+
if (p.first.IsSupportivePartition()) {
695+
continue;
696+
}
697+
694698
ctx.Send(p.second.Actor, new TEvPQ::TEvChangePartitionConfig(TopicConverter, Config, BootstrapConfigTx ? *BootstrapConfigTx : NKikimrPQ::TBootstrapConfig()));
695699
}
696700
ChangePartitionConfigInflight += Partitions.size();
@@ -1873,13 +1877,19 @@ void TPersQueue::Handle(TEvPersQueue::TEvOffsets::TPtr& ev, const TActorContext&
18731877
}
18741878
ui32 cnt = 0;
18751879
for (auto& p : Partitions) {
1876-
cnt += p.second.InitDone;
1880+
if (p.first.IsSupportivePartition()) {
1881+
continue;
1882+
}
1883+
1884+
cnt += p.second.InitDone;
18771885
}
18781886
TActorId ans = CreateOffsetsProxyActor(TabletID(), ev->Sender, cnt, ctx);
18791887

18801888
for (auto& p : Partitions) {
1881-
if (!p.second.InitDone)
1889+
if (!p.second.InitDone || p.first.IsSupportivePartition()) {
18821890
continue;
1891+
}
1892+
18831893
THolder<TEvPQ::TEvPartitionOffsets> event = MakeHolder<TEvPQ::TEvPartitionOffsets>(ans, ev->Get()->Record.HasClientId() ?
18841894
ev->Get()->Record.GetClientId() : "");
18851895
ctx.Send(p.second.Actor, event.Release());
@@ -1937,15 +1947,20 @@ void TPersQueue::Handle(TEvPersQueue::TEvStatus::TPtr& ev, const TActorContext&
19371947
}
19381948

19391949
ui32 cnt = 0;
1940-
for (auto& [_, partitionInfo] : Partitions) {
1941-
cnt += partitionInfo.InitDone;
1950+
for (auto& [partitionId, partitionInfo] : Partitions) {
1951+
if (partitionId.IsSupportivePartition()) {
1952+
continue;
1953+
}
1954+
1955+
cnt += partitionInfo.InitDone;
19421956
}
19431957

19441958
TActorId ans = CreateStatusProxyActor(TabletID(), ev->Sender, cnt, ev->Cookie, ctx);
19451959
for (auto& p : Partitions) {
1946-
if (!p.second.InitDone) {
1960+
if (!p.second.InitDone || p.first.IsSupportivePartition()) {
19471961
continue;
19481962
}
1963+
19491964
THolder<TEvPQ::TEvPartitionStatus> event;
19501965
if (ev->Get()->Record.GetConsumers().empty()) {
19511966
event = MakeHolder<TEvPQ::TEvPartitionStatus>(ans, ev->Get()->Record.HasClientId() ? ev->Get()->Record.GetClientId() : "",
@@ -4556,7 +4571,11 @@ void TPersQueue::SendProposeTransactionAbort(const TActorId& target,
45564571
void TPersQueue::SendEvProposePartitionConfig(const TActorContext& ctx,
45574572
TDistributedTransaction& tx)
45584573
{
4559-
for (auto& [_, partition] : Partitions) {
4574+
for (auto& [partitionId, partition] : Partitions) {
4575+
if (partitionId.IsSupportivePartition()) {
4576+
continue;
4577+
}
4578+
45604579
auto event = std::make_unique<TEvPQ::TEvProposePartitionConfig>(tx.Step, tx.TxId);
45614580

45624581
event->TopicConverter = tx.TopicConverter;
@@ -4567,7 +4586,7 @@ void TPersQueue::SendEvProposePartitionConfig(const TActorContext& ctx,
45674586
}
45684587

45694588
tx.PartitionRepliesCount = 0;
4570-
tx.PartitionRepliesExpected = Partitions.size();
4589+
tx.PartitionRepliesExpected = OriginalPartitionsCount;
45714590
}
45724591

45734592
TActorId TPersQueue::GetPartitionQuoter(const TPartitionId& partition) {

ydb/public/sdk/cpp/client/ydb_topic/ut/topic_to_table_ut.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,26 @@ Y_UNIT_TEST_F(WriteToTopic_Demo_38, TFixture)
20232023
WriteMessagesInTx(0, 1);
20242024
}
20252025

2026+
Y_UNIT_TEST_F(WriteToTopic_Demo_39, TFixture)
2027+
{
2028+
CreateTopic("topic_A", TEST_CONSUMER);
2029+
2030+
NTable::TSession tableSession = CreateTableSession();
2031+
NTable::TTransaction tx = BeginTx(tableSession);
2032+
2033+
WriteToTopic("topic_A", TEST_MESSAGE_GROUP_ID, "message #1", &tx);
2034+
WriteToTopic("topic_A", TEST_MESSAGE_GROUP_ID, "message #2", &tx);
2035+
2036+
WaitForAcks("topic_A", TEST_MESSAGE_GROUP_ID);
2037+
2038+
AddConsumer("topic_A", {"consumer"});
2039+
2040+
CommitTx(tx, EStatus::SUCCESS);
2041+
2042+
auto messages = ReadFromTopic("topic_A", "consumer", TDuration::Seconds(2));
2043+
UNIT_ASSERT_VALUES_EQUAL(messages.size(), 2);
2044+
}
2045+
20262046
}
20272047

20282048
}

0 commit comments

Comments
 (0)