|  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: -
From: bellosthomas at gmail dot com Assigned:
Status: Open Package: memcache (PECL)
PHP Version: 5.3.2 OS: CentOS 5.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
20 + 13 = ?
Subscribe to this entry?

 [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

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Mar 08 05:01:24 2021 UTC