Don't update caches with empty zNodes

We found out that we leak some empty znodes that were just ignored by
nodepool before the caching changes. Now that we know that these exist
ignore them as well so we don't get spammed by exceptions.

Change-Id: I00a0ad2c7f645a2d03bd1674bf5d050c38b1dd50
This commit is contained in:
Tobias Henkel 2018-11-30 23:26:19 +01:00
parent 85968314bd
commit 3e675082ba
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
1 changed files with 8 additions and 0 deletions

View File

@ -2113,6 +2113,10 @@ class ZooKeeper(object):
node_id = path.rsplit('/', 1)[1]
if event.event_type in (TreeEvent.NODE_ADDED, TreeEvent.NODE_UPDATED):
# Nodes with empty data are invalid so skip add or update these.
if not event.event_data.data:
return
# Perform an in-place update of the already cached node if possible
d = self._bytesToDict(event.event_data.data)
old_node = self._cached_nodes.get(node_id)
@ -2176,6 +2180,10 @@ class ZooKeeper(object):
request_id = path.rsplit('/', 1)[1]
if event.event_type in (TreeEvent.NODE_ADDED, TreeEvent.NODE_UPDATED):
# Requests with empty data are invalid so skip add or update these.
if not event.event_data.data:
return
# Perform an in-place update of the cached request if possible
d = self._bytesToDict(event.event_data.data)
old_request = self._cached_node_requests.get(request_id)