|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59472 memcache.hash_strategy issues
Submitted: 2010-10-22 11:00 UTC Modified: 2021-03-25 16:30 UTC
From: bellosthomas at gmail dot com Assigned: cmb (profile)
Status: Closed Package: memcache (PECL)
PHP Version: 5.3.2 OS: CentOS 5.4
Private report: No CVE-ID: None
 [2010-10-22 11:00 UTC] bellosthomas at gmail dot com

Using php 5.3.3 and memcache 3.0.3.

I have 2 centos (master and slave) running one memcached instance each.
Additionaly I use the below setting
memcache.hash_strategy = consistent

Which, based on the documentation:
"allows servers to be added or removed from the pool without causing keys to be remapped"

I start both instances and navigate through the app causing items to be stored on the servers.
Using memcache.php I see that master has 5 items and slave 2 items.

I bring down the master and navigate through the app, which causes the items
that were previously stored on the master, to be cached on the slave.
So far so good.

I then bring up the master and again navigate through the app. 
The items are now cached again to the master, meaning that both nodes now have cached the same items.

Now, consider the following scenario.
I update a database item, which (due to the above) is stored on both nodes. 
I then do a get on the item's key from the server pool and I get back the cached item from master.
I update its contents and put it back to the cache.

For some reason, master crashes. However, when I check the cache for its key, I get a hit since it is
on the slave server, BUT the contents are old, out of sync with the database (bad news).

I would have expected that the key mapping would be such that it will not have to save keys to the 
master again, since they are already cached in the slave.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-25 16:30 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-03-25 16:30 UTC]
The official bug tracker for PECL/memcache is now at

So, if this is still an issue with either of the current memcache
versions (4 or 8), please file an issue there.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Apr 21 21:01:24 2021 UTC