mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
fix level sorting
This commit is contained in:
parent
13e82d6439
commit
9c185374e4
@ -613,13 +613,15 @@ public:
|
|||||||
|
|
||||||
struct PathCmp
|
struct PathCmp
|
||||||
{
|
{
|
||||||
using is_transparent = std::true_type;
|
|
||||||
|
|
||||||
auto operator()(const std::string_view a,
|
auto operator()(const std::string_view a,
|
||||||
const std::string_view b) const
|
const std::string_view b) const
|
||||||
{
|
{
|
||||||
return a.size() < b.size() || (a.size() == b.size() && a < b);
|
size_t level_a = std::count(a.begin(), a.end(), '/');
|
||||||
|
size_t level_b = std::count(b.begin(), b.end(), '/');
|
||||||
|
return level_a < level_b || (level_a == level_b && a < b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using is_transparent = void; // required to make find() work with different type than key_type
|
||||||
};
|
};
|
||||||
|
|
||||||
mutable std::map<std::string, UncommittedNode, PathCmp> nodes;
|
mutable std::map<std::string, UncommittedNode, PathCmp> nodes;
|
||||||
|
@ -3778,6 +3778,32 @@ TYPED_TEST(CoordinationTest, TestRemoveRecursiveInMultiRequest)
|
|||||||
ASSERT_FALSE(exists("/A/B"));
|
ASSERT_FALSE(exists("/A/B"));
|
||||||
ASSERT_FALSE(exists("/A/B/D"));
|
ASSERT_FALSE(exists("/A/B/D"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SCOPED_TRACE("[BUG] Recursive Remove Level Sorting");
|
||||||
|
int new_zxid = ++zxid;
|
||||||
|
|
||||||
|
Coordination::Requests ops = {
|
||||||
|
zkutil::makeCreateRequest("/a", "", zkutil::CreateMode::Persistent),
|
||||||
|
zkutil::makeCreateRequest("/a/bbbbbb", "", zkutil::CreateMode::Persistent),
|
||||||
|
zkutil::makeCreateRequest("/A", "", zkutil::CreateMode::Persistent),
|
||||||
|
zkutil::makeCreateRequest("/A/B", "", zkutil::CreateMode::Persistent),
|
||||||
|
zkutil::makeCreateRequest("/A/CCCCCCCCCCCC", "", zkutil::CreateMode::Persistent),
|
||||||
|
zkutil::makeRemoveRecursiveRequest("/A", 3),
|
||||||
|
};
|
||||||
|
auto remove_request = std::make_shared<ZooKeeperMultiRequest>(ops, ACLs{});
|
||||||
|
storage.preprocessRequest(remove_request, 1, 0, new_zxid);
|
||||||
|
auto remove_responses = storage.processRequest(remove_request, 1, new_zxid);
|
||||||
|
|
||||||
|
ASSERT_EQ(remove_responses.size(), 1);
|
||||||
|
ASSERT_TRUE(is_multi_ok(remove_responses[0].response));
|
||||||
|
ASSERT_TRUE(exists("/a"));
|
||||||
|
ASSERT_TRUE(exists("/a/bbbbbb"));
|
||||||
|
ASSERT_FALSE(exists("/A"));
|
||||||
|
ASSERT_FALSE(exists("/A/B"));
|
||||||
|
ASSERT_FALSE(exists("/A/CCCCCCCCCCCC"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(CoordinationTest, TestRemoveRecursiveWatches)
|
TYPED_TEST(CoordinationTest, TestRemoveRecursiveWatches)
|
||||||
|
Loading…
Reference in New Issue
Block a user