@@ -24,9 +24,20 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
24
24
UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::SUCCESS, result.GetIssues ().ToString ());
25
25
}
26
26
27
- void ExecuteDataQuery (NYdb::NTable::TSession& session, const TString& query ) {
28
- const auto result = session.ExecuteDataQuery (query, NYdb::NTable::TTxControl::BeginTx ().CommitTx ()).GetValueSync ();
29
- UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::SUCCESS, result.GetIssues ().ToString ());
27
+ void ExecuteDataQuery (NYdb::NTable::TSession& session, const TString& query) {
28
+ TString error;
29
+ for (size_t i = 0 ; i < 20 ; ++i) {
30
+ const auto result = session.ExecuteDataQuery (query, NYdb::NTable::TTxControl::BeginTx ().CommitTx ()).GetValueSync ();
31
+ if (NYdb::EStatus::SUCCESS != result.GetStatus ()) {
32
+ error = result.GetIssues ().ToString ();
33
+ Sleep (TDuration::MilliSeconds (500 ));
34
+ continue ;
35
+ }
36
+ UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), NYdb::EStatus::SUCCESS, result.GetIssues ().ToString ());
37
+ return ;
38
+ }
39
+
40
+ UNIT_ASSERT_C (false , " ExecuteDataQuery error: " << error);
30
41
}
31
42
32
43
ui64 GetBalancerTabletId (TTopicSdkTestSetup& setup, const TString& topicPath) {
@@ -68,6 +79,8 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
68
79
69
80
size_t count = 0 ;
70
81
82
+ std::set<ui32> partitions;
83
+
71
84
auto reader = client.CreateReadSession (
72
85
TReadSessionSettings ()
73
86
.AutoPartitioningSupport (true )
@@ -78,6 +91,7 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
78
91
if (auto * x = std::get_if<NYdb::NTopic::TReadSessionEvent::TDataReceivedEvent>(&event)) {
79
92
count += x->GetMessages ().size ();
80
93
} else if (auto * x = std::get_if<NYdb::NTopic::TReadSessionEvent::TStartPartitionSessionEvent>(&event)) {
94
+ partitions.insert (x->GetPartitionSession ()->GetPartitionId ());
81
95
x->Confirm ();
82
96
Cerr << " >>>>> " << x->DebugString () << Endl << Flush;
83
97
} else if (auto * x = std::get_if<NYdb::NTopic::TReadSessionEvent::TCommitOffsetAcknowledgementEvent>(&event)) {
@@ -105,6 +119,8 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
105
119
}
106
120
107
121
UNIT_ASSERT_VALUES_EQUAL (expected, count);
122
+ UNIT_ASSERT_C (partitions.size () > 1 , " Split must be happened" );
123
+ Cerr << " >>>>> Partition count: " << partitions.size () << Endl << Flush;
108
124
}
109
125
110
126
Y_UNIT_TEST (CDC_Write) {
@@ -121,9 +137,12 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
121
137
value Text,
122
138
PRIMARY KEY (id, order)
123
139
) WITH (
124
- AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 64,
140
+ AUTO_PARTITIONING_BY_SIZE = ENABLED,
141
+ AUTO_PARTITIONING_PARTITION_SIZE_MB = 5,
142
+ AUTO_PARTITIONING_BY_LOAD = ENABLED,
143
+ AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 1,
125
144
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 64,
126
- UNIFORM_PARTITIONS = 64
145
+ UNIFORM_PARTITIONS = 1
127
146
);
128
147
)" );
129
148
@@ -134,7 +153,8 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
134
153
MODE = 'UPDATES',
135
154
FORMAT = 'JSON',
136
155
TOPIC_AUTO_PARTITIONING = 'ENABLED',
137
- TOPIC_MIN_ACTIVE_PARTITIONS = 2
156
+ TOPIC_MIN_ACTIVE_PARTITIONS = 1,
157
+ TOPIC_MAX_ACTIVE_PARTITIONS = 100
138
158
);
139
159
)" );
140
160
@@ -143,10 +163,10 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
143
163
alterSettings
144
164
.BeginAlterPartitioningSettings ()
145
165
.MinActivePartitions (1 )
146
- .MaxActivePartitions (10000 )
166
+ .MaxActivePartitions (100 )
147
167
.BeginAlterAutoPartitioningSettings ()
148
168
.Strategy (EAutoPartitioningStrategy::ScaleUp)
149
- .StabilizationWindow (TDuration::Seconds (1 ))
169
+ .StabilizationWindow (TDuration::Seconds (15 ))
150
170
.DownUtilizationPercent (1 )
151
171
.UpUtilizationPercent (2 )
152
172
.EndAlterAutoPartitioningSettings ()
@@ -162,23 +182,25 @@ Y_UNIT_TEST_SUITE(SlowTopicAutopartitioning) {
162
182
}
163
183
164
184
Cerr << " >>>>> " << TInstant::Now () << " Start table insert" << Endl << Flush;
165
- ExecuteDataQuery (session, R"(
166
- --!syntax_v1
167
- $sample = AsList(
168
- AsStruct(ListFromRange(0, 150000) AS v)
169
- );
185
+ for (size_t i = 0 ; i < 50 ; ++i) {
186
+ ExecuteDataQuery (session, R"(
187
+ --!syntax_v1
188
+ $sample = AsList(
189
+ AsStruct(ListFromRange(0, 5000) AS v)
190
+ );
170
191
171
- UPSERT INTO `/Root/origin` (id, order, value)
172
- SELECT
173
- RandomNumber(v) AS id,
174
- v AS order,
175
- CAST('0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF' AS Utf8?) AS value
176
- FROM as_table($sample)
177
- FLATTEN BY (v);
178
- )" );
192
+ UPSERT INTO `/Root/origin` (id, order, value)
193
+ SELECT
194
+ RandomNumber(v) AS id,
195
+ CAST(v AS Uint64) AS order,
196
+ CAST('0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF' AS Utf8?) AS value
197
+ FROM as_table($sample)
198
+ FLATTEN BY (v);
199
+ )" );
200
+ }
179
201
180
202
Cerr << " >>>>> " << TInstant::Now () << " Start read topic" << Endl << Flush;
181
- AssertMessageCountInTopic (client, " /Root/origin/feed/streamImpl" , 150000 );
203
+ AssertMessageCountInTopic (client, " /Root/origin/feed/streamImpl" , 250000 );
182
204
Cerr << " >>>>> " << TInstant::Now () << " End" << Endl << Flush;
183
205
}
184
206
}
0 commit comments