Don't remove from cache if it wasn't added during rollback

This commit is contained in:
Antonio Andelic 2022-08-30 08:14:53 +00:00
parent 2416ddfae7
commit 21cdb9a500
2 changed files with 13 additions and 9 deletions

View File

@ -463,18 +463,22 @@ void KeeperStorage::UncommittedState::rollback(int64_t rollback_zxid)
delta_it->operation);
auto & path_deltas = deltas_for_path.at(delta_it->path);
assert(path_deltas.back() == &*delta_it);
path_deltas.pop_back();
if (path_deltas.empty())
deltas_for_path.erase(delta_it->path);
if (path_deltas.back() == &*delta_it)
{
path_deltas.pop_back();
if (path_deltas.empty())
deltas_for_path.erase(delta_it->path);
}
}
else if (auto * add_auth = std::get_if<AddAuthDelta>(&delta_it->operation))
{
auto & uncommitted_auth = session_and_auth[add_auth->session_id];
assert(uncommitted_auth.back() == &add_auth->auth_id);
uncommitted_auth.pop_back();
if (uncommitted_auth.empty())
session_and_auth.erase(add_auth->session_id);
if (uncommitted_auth.back() == &add_auth->auth_id)
{
uncommitted_auth.pop_back();
if (uncommitted_auth.empty())
session_and_auth.erase(add_auth->session_id);
}
}
}

View File

@ -263,7 +263,7 @@ public:
std::shared_ptr<Node> tryGetNodeFromStorage(StringRef path) const;
std::unordered_map<int64_t, std::list<const AuthID * >> session_and_auth;
std::unordered_map<int64_t, std::list<const AuthID *>> session_and_auth;
struct UncommittedNode
{