← Back to team overview

registry team mailing list archive

[Bug 664567] [NEW] Memcached race condition and test cleanup

 

Public bug reported:

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.

** Affects: swift
     Importance: Undecided
     Assignee: David Goetz (david-goetz)
         Status: New

** Changed in: swift
     Assignee: (unassigned) => David Goetz (david-goetz)

-- 
Memcached race condition and test cleanup
https://bugs.launchpad.net/bugs/664567
You received this bug notification because you are a member of Registry
Administrators, which is subscribed to OpenStack Object Storage (swift).



Follow ups

References