@@ -122,12 +122,14 @@ void unregisterEphemeralPath(KeeperStorageBase::Ephemerals & ephemerals, int64_t
122122 if (ephemerals_it == ephemerals.end ())
123123 {
124124 if (throw_if_missing)
125- throw Exception (ErrorCodes::LOGICAL_ERROR, " Session {} is missing ephemeral path {} " , session_id, path );
125+ throw Exception (ErrorCodes::LOGICAL_ERROR, " Session {} is expected to have ephemeral paths but no path is registered " , session_id);
126126
127127 return ;
128128 }
129129
130- ephemerals_it->second .erase (path);
130+ if (auto erased = ephemerals_it->second .erase (path); !erased && throw_if_missing)
131+ throw Exception (ErrorCodes::LOGICAL_ERROR, " Session {} is missing ephemeral path {}" , session_id, path);
132+
131133 if (ephemerals_it->second .empty ())
132134 ephemerals.erase (ephemerals_it);
133135}
@@ -255,14 +257,9 @@ void NodeStats::copyStats(const Coordination::Stat & stat)
255257 aversion = stat.aversion ;
256258
257259 if (stat.ephemeralOwner == 0 )
258- {
259- is_ephemeral_and_ctime.is_ephemeral = false ;
260260 setNumChildren (stat.numChildren );
261- }
262261 else
263- {
264262 setEphemeralOwner (stat.ephemeralOwner );
265- }
266263}
267264
268265void KeeperRocksNodeInfo::copyStats (const Coordination::Stat & stat)
@@ -1356,6 +1353,7 @@ bool KeeperStorage<Container>::removeNode(const std::string & path, int32_t vers
13561353
13571354 if (prev_node.stats .ephemeralOwner () != 0 )
13581355 {
1356+ chassert (committed_ephemeral_nodes != 0 );
13591357 --committed_ephemeral_nodes;
13601358 std::lock_guard lock (ephemeral_mutex);
13611359 unregisterEphemeralPath (committed_ephemerals, prev_node.stats .ephemeralOwner (), path, /* throw_if_missing=*/ true );
0 commit comments