Memcached race condition and test cleanup

Bug #664567 reported by David Goetz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Medium
David Goetz

Bug Description

In the memcached client incr and decr function there is a race condition that needs to be fixed along these lines:

diff --git a/swift/common/memcached.py b/swift/common/memcached.py
index 164c1d8..90266ea 100644 (file)
--- a/swift/common/memcached.py
+++ b/swift/common/memcached.py
@@ -155,8 +155,14 @@ class MemcacheRing(object):
                 line = fp.readline().strip().split()
                 if line[0].upper() == 'NOT_FOUND':
                     line[0] = str(delta)
- sock.sendall('add %s %d %d %s noreply\r\n%s\r\n' % \
+ sock.sendall('add %s %d %d %s\r\n%s\r\n' % \
                                   (key, 0, timeout, len(line[0]), line[0]))
+ line = fp.readline().strip().split()
+ if line[0].upper() == 'NOT_STORED':
+ sock.sendall('incr %s %s\r\n' % (key, delta))
+ line = fp.readline().strip().split()
+ else:
+ line[0] = str(delta)
                 ret = int(line[0].strip())
                 self._return_conn(server, fp, sock)
                 return ret

Unit tests mocking out the client need to be cleaned up and the incr / decr functions should be able to handle negative deltas gracefully.

Related branches

Changed in swift:
assignee: nobody → David Goetz (david-goetz)
Chuck Thier (cthier)
Changed in swift:
milestone: none → 1.1.1
importance: Undecided → Medium
Chuck Thier (cthier)
Changed in swift:
status: New → Triaged
clayg (clay-gerrard)
Changed in swift:
status: Triaged → In Progress
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in swift:
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.