ZoroXing / xmemcached

Automatically exported from code.google.com/p/xmemcached
Apache License 2.0
0 stars 0 forks source link

connectionPoolSize has badly side effect on ArrayMemcachedSessionLocator. #180

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When two MemcachedClient with exact same address list but different 
connectionPoolSize configuration, they will/maybe hash the same key into 
different memcached clients.

This is due to the following two facts:
1. connectionPoolSize > 1 will cause MemcachedClient create multiple sessions 
for each memcached address.
2. ArrayMemcachedSessionLocator will use hash(key) % allSessions.size() to 
locate a session.
3. allSessions.size()  depends on connectionPoolSize.

KetamaMemcachedSessionLocator has a smarter way to handle the 
connectionPoolSize side effect, it use session's actual memcached address to 
calculate the position of the session. This will promise no matter what the 
connectionPoolSize is, all the sessions for one memcached address will always 
located in the same position of the hash ring. And in turn, the same key on 
different memcached client with exact same address list will always be hashed 
to the same memcached address.

I didn't see this side effect documented, it should either be mentioned 
explicitly or be fixed in ArrayMemcachedSessionLocator.

Original issue reported on code.google.com by gjyal...@gmail.com on 28 Feb 2012 at 4:11

GoogleCodeExporter commented 8 years ago
Hi
   Yes,you are right,it is a serious issue in ArrayMemcachedSessionLocator.Thanks for your report,it's my mistake,i wll fix it as soon as possible.

Original comment by killme2...@gmail.com on 28 Feb 2012 at 4:43

GoogleCodeExporter commented 8 years ago
You are welcome. Hope this will save some people some time.

Original comment by gjyal...@gmail.com on 28 Feb 2012 at 4:49

GoogleCodeExporter commented 8 years ago
Fixed by 
https://github.com/killme2008/xmemcached/commit/06df5f8c82488cf06ab06d6f2ef6e216
f77cc13e

Original comment by killme2...@gmail.com on 17 Mar 2012 at 12:39

GoogleCodeExporter commented 8 years ago
xmemcached 1.3.6 released.

Original comment by killme2...@gmail.com on 19 Mar 2012 at 2:13