Read from server sometimes fails (Patch included)
Bug #628339 reported by
Jeremy Cowles
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-
+++ local_copy/
@@ -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
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.
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.