Skip to content

Commit b58f41e

Browse files
nshestakovgithub-actions[bot]
authored andcommitted
Fixed the deletion of blobs by retention in the supportive partition of the topic (#19901)
1 parent 4ab35c3 commit b58f41e

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

.github/last_commit.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6065f1e3f7655f65b808df9cee77081380d85c3b
1+
693a9330006deec1f2ced3ef39abf3db14e13fc4

src/client/topic/ut/topic_to_table_ut.cpp

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ class TFixture : public NUnitTest::TBaseFixture {
111111
void CreateTopic(const TString& path = TString{TEST_TOPIC},
112112
const TString& consumer = TEST_CONSUMER,
113113
size_t partitionCount = 1,
114-
std::optional<size_t> maxPartitionCount = std::nullopt);
114+
std::optional<size_t> maxPartitionCount = std::nullopt,
115+
const TDuration retention = TDuration::Hours(1),
116+
bool important = false);
115117
TTopicDescription DescribeTopic(const TString& path);
116118

117119
void AddConsumer(const TString& topicPath, const TVector<TString>& consumers);
@@ -862,10 +864,12 @@ void TFixture::WriteMessages(const TVector<TString>& messages,
862864
void TFixture::CreateTopic(const TString& path,
863865
const TString& consumer,
864866
size_t partitionCount,
865-
std::optional<size_t> maxPartitionCount)
867+
std::optional<size_t> maxPartitionCount,
868+
const TDuration retention,
869+
bool important)
866870

867871
{
868-
Setup->CreateTopic(path, consumer, partitionCount, maxPartitionCount);
872+
Setup->CreateTopic(path, consumer, partitionCount, maxPartitionCount, retention, important);
869873
}
870874

871875
void TFixture::AddConsumer(const TString& topicPath,
@@ -4429,6 +4433,56 @@ Y_UNIT_TEST_F(The_Transaction_Starts_On_One_Version_And_Ends_On_The_Other, TFixt
44294433
RestartPQTablet("topic_A", 1);
44304434
}
44314435

4436+
Y_UNIT_TEST_F(TestRetentionOnLongTxAndBigMessages, TFixtureQuery)
4437+
{
4438+
// TODO uncomment
4439+
return;
4440+
4441+
auto bigMessage = []() {
4442+
TStringBuilder sb;
4443+
sb.reserve(10_MB);
4444+
for (size_t i = 0; i < sb.capacity(); ++i) {
4445+
sb << RandomNumber<char>();
4446+
}
4447+
return sb;
4448+
};
4449+
4450+
TString msg = bigMessage();
4451+
4452+
CreateTopic("topic_A", TEST_CONSUMER, 1, 1, TDuration::Seconds(1), true);
4453+
4454+
auto session = CreateSession();
4455+
auto tx0 = session->BeginTx();
4456+
auto tx1 = session->BeginTx();
4457+
4458+
WriteToTopic("topic_A", "grp-0", msg, tx0.get());
4459+
WriteToTopic("topic_A", "grp-1", msg, tx1.get());
4460+
4461+
Sleep(TDuration::Seconds(3));
4462+
4463+
WriteToTopic("topic_A", "grp-0", "short-msg", tx0.get());
4464+
WriteToTopic("topic_A", "grp-1", "short-msg", tx1.get());
4465+
4466+
WriteToTopic("topic_A", "grp-0", msg, tx0.get());
4467+
WriteToTopic("topic_A", "grp-1", msg, tx1.get());
4468+
4469+
Sleep(TDuration::Seconds(3));
4470+
4471+
WriteToTopic("topic_A", "grp-0", msg, tx0.get());
4472+
WriteToTopic("topic_A", "grp-1", msg, tx1.get());
4473+
4474+
Sleep(TDuration::Seconds(3));
4475+
4476+
session->CommitTx(*tx0, EStatus::SUCCESS);
4477+
session->CommitTx(*tx1, EStatus::SUCCESS);
4478+
4479+
//RestartPQTablet("topic_A", 0);
4480+
4481+
auto read = ReadFromTopic("topic_A", TEST_CONSUMER, TDuration::Seconds(2));
4482+
UNIT_ASSERT(read.size() > 0);
4483+
UNIT_ASSERT_EQUAL(msg, read[0]);
4484+
}
4485+
44324486
}
44334487

44344488
}

src/client/topic/ut/ut_utils/topic_sdk_test_setup.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ void TTopicSdkTestSetup::CreateTopicWithAutoscale(const std::string& path, const
2626
CreateTopic(path, consumer, partitionCount, maxPartitionCount);
2727
}
2828

29-
void TTopicSdkTestSetup::CreateTopic(const std::string& path, const std::string& consumer, size_t partitionCount, std::optional<size_t> maxPartitionCount)
29+
void TTopicSdkTestSetup::CreateTopic(const std::string& path, const std::string& consumer, size_t partitionCount, std::optional<size_t> maxPartitionCount, const TDuration retention, bool important)
3030
{
3131
TTopicClient client(MakeDriver());
3232

3333
TCreateTopicSettings topics;
3434
topics
35+
.RetentionPeriod(retention)
3536
.BeginConfigurePartitioningSettings()
3637
.MinActivePartitions(partitionCount)
3738
.MaxActivePartitions(maxPartitionCount.value_or(partitionCount));
@@ -44,6 +45,7 @@ void TTopicSdkTestSetup::CreateTopic(const std::string& path, const std::string&
4445
}
4546

4647
TConsumerSettings<TCreateTopicSettings> consumers(topics, consumer);
48+
consumers.Important(important);
4749
topics.AppendConsumers(consumers);
4850

4951
auto status = client.CreateTopic(path, topics).GetValueSync();

src/client/topic/ut/ut_utils/topic_sdk_test_setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TTopicSdkTestSetup {
1717
TTopicSdkTestSetup(const TString& testCaseName, const NKikimr::Tests::TServerSettings& settings = MakeServerSettings(), bool createTopic = true);
1818

1919
void CreateTopic(const std::string& path = TEST_TOPIC, const std::string& consumer = TEST_CONSUMER, size_t partitionCount = 1,
20-
std::optional<size_t> maxPartitionCount = std::nullopt);
20+
std::optional<size_t> maxPartitionCount = std::nullopt, const TDuration retention = TDuration::Hours(1), bool important = false);
2121
void CreateTopicWithAutoscale(const std::string& path = TEST_TOPIC, const std::string& consumer = TEST_CONSUMER, size_t partitionCount = 1,
2222
size_t maxPartitionCount = 100);
2323

0 commit comments

Comments
 (0)