Skip to content

Commit ed9142d

Browse files
The request should contain only known partitions (#20547) (#20567)
2 parents efdee79 + 6612bd5 commit ed9142d

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ydb/core/kqp/topics/kqp_topics.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ ui64 TTopicPartitionOperations::GetTabletId() const
219219
return *TabletId_;
220220
}
221221

222+
bool TTopicPartitionOperations::HasTabletId() const
223+
{
224+
return TabletId_.Defined();
225+
}
226+
222227
void TTopicPartitionOperations::SetTabletId(ui64 value)
223228
{
224229
Y_ABORT_UNLESS(TabletId_.Empty());
@@ -424,6 +429,17 @@ bool TTopicOperations::ProcessSchemeCacheNavigate(const NSchemeCache::TSchemeCac
424429
}
425430
}
426431

432+
for (const auto& [key, operations] : Operations_) {
433+
if (!operations.HasTabletId()) {
434+
builder << "Topic '" << key.Topic_ << "'. Unknown partition " << key.Partition_;
435+
436+
status = Ydb::StatusIds::SCHEME_ERROR;
437+
message = std::move(builder);
438+
439+
return false;
440+
}
441+
}
442+
427443
status = Ydb::StatusIds::SUCCESS;
428444
message = "";
429445

ydb/core/kqp/topics/kqp_topics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class TTopicPartitionOperations {
9191

9292
void SetTabletId(ui64 value);
9393
ui64 GetTabletId() const;
94+
bool HasTabletId() const;
9495

9596
TMaybe<TString> GetTopicName() const;
9697

ydb/services/persqueue_v1/ut/topic_service_ut.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,20 @@ Y_UNIT_TEST_F(UnknownTopic, TUpdateOffsetsInTransactionFixture) {
311311
UNIT_ASSERT_VALUES_EQUAL(response.operation().status(), Ydb::StatusIds::SCHEME_ERROR);
312312
}
313313

314+
Y_UNIT_TEST_F(UnknownPartition, TUpdateOffsetsInTransactionFixture) {
315+
auto response = Call_UpdateOffsetsInTransaction({
316+
TTopic{.Path=VALID_TOPIC_PATH, .Partitions={
317+
TPartition{.Id=1000, .Offsets={
318+
TOffsetRange{.Begin=0, .End=2}
319+
}},
320+
TPartition{.Id=2000, .Offsets={
321+
TOffsetRange{.Begin=1, .End=2}
322+
}}
323+
}}
324+
});
325+
UNIT_ASSERT_VALUES_EQUAL(response.operation().status(), Ydb::StatusIds::SCHEME_ERROR);
326+
}
327+
314328
Y_UNIT_TEST_F(UseDoubleSlashInTopicPath, TUpdateOffsetsInTransactionFixture) {
315329
TestTopicPaths("//Root//PQ//rt3.dc1--topic1", "/Root/PQ/rt3.dc1--topic1");
316330
}

0 commit comments

Comments
 (0)