aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksei Borzenkov <snaury@gmail.com>2022-07-07 09:09:47 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2022-07-07 09:09:47 +0300
commit3c47eabe6e9cdf65794122a0e490e1f0474e7a4f (patch)
treede88f50dd70037e254c860968cca85992c4e2412
parent3bb2246a9a13af2954d27a4313dac8566846c376 (diff)
downloadydb-3c47eabe6e9cdf65794122a0e490e1f0474e7a4f.tar.gz
22-2: Set MinPartitionsCount to initial number of partitions, KIKIMR-1526522.2.47
Merge from trunk: r9676889 REVIEW: 2707530 x-ydb-stable-ref: ff1cf88ef1e33a910effc8920e36c641fd1f21bd
-rw-r--r--ydb/core/client/flat_ut.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp5
-rw-r--r--ydb/core/tx/schemeshard/ut_base.cpp18
-rw-r--r--ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp60
-rw-r--r--ydb/services/ydb/ydb_ut.cpp10
5 files changed, 96 insertions, 0 deletions
diff --git a/ydb/core/client/flat_ut.cpp b/ydb/core/client/flat_ut.cpp
index 362c052aa1..a759ffec02 100644
--- a/ydb/core/client/flat_ut.cpp
+++ b/ydb/core/client/flat_ut.cpp
@@ -1803,6 +1803,9 @@ Y_UNIT_TEST_SUITE(TFlatTest) {
PartitionConfig {
FollowerCount: %d
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
CompactionPolicy {
InMemSizeToSnapshot: 100000
InMemStepsToSnapshot: 2
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp
index 69eb87bd37..4db21b6816 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_table.cpp
@@ -550,6 +550,11 @@ public:
}
schema.MutablePartitionConfig()->CopyFrom(compilationPartitionConfig);
+ if (!schema.GetPartitionConfig().GetPartitioningPolicy().HasMinPartitionsCount()) {
+ // This is the expected partitions count, see below
+ schema.MutablePartitionConfig()->MutablePartitioningPolicy()->SetMinPartitionsCount(shardsToCreate);
+ }
+
const NScheme::TTypeRegistry* typeRegistry = AppData()->TypeRegistry;
const TSchemeLimits& limits = domainInfo->GetSchemeLimits();
TTableInfo::TAlterDataPtr alterData = TTableInfo::CreateAlterData(nullptr, schema, *typeRegistry, limits, *domainInfo, errStr, LocalSequences);
diff --git a/ydb/core/tx/schemeshard/ut_base.cpp b/ydb/core/tx/schemeshard/ut_base.cpp
index a6b201c0d0..83274e827e 100644
--- a/ydb/core/tx/schemeshard/ut_base.cpp
+++ b/ydb/core/tx/schemeshard/ut_base.cpp
@@ -3088,6 +3088,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key"]
UniformPartitionsCount: 3
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
env.TestWaitNotification(runtime, txId);
@@ -3143,6 +3148,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
SplitBoundary { KeyPrefix {
Tuple { Optional { Uint32 : 200 } }
}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
env.TestWaitNotification(runtime, txId);
@@ -3577,6 +3587,9 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
KeyColumnNames: ["key"]
UniformPartitionsCount: 3
PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
CompactionPolicy {
InMemSizeToSnapshot: 4194304
InMemStepsToSnapshot: 300
@@ -3741,6 +3754,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key"]
UniformPartitionsCount: 3
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
env.TestWaitNotification(runtime, txId);
diff --git a/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp b/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp
index 4118f3c01c..c1524ee591 100644
--- a/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp
+++ b/ydb/core/tx/schemeshard/ut_split_merge_reboots.cpp
@@ -37,6 +37,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true),
@@ -120,6 +125,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "B" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "C" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true),
@@ -167,6 +177,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "B" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "C" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true),
@@ -221,6 +236,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "B" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "C" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
TestDescribeResult(DescribePath(runtime, "/MyRoot/Table", true),
@@ -390,6 +410,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "Jack" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
@@ -428,6 +453,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "B" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "C" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
@@ -500,6 +530,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "B" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
@@ -591,6 +626,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
pathVersion = TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"),
@@ -649,6 +689,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
@@ -769,6 +814,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
@@ -860,6 +910,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
Columns { Name: "Value" Type: "Utf8"}
KeyColumnNames: ["key1", "key2"]
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "A" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
@@ -999,6 +1054,11 @@ Y_UNIT_TEST_SUITE(TSchemeShardSplitTestReboots) {
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "AAAA" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "CCCC" } }}}
SplitBoundary { KeyPrefix { Tuple { Optional { Text: "DDDD" } }}}
+ PartitionConfig {
+ PartitioningPolicy {
+ MinPartitionsCount: 0
+ }
+ }
)");
t.TestEnv->TestWaitNotification(runtime, t.TxId);
diff --git a/ydb/services/ydb/ydb_ut.cpp b/ydb/services/ydb/ydb_ut.cpp
index 2d37063079..3f4ac49345 100644
--- a/ydb/services/ydb/ydb_ut.cpp
+++ b/ydb/services/ydb/ydb_ut.cpp
@@ -1268,6 +1268,7 @@ primary_key: "Key"
partitioning_settings {
partitioning_by_size: DISABLED
partitioning_by_load: DISABLED
+ min_partitions_count: 1
}
)___";
UNIT_ASSERT_NO_DIFF(tmp, expected);
@@ -1609,6 +1610,7 @@ indexes {
partitioning_settings {
partitioning_by_size: DISABLED
partitioning_by_load: DISABLED
+ min_partitions_count: 1
}
)___";
UNIT_ASSERT_NO_DIFF(tmp, expected);
@@ -3521,6 +3523,14 @@ void CheckTableSettings(const TKikimrWithGrpcAndRootSchema &server,
UNIT_ASSERT_VALUES_EQUAL(desc.TablePartitionsSize(), 1);
}
+ if (resp.GetPartitionConfig().GetPartitioningPolicy().HasMinPartitionsCount() &&
+ !expected.GetPartitionConfig().GetPartitioningPolicy().HasMinPartitionsCount())
+ {
+ // SchemeShard will set some min partitions count when unspecified by the user
+ expected.MutablePartitionConfig()->MutablePartitioningPolicy()->SetMinPartitionsCount(
+ resp.GetPartitionConfig().GetPartitioningPolicy().GetMinPartitionsCount());
+ }
+
std::vector<const ::google::protobuf::FieldDescriptor*> fields;
auto *reflection = resp.GetReflection();
reflection->ListFields(resp, &fields);