Read from server sometimes fails (Patch included)

Bug #628339 reported by Jeremy Cowles
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Python Memcached
Fix Released
High
Sean Reifschneider

Bug Description

The function _expectvalue assumes a value is always returned from the server, which was not true in some cases.

Here is my patch:

--- python-memcached-1.45/memcache.py 2010-09-01 12:53:40.615960000 -0700
+++ local_copy/memcache.py 2010-08-31 11:04:31.517060834 -0700
@@ -870,6 +870,8 @@
     def _expectvalue(self, server, line=None):
         if not line:
             line = server.readline()
+ if not line:
+ return (None, None, None)

         if line[:5] == 'VALUE':
             resp, rkey, flags, len = line.split()

(the same as attachment)

--
Jeremy

Revision history for this message
Jeremy Cowles (jeremy-cowles) wrote :
Revision history for this message
Kirill Zaitsev (k-zaitsev) wrote :

I confirm that.
The bug is pretty easy to reproduce. It happens always when one of the servers in multi-server setup fails.
To reproduce: create a Client with at least two servers (for example two local memcached servers on different ports), then set some values, then shut one of the servers down and try to fetch a value. this will result in a TypeError as specified above.

This happens because readline() of the _Host class returns None if the Host is down(and no data was received). This affects several places actually: _incrdecr, _expectvalue, _expect_cas_value will all fail as they expect line to be a string. There are few other functions, that just check that value returned by readline is true, but that's OK in those functions I guess.
I'll supply a bit better patch here soon.

Changed in python-memcached:
status: New → Confirmed
Changed in python-memcached:
assignee: nobody → Sean Reifschneider (jafo)
status: Confirmed → Fix Committed
Changed in python-memcached:
importance: Undecided → High
Changed in python-memcached:
status: Fix Committed → Fix Released
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.