Permalink
Browse files

fix bug in deleting account memcache.

Every request of container and object will invoke account_info() or
container_info() to query the meta of account and container. The meta
will be cached in memcache with the key 'account/{$account}' or
'container/{$container}', So, if any request to update account and
container, we should delete the cache. But in the cache deletion of
account, it use the wrong key 'account/v1/{$account}'. This could lead
to inconsistency of account meta.

Change-Id: Ied116a58a2d5866ac76d75ae50f21277d66e5755
  • Loading branch information...
1 parent 4236e63 commit 1701b6bc2424cd8db843ffb4517bb1239de46198 @AlexYangYu AlexYangYu committed Nov 12, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 swift/proxy/controllers/account.py
View
11 swift/proxy/controllers/account.py
@@ -31,7 +31,7 @@
from swift.common.utils import normalize_timestamp, public
from swift.common.constraints import check_metadata, MAX_ACCOUNT_NAME_LENGTH
from swift.common.http import is_success, HTTP_NOT_FOUND
-from swift.proxy.controllers.base import Controller
+from swift.proxy.controllers.base import Controller, get_account_memcache_key
from swift.common.swob import HTTPBadRequest, HTTPMethodNotAllowed, Request
@@ -97,7 +97,8 @@ def PUT(self, req):
'Connection': 'close'}
self.transfer_headers(req.headers, headers)
if self.app.memcache:
- self.app.memcache.delete('account%s' % req.path_info.rstrip('/'))
+ self.app.memcache.delete(
+ get_account_memcache_key(self.account_name))
resp = self.make_requests(
req, self.app.account_ring, account_partition, 'PUT',
req.path_info, [headers] * len(accounts))
@@ -116,7 +117,8 @@ def POST(self, req):
'Connection': 'close'}
self.transfer_headers(req.headers, headers)
if self.app.memcache:
- self.app.memcache.delete('account%s' % req.path_info.rstrip('/'))
+ self.app.memcache.delete(
+ get_account_memcache_key(self.account_name))
resp = self.make_requests(
req, self.app.account_ring, account_partition, 'POST',
req.path_info, [headers] * len(accounts))
@@ -149,7 +151,8 @@ def DELETE(self, req):
'X-Trans-Id': self.trans_id,
'Connection': 'close'}
if self.app.memcache:
- self.app.memcache.delete('account%s' % req.path_info.rstrip('/'))
+ self.app.memcache.delete(
+ get_account_memcache_key(self.account_name))
resp = self.make_requests(
req, self.app.account_ring, account_partition, 'DELETE',
req.path_info, [headers] * len(accounts))

0 comments on commit 1701b6b

Please sign in to comment.