Another fix

This commit is contained in:
Antonio Andelic 2024-02-08 13:52:46 +01:00
parent 33f12c9f35
commit dfb3a8f7be
4 changed files with 20 additions and 16 deletions

View File

@ -89,11 +89,10 @@ namespace
writeBinary(node.ephemeralOwner(), out);
if (version < SnapshotVersion::V6)
writeBinary(static_cast<int32_t>(node.data_size), out);
const bool is_ephemeral = node.isEphemeral();
writeBinary(is_ephemeral ? 0 : node.numChildren(), out);
writeBinary(node.numChildren(), out);
writeBinary(node.pzxid, out);
writeBinary(is_ephemeral ? 0 : node.seqNum(), out);
writeBinary(node.seqNum(), out);
if (version >= SnapshotVersion::V4 && version <= SnapshotVersion::V5)
writeBinary(node.sizeInBytes(), out);

View File

@ -185,9 +185,8 @@ uint64_t calculateDigest(std::string_view path, const KeeperStorage::Node & node
hash.update(node.version);
hash.update(node.cversion);
hash.update(node.aversion);
bool is_ephemeral = node.isEphemeral();
hash.update(is_ephemeral ? node.ephemeralOwner() : 0);
hash.update(is_ephemeral ? 0 : node.numChildren());
hash.update(node.ephemeralOwner());
hash.update(node.numChildren());
hash.update(node.pzxid);
return hash.get64();
@ -223,6 +222,9 @@ KeeperStorage::Node & KeeperStorage::Node::operator=(const Node & other)
data = new char[data_size];
memcpy(data, other.data, data_size);
}
children = other.children;
return *this;
}
@ -252,7 +254,7 @@ void KeeperStorage::Node::copyStats(const Coordination::Stat & stat)
if (stat.ephemeralOwner == 0)
{
is_ephemeral_and_mtime.is_ephemeral = false;
ephemeral_or_children_data.children_info.num_children = stat.numChildren;
setNumChildren(stat.numChildren);
}
else
{
@ -269,10 +271,9 @@ void KeeperStorage::Node::setResponseStat(Coordination::Stat & response_stat) co
response_stat.version = version;
response_stat.cversion = cversion;
response_stat.aversion = aversion;
bool is_ephemeral = isEphemeral();
response_stat.ephemeralOwner = is_ephemeral ? ephemeral_or_children_data.ephemeral_owner : 0;
response_stat.ephemeralOwner = ephemeralOwner();
response_stat.dataLength = static_cast<int32_t>(data_size);
response_stat.numChildren = is_ephemeral ? 0 : numChildren();
response_stat.numChildren = numChildren();
response_stat.pzxid = pzxid;
}
@ -1316,7 +1317,7 @@ struct KeeperStorageRemoveRequestProcessor final : public KeeperStorageRequestPr
KeeperStorage::UpdateNodeDelta{[](KeeperStorage::Node & parent)
{
++parent.cversion;
--parent.ephemeral_or_children_data.children_info.num_children;
parent.decreaseNumChildren();
}});
new_deltas.emplace_back(request.path, zxid, KeeperStorage::RemoveNodeDelta{request.version, node->ephemeralOwner()});
@ -1561,9 +1562,7 @@ struct KeeperStorageListRequestProcessor final : public KeeperStorageRequestProc
auto list_request_type = ALL;
if (auto * filtered_list = dynamic_cast<Coordination::ZooKeeperFilteredListRequest *>(&request))
{
list_request_type = filtered_list->list_request_type;
}
if (list_request_type == ALL)
return true;
@ -2294,7 +2293,7 @@ void KeeperStorage::preprocessRequest(
[ephemeral_path](Node & parent)
{
++parent.cversion;
--parent.ephemeral_or_children_data.children_info.num_children;
parent.decreaseNumChildren();
}
}
);

View File

@ -90,12 +90,13 @@ public:
{
if (isEphemeral())
return ephemeral_or_children_data.ephemeral_owner;
return 0;
}
void setEphemeralOwner(int64_t ephemeral_owner)
{
is_ephemeral_and_mtime.is_ephemeral = true;
is_ephemeral_and_mtime.is_ephemeral = ephemeral_owner != 0;
ephemeral_or_children_data.ephemeral_owner = ephemeral_owner;
}
@ -118,6 +119,12 @@ public:
++ephemeral_or_children_data.children_info.num_children;
}
void decreaseNumChildren()
{
chassert(!isEphemeral());
--ephemeral_or_children_data.children_info.num_children;
}
int32_t seqNum() const
{
if (isEphemeral())

View File

@ -455,7 +455,6 @@ Coordination::ZooKeeperRequestPtr CreateRequestGenerator::generateImpl(const Coo
auto request = std::make_shared<ZooKeeperCreateRequest>();
request->acls = acls;
request->is_sequential = true;
std::string path_candidate = std::filesystem::path(parent_path.getPath()) / name.getString();