aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkomels <komels@ydb.tech>2022-12-23 13:09:24 +0300
committerkomels <komels@ydb.tech>2022-12-23 13:09:24 +0300
commitb893c2ff24033721dd21a2f4d50b9830bb911d0c (patch)
tree4f74b2094a8b2a45fb68618f0f70491075e0c736
parentc70e9bd2cc0dae340be5089063ae505f73121172 (diff)
downloadydb-b893c2ff24033721dd21a2f4d50b9830bb911d0c.tar.gz
Fix PQ Allocate
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp6
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_impl.cpp4
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_impl.h2
-rw-r--r--ydb/core/tx/schemeshard/ut_allocate_pq.cpp22
-rw-r--r--ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp14
-rw-r--r--ydb/core/tx/schemeshard/ut_helpers/ls_checks.h1
6 files changed, 39 insertions, 10 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp
index b19de1dddd2..c68b584dc27 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_allocate_pq.cpp
@@ -165,7 +165,7 @@ public:
return result;
}
- pqGroupInfo->AlterVersion = allocateDesc.GetAlterVersion();
+ pqGroupInfo->AlterVersion = allocateDesc.GetAlterVersion() + 1;
if (!allocateDesc.HasPQTabletConfig()) {
auto errStr = TStringBuilder() << "No PQTabletConfig specified";
@@ -411,6 +411,8 @@ public:
context.SS->PersQueueGroups[pathId] = emptyGroup;
context.SS->PersQueueGroups[pathId]->AlterData = pqGroupInfo;
+ context.SS->PersQueueGroups[pathId]->AlterVersion = pqGroupInfo->AlterVersion;
+
context.SS->IncrementPathDbRefCount(pathId);
context.SS->PersistPersQueueGroup(db, pathId, emptyGroup);
@@ -457,7 +459,7 @@ public:
context.SS->ClearDescribePathCaches(parentPath.Base());
context.OnComplete.PublishToSchemeBoard(OperationId, parentPath.Base()->PathId);
- context.SS->ClearDescribePathCaches(dstPath.Base());
+ context.SS->ClearDescribePathCaches(dstPath.Base(), true);
context.OnComplete.PublishToSchemeBoard(OperationId, dstPath.Base()->PathId);
dstPath.DomainInfo()->IncPathsInside();
diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.cpp b/ydb/core/tx/schemeshard/schemeshard_impl.cpp
index 614612a387d..9effda381a4 100644
--- a/ydb/core/tx/schemeshard/schemeshard_impl.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard_impl.cpp
@@ -491,10 +491,10 @@ bool TSchemeShard::ApplyStorageConfig(
return true;
}
-void TSchemeShard::ClearDescribePathCaches(const TPathElement::TPtr node) {
+void TSchemeShard::ClearDescribePathCaches(const TPathElement::TPtr node, bool force) {
Y_VERIFY(node);
- if (node->Dropped() || !node->IsCreateFinished()) {
+ if ((node->Dropped() || !node->IsCreateFinished()) && !force) {
return;
}
diff --git a/ydb/core/tx/schemeshard/schemeshard_impl.h b/ydb/core/tx/schemeshard/schemeshard_impl.h
index 54953898eeb..4c544e9a02d 100644
--- a/ydb/core/tx/schemeshard/schemeshard_impl.h
+++ b/ydb/core/tx/schemeshard/schemeshard_impl.h
@@ -483,7 +483,7 @@ public:
static bool ResolveChannelsDetailsAsIs(ui32 /*profileId*/, const TChannelProfiles::TProfile& profile, const TStoragePools& storagePools, TChannelsBindings& channelsBinding);
static bool TabletResolveChannelsDetails(ui32 profileId, const TChannelProfiles::TProfile& profile, const TStoragePools& storagePools, TChannelsBindings& channelsBinding);
- void ClearDescribePathCaches(const TPathElement::TPtr node);
+ void ClearDescribePathCaches(const TPathElement::TPtr node, bool force = false);
TString PathToString(TPathElement::TPtr item);
NKikimrSchemeOp::TPathVersion GetPathVersion(const TPath& pathEl) const;
ui64 GetAliveChildren(TPathElement::TPtr pathEl, const std::optional<TPathElement::EPathType>& type = std::nullopt) const;
diff --git a/ydb/core/tx/schemeshard/ut_allocate_pq.cpp b/ydb/core/tx/schemeshard/ut_allocate_pq.cpp
index 4d7647a5b16..6db54cb71fa 100644
--- a/ydb/core/tx/schemeshard/ut_allocate_pq.cpp
+++ b/ydb/core/tx/schemeshard/ut_allocate_pq.cpp
@@ -24,21 +24,33 @@ Y_UNIT_TEST_SUITE(TSchemeShardAllocatePQTest) {
TestMkDir(runtime, ++txId, "/MyRoot", "DirA");
TestCreatePQGroup(runtime, ++txId, "/MyRoot/DirA",
"Name: \"PQGroup\""
- "TotalGroupCount: 10 "
+ "TotalGroupCount: 9 "
"PartitionPerTablet: 4 "
"PQTabletConfig: {PartitionConfig { LifetimeSeconds : 10}}");
env.TestWaitNotification(runtime, {txId-1, txId});
+ TestAlterPQGroup(runtime, ++txId, "/MyRoot/DirA",
+ "Name: \"PQGroup\""
+ "TotalGroupCount: 10 "
+ "PartitionPerTablet: 4 "
+ "PQTabletConfig: {PartitionConfig { LifetimeSeconds : 10}}");
+
+ env.TestWaitNotification(runtime, {txId-1, txId});
+
TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA"),
{NLs::Finished,
NLs::PathsInsideDomain(2),
NLs::ShardsInsideDomain(4)});
- TestDescribeResult(DescribePath(runtime, "/MyRoot/DirA/PQGroup", true),
- {NLs::CheckPartCount("PQGroup", 10, 4, 3, 10)});
+
+ TestDescribeResult(
+ DescribePath(runtime, "/MyRoot/DirA/PQGroup", true),
+ {NLs::CheckPartCount("PQGroup", 10, 4, 3, 10, NKikimrSchemeOp::EPathState::EPathStateNoChanges),
+ NLs::CheckPQAlterVersion("PQGroup", 2)}
+ );
{
auto balancerDescr = GetDescibeFromPQBalancer(runtime, 9437197);
- TString expected = R"(TopicName: "PQGroup" Version: 0 Config { PartitionConfig { LifetimeSeconds: 10 } YdbDatabasePath: "/MyRoot" } PartitionPerTablet: 4 Partitions { Partition: 0 TabletId: 9437194 } Partitions { Partition: 1 TabletId: 9437194 } Partitions { Partition: 2 TabletId: 9437195 } Partitions { Partition: 3 TabletId: 9437194 } Partitions { Partition: 4 TabletId: 9437196 } Partitions { Partition: 5 TabletId: 9437195 } Partitions { Partition: 6 TabletId: 9437194 } Partitions { Partition: 7 TabletId: 9437196 } Partitions { Partition: 8 TabletId: 9437195 } Partitions { Partition: 9 TabletId: 9437195 } SchemeShardId: 8751008 BalancerTabletId: 9437197 SecurityObject: "\022\000")";
+ TString expected = R"(TopicName: "PQGroup" Version: 2 Config { PartitionConfig { LifetimeSeconds: 10 } YdbDatabasePath: "/MyRoot" } PartitionPerTablet: 4 Partitions { Partition: 0 TabletId: 9437194 } Partitions { Partition: 1 TabletId: 9437194 } Partitions { Partition: 2 TabletId: 9437195 } Partitions { Partition: 3 TabletId: 9437194 } Partitions { Partition: 4 TabletId: 9437196 } Partitions { Partition: 5 TabletId: 9437195 } Partitions { Partition: 6 TabletId: 9437194 } Partitions { Partition: 7 TabletId: 9437195 } Partitions { Partition: 8 TabletId: 9437195 } Partitions { Partition: 9 TabletId: 9437196 } SchemeShardId: 8751008 BalancerTabletId: 9437197 SecurityObject: "\022\000")";
UNIT_ASSERT_NO_DIFF(expected, balancerDescr.ShortUtf8DebugString());
}
@@ -99,7 +111,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardAllocatePQTest) {
{
auto balancerDescr = GetDescibeFromPQBalancer(runtime, 9437197);
- TString expected = R"(TopicName: "PQGroup" Version: 1 Config { PartitionConfig { LifetimeSeconds: 10 } YdbDatabasePath: "/MyRoot/Database" } PartitionPerTablet: 4 Partitions { Partition: 0 TabletId: 9437194 } Partitions { Partition: 1 TabletId: 9437194 } Partitions { Partition: 2 TabletId: 9437195 } Partitions { Partition: 3 TabletId: 9437194 } Partitions { Partition: 4 TabletId: 9437196 } Partitions { Partition: 5 TabletId: 9437195 } Partitions { Partition: 6 TabletId: 9437194 } Partitions { Partition: 7 TabletId: 9437196 } Partitions { Partition: 8 TabletId: 9437195 } Partitions { Partition: 9 TabletId: 9437195 } SchemeShardId: 9437198 BalancerTabletId: 9437197 SecurityObject: "\022\000")";
+ TString expected = R"(TopicName: "PQGroup" Version: 3 Config { PartitionConfig { LifetimeSeconds: 10 } YdbDatabasePath: "/MyRoot/Database" } PartitionPerTablet: 4 Partitions { Partition: 0 TabletId: 9437194 } Partitions { Partition: 1 TabletId: 9437194 } Partitions { Partition: 2 TabletId: 9437195 } Partitions { Partition: 3 TabletId: 9437194 } Partitions { Partition: 4 TabletId: 9437196 } Partitions { Partition: 5 TabletId: 9437195 } Partitions { Partition: 6 TabletId: 9437194 } Partitions { Partition: 7 TabletId: 9437195 } Partitions { Partition: 8 TabletId: 9437195 } Partitions { Partition: 9 TabletId: 9437196 } SchemeShardId: 9437198 BalancerTabletId: 9437197 SecurityObject: "\022\000")";
UNIT_ASSERT_NO_DIFF(expected, balancerDescr.ShortUtf8DebugString());
}
diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp
index 2b00a872c9e..4699f09e350 100644
--- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp
+++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.cpp
@@ -502,6 +502,20 @@ TCheckFunc CheckPartCount(const TString& name, ui32 partCount, ui32 maxParts, ui
};
}
+TCheckFunc CheckPQAlterVersion (const TString& name, ui64 alterVersion) {
+ return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) {
+ UNIT_ASSERT(record.HasPathDescription());
+ NKikimrSchemeOp::TPathDescription descr = record.GetPathDescription();
+
+ UNIT_ASSERT(descr.HasSelf());
+ auto self = descr.GetSelf();
+ UNIT_ASSERT(self.HasCreateFinished());
+ UNIT_ASSERT_STRINGS_EQUAL(self.GetName(), name);
+ UNIT_ASSERT(descr.HasPersQueueGroup());
+ UNIT_ASSERT_VALUES_EQUAL(descr.GetPersQueueGroup().GetAlterVersion(), alterVersion);
+ };
+}
+
TCheckFunc PathVersionEqual(ui64 version) {
return [=] (const NKikimrScheme::TEvDescribeSchemeResult& record) {
UNIT_ASSERT_VALUES_EQUAL(record.GetStatus(), NKikimrScheme::StatusSuccess);
diff --git a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h
index a4ca194b3a8..f4379b7c0ae 100644
--- a/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h
+++ b/ydb/core/tx/schemeshard/ut_helpers/ls_checks.h
@@ -112,6 +112,7 @@ namespace NLs {
TCheckFunc CheckPartCount(const TString& name, ui32 partCount, ui32 maxParts, ui32 tabletCount, ui32 groupCount,
NKikimrSchemeOp::EPathState pathState = NKikimrSchemeOp::EPathState::EPathStateNoChanges);
+ TCheckFunc CheckPQAlterVersion (const TString& name, ui64 alterVersion);
TCheckFunc IndexesCount(ui32 count);
TCheckFunc IndexType(NKikimrSchemeOp::EIndexType type);