Skip to content

The TEvProposePartitionConfig message is sent only to the main partitions #9599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions ydb/core/persqueue/pq_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class TMonitoringProxy : public TActorBootstrapped<TMonitoringProxy> {
, TabletID(tabletId)
, Inflight(inflight)
{
for (auto& p: Partitions) {
for (auto& p : Partitions) {
Results[p.first].push_back(Sprintf("Partition %u: NO DATA", p.first));
}
}
Expand Down Expand Up @@ -691,6 +691,10 @@ void TPersQueue::ApplyNewConfigAndReply(const TActorContext& ctx)
ClearNewConfig();

for (auto& p : Partitions) { //change config for already created partitions
if (p.first.IsSupportivePartition()) {
continue;
}

ctx.Send(p.second.Actor, new TEvPQ::TEvChangePartitionConfig(TopicConverter, Config, BootstrapConfigTx ? *BootstrapConfigTx : NKikimrPQ::TBootstrapConfig()));
}
ChangePartitionConfigInflight += Partitions.size();
Expand Down Expand Up @@ -1871,13 +1875,19 @@ void TPersQueue::Handle(TEvPersQueue::TEvOffsets::TPtr& ev, const TActorContext&
}
ui32 cnt = 0;
for (auto& p : Partitions) {
cnt += p.second.InitDone;
if (p.first.IsSupportivePartition()) {
continue;
}

cnt += p.second.InitDone;
}
TActorId ans = CreateOffsetsProxyActor(TabletID(), ev->Sender, cnt, ctx);

for (auto& p : Partitions) {
if (!p.second.InitDone)
if (!p.second.InitDone || p.first.IsSupportivePartition()) {
continue;
}

THolder<TEvPQ::TEvPartitionOffsets> event = MakeHolder<TEvPQ::TEvPartitionOffsets>(ans, ev->Get()->Record.HasClientId() ?
ev->Get()->Record.GetClientId() : "");
ctx.Send(p.second.Actor, event.Release());
Expand Down Expand Up @@ -1935,15 +1945,20 @@ void TPersQueue::Handle(TEvPersQueue::TEvStatus::TPtr& ev, const TActorContext&
}

ui32 cnt = 0;
for (auto& [_, partitionInfo] : Partitions) {
cnt += partitionInfo.InitDone;
for (auto& [partitionId, partitionInfo] : Partitions) {
if (partitionId.IsSupportivePartition()) {
continue;
}

cnt += partitionInfo.InitDone;
}

TActorId ans = CreateStatusProxyActor(TabletID(), ev->Sender, cnt, ev->Cookie, ctx);
for (auto& p : Partitions) {
if (!p.second.InitDone) {
if (!p.second.InitDone || p.first.IsSupportivePartition()) {
continue;
}

THolder<TEvPQ::TEvPartitionStatus> event;
if (ev->Get()->Record.GetConsumers().empty()) {
event = MakeHolder<TEvPQ::TEvPartitionStatus>(ans, ev->Get()->Record.HasClientId() ? ev->Get()->Record.GetClientId() : "",
Expand Down Expand Up @@ -4554,7 +4569,11 @@ void TPersQueue::SendProposeTransactionAbort(const TActorId& target,
void TPersQueue::SendEvProposePartitionConfig(const TActorContext& ctx,
TDistributedTransaction& tx)
{
for (auto& [_, partition] : Partitions) {
for (auto& [partitionId, partition] : Partitions) {
if (partitionId.IsSupportivePartition()) {
continue;
}

auto event = std::make_unique<TEvPQ::TEvProposePartitionConfig>(tx.Step, tx.TxId);

event->TopicConverter = tx.TopicConverter;
Expand All @@ -4565,7 +4584,7 @@ void TPersQueue::SendEvProposePartitionConfig(const TActorContext& ctx,
}

tx.PartitionRepliesCount = 0;
tx.PartitionRepliesExpected = Partitions.size();
tx.PartitionRepliesExpected = OriginalPartitionsCount;
}

TActorId TPersQueue::GetPartitionQuoter(const TPartitionId& partition) {
Expand Down
21 changes: 21 additions & 0 deletions ydb/public/sdk/cpp/client/ydb_topic/ut/topic_to_table_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void TFixture::SetUp(NUnitTest::TTestContext&)
{
NKikimr::Tests::TServerSettings settings = TTopicSdkTestSetup::MakeServerSettings();
settings.SetEnableTopicServiceTx(true);
settings.SetEnablePQConfigTransactionsAtSchemeShard(true);

Setup = std::make_unique<TTopicSdkTestSetup>(TEST_CASE_NAME, settings);

Expand Down Expand Up @@ -2097,6 +2098,26 @@ Y_UNIT_TEST_F(WriteToTopic_Demo_38, TFixture)
WriteMessagesInTx(0, 1);
}

Y_UNIT_TEST_F(WriteToTopic_Demo_39, TFixture)
{
CreateTopic("topic_A", TEST_CONSUMER);

NTable::TSession tableSession = CreateTableSession();
NTable::TTransaction tx = BeginTx(tableSession);

WriteToTopic("topic_A", TEST_MESSAGE_GROUP_ID, "message #1", &tx);
WriteToTopic("topic_A", TEST_MESSAGE_GROUP_ID, "message #2", &tx);

WaitForAcks("topic_A", TEST_MESSAGE_GROUP_ID);

AddConsumer("topic_A", {"consumer"});

CommitTx(tx, EStatus::SUCCESS);

auto messages = ReadFromTopic("topic_A", "consumer", TDuration::Seconds(2));
UNIT_ASSERT_VALUES_EQUAL(messages.size(), 2);
}

Y_UNIT_TEST_F(ReadRuleGeneration, TFixture)
{
// There was a server
Expand Down
Loading