zeopack.py / ClientStorage.py: deadlock on non existent storage

Bug #143357 reported by Bug Importer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ZODB
Incomplete
Medium
Unassigned

Bug Description

Hello,

I try to pack my storages at zeo with the zeopack.py command per cronjob.
Example:
> zeopack.py -h localhost -S 1 -p 9999 -d 30

If I try inadvertently to pack an non existent storage like "2" for example, the
zeopack.py doesn't return an error. Instead of returning an error, it retries to connect the storage over and over again. The script has to be stopped manually. This effect isn't very practical for cron jobs.

Debug results:

> ./zeopack.py -h localhost -S 2 -p 9999 -d 30
------
2005-03-24T11:37:23 INFO(0) ZCS:22023 ClientStorage (pid=22023) created RO/normal for storage: '2'
------
2005-03-24T11:37:23 INFO(0) ZEC:2-None-0 ClientCache: storage='2', size=20971520; file[0]='2-None-0'
------
2005-03-24T11:37:23 INFO(0) ZCS:22023 Testing connection <ManagedConnection ('192.168.3.197', 9999)>
------
2005-03-24T11:37:23 INFO(0) zrpc-conn:localhost:9999 received handshake 'Z201'
------
2005-03-24T11:37:23 INFO(0) ZCS:22023 Server authentication protocol None
------
2005-03-24T11:37:23 ERROR(200) zrpc:22023 CW: error in testConnection (('localhost', 9999))
Traceback (most recent call last):
  File "/usr/lib/zope2.7/lib/python/ZEO/zrpc/client.py", line 482, in test_connection
    self.preferred = self.client.testConnection(self.conn)
  File "/usr/lib/zope2.7/lib/python/ZEO/ClientStorage.py", line 469, in testConnection
    stub.register(str(self._storage), self._is_read_only)
  File "/usr/lib/zope2.7/lib/python/ZEO/ServerStub.py", line 47, in register
    self.rpc.call('register', storage_name, read_only)
  File "/usr/lib/zope2.7/lib/python/ZEO/zrpc/connection.py", line 375, in call
    raise inst # error raised by server
ValueError: unknown storage: 2

Solution:

The testConnection routine of ClientStorage class should also consider the
"ValueError: unknown storage" to break the deadlock.

Best regards
A. Gabriel

Revision history for this message
Jean Jordaan (jean-jordaan) wrote :

Here's a different angle on the same issue:

I'm trying to make zeopack fail without hanging when faced by a ZEO server it can't talk to.

I set wait_timeout in the pack2 function in zeopack.py:
 cs = ClientStorage(addr, storage=storage, wait=1, wait_timeout=3, read_only=1)

However, this has no effect because in ClientStorage._wait, the call to 'self._rpc_mgr.connect(sync=1)' hangs before the timeout 'while' loop is entered.

I'm looking at
 Zope-2.10.5-final/lib/python/ZEO/ClientStorage.py
but the code is the same in Zope-2.11.3-final

This is what a failing zeopack run looks like:

zope@redacted:/home/zope/instances/plone-2.5/client2$
PYTHONPATH=/home/zope/Zope-2.10.5-final/lib/python/
/home/zope/Zope-2.10.5-final/bin/zeopack.py -p 9030 -S 1
ERROR:ZEO.zrpc.Connection(C):(redacted:9030) bad handshake 'Z201'
ERROR:ZEO.zrpc.Connection(C):(redacted:9030) Error caught in asyncore
Traceback (most recent call last):
 File "/home/zope/Python-2.4.4/lib/python2.4/asyncore.py", line 69, in read
   obj.handle_read_event()
 File "/home/zope/Python-2.4.4/lib/python2.4/asyncore.py", line 391, in handle_read_event
   self.handle_read()
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/zrpc/smac.py", line 219, in handle_read
   self.message_input(msg)
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/zrpc/connection.py", line 903, in recv_handshake
   Connection.recv_handshake(self, proto)
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/zrpc/connection.py", line 489, in recv_handshake
   raise ZRPCError("bad handshake %r" % proto)
ZRPCError: bad handshake 'Z201'
ERROR:ZEO.zrpc:(23263) CW: error in testConnection (('redacted', 9030))
Traceback (most recent call last):
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/zrpc/client.py", line 454, in test_connection
   self.preferred = self.client.testConnection(self.conn)
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/ClientStorage.py", line 430, in testConnection
   auth = stub.getAuthProtocol()
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/ServerStub.py", line 89, in getAuthProtocol
   return self.rpc.call('getAuthProtocol')
 File "/home/zope/Zope-2.10.5-final/lib/python/ZEO/zrpc/connection.py", line 639, in call
   raise DisconnectedError()
DisconnectedError

This loops forever.

affects: zope2 → zodb
Jim Fulton (jim-zope)
Changed in zodb:
importance: Low → Medium
kenji yuki (kenj115188)
Changed in ubuntu:
status: New → Incomplete
Changed in zodb:
assignee: nobody → Kadir Selçuk (turkdevops)
Changed in ubuntu:
assignee: nobody → Kadir Selçuk (turkdevops)
status: Incomplete → Fix Committed
Changed in zodb:
assignee: Kadir Selçuk (turkdevops) → nobody
Changed in ubuntu:
assignee: Kadir Selçuk (turkdevops) → nobody
Changed in zodb:
status: New → Incomplete
Changed in ubuntu:
status: Fix Committed → Incomplete
Colin Watson (cjwatson)
no longer affects: ubuntu
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.