php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58585 Session redundancy doesn't work
Submitted: 2009-03-16 01:36 UTC Modified: 2021-03-25 16:44 UTC
Votes:16
Avg. Score:4.4 ± 0.9
Reproduced:9 of 9 (100.0%)
Same Version:2 (22.2%)
Same OS:-2 (-22.2%)
From: mail at chernousov dot com Assigned: cmb (profile)
Status: Closed Package: memcache (PECL)
PHP Version: 5.2.5 OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mail at chernousov dot com
New email:
PHP Version: OS:

 

 [2009-03-16 01:36 UTC] mail at chernousov dot com
Description:
------------
PHP 5.2.8 (some reason this version doesn't exists in bugreport form)
memcached 1.2.6
pecl-memcache: 3.0.4 (some reason this version doesn't exists in bugreport form)


I tried to test session redundancy with 2 servers, host1 and host2.

session.save_path="tcp://host1:11211,tcp://host2:11211"
memcache.allow_failover=1
memcache.max_failover_attempts=20
memcache.session_redundancy=2

As soon as host2 goes down, I got error: "Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct..."

Next I start host2 and stop host1. Error disappears.
Changing servers order in session.save_path doesn't affect anything.

P.S. I just tried version 3.0.1, this problem doesn't appear there, all works as expected.

Reproduce code:
---------------




Patches

0001-Fix-bug-58585-Session-redundancy-doesn-t-work.patch (last revision 2013-10-22 03:03 UTC by mattc at catalyst dot net dot nz)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-16 08:58 UTC] slim at inbox dot lv
I can confirm this problem. After upgrading from 3.0.2 to 3.0.4 pecl-memcache does not write to both memcached servers
 [2009-07-10 10:57 UTC] georg dot hoellrigl at xidras dot com
Is there someone working on that?

It also works with 3.0.3
 [2009-10-26 06:29 UTC] robyinno at tele2 dot it
I have verified the same problem with 3.0.4 with memcached-1.2.8 and memchached-1.2.8-repchached patched.
After I have uninstalled 3.0.4 and installed 3.0.3 and everything work.
 [2009-12-15 20:57 UTC] ryan dot brothers at gmail dot com
I just wanted to check if anyone had any workarounds for this issue besides downgrading to the older 3.0.3 release - as I am experiencing it too.
 [2010-04-09 09:41 UTC] abodera at gmail dot com
Workaround: set session_redundancy to num_servers+1 ;)

Setting session_redundancy to 3 makes session handler write to 2 servers.
 [2011-03-11 01:45 UTC] hradtke@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 [2011-04-11 00:30 UTC] hradtke@php.net
Reopening as this caused a regression in the session handling code.
 [2011-05-09 05:48 UTC] ezequiel dot lara at mpt dot es
(just for the record: still happening in 3.0.6)
 [2011-07-21 12:19 UTC] linusnorton at gmail dot com
I am also experiencing this problem with 3.0.6, is there a 
3.0.7?

Also has this really been in beta for 4 years?
 [2011-07-21 14:59 UTC] hradtke@php.net
Parts of pecl/memcache are in beta and parts are stable. The re-write stalled midway through and it has been struggling ever since.
 [2012-06-13 10:32 UTC] ea333 at freemail dot hu
What is the regression with session handling?

I use 3.0.6 with the session_redundancy fix, and here is a little test, works 
good:

redundancy: 2 
sessionid: 4g908ob8580aj509d4vquserd7
random: 947373857
***: x.x.x.41 1
string(17) "test|i:947373857;"
***: x.x.x.35 1
bool(false)
***: x.x.x.25 1
bool(false)
***: x.x.x.57 1
string(17) "test|i:947373857;"
***: x.x.x.48 1
bool(false)


redundancy: 3 
sessionid: 4g908ob8580aj509d4vquserd7
random: 1677479115
***: x.x.x.41 1
string(18) "test|i:1677479115;"
***: x.x.x.35 1
string(18) "test|i:1677479115;"
***: x.x.x.25 1
bool(false)
***: x.x.x.57 1
string(18) "test|i:1677479115;"
***: x.x.x.48 1
bool(false)


redundancy: 4 
sessionid: 4g908ob8580aj509d4vquserd7
random: 1804507623
***: x.x.x.41 1
string(18) "test|i:1804507623;"
***: x.x.x.35 1
string(18) "test|i:1804507623;"
***: x.x.x.25 1
string(18) "test|i:1804507623;"
***: x.x.x.57 1
string(18) "test|i:1804507623;"
***: x.x.x.48 1
bool(false)


redundancy: 5 
sessionid: 4g908ob8580aj509d4vquserd7
random: 752757916
***: x.x.x.41 1
string(17) "test|i:752757916;"
***: x.x.x.35 1
string(17) "test|i:752757916;"
***: x.x.x.25 1
string(17) "test|i:752757916;"
***: x.x.x.57 1
string(17) "test|i:752757916;"
***: x.x.x.48 1
string(17) "test|i:752757916;"


redundancy: 6 
sessionid: 4g908ob8580aj509d4vquserd7
random: 12963724
***: x.x.x.41 1
string(16) "test|i:12963724;"
***: x.x.x.35 1
string(16) "test|i:12963724;"
***: x.x.x.25 1
string(16) "test|i:12963724;"
***: x.x.x.57 1
string(16) "test|i:12963724;"
***: x.x.x.48 1
string(16) "test|i:12963724;"
 [2013-08-15 03:06 UTC] mattc at catalyst dot net dot nz
From my testing, if there are two memcached servers in the pool and session 
redundancy is set to 2 then only one copy of the session is 
stored.

It appears to be an off by one bug on line 419 of memcache_session.c:

 } while (skip_servers.len < MEMCACHE_G(session_redundancy)-1 && 
skip_servers.len < pool->num_servers);


should be:

 } while (skip_servers.len < MEMCACHE_G(session_redundancy) && skip_servers.len 
< pool->num_servers);
 [2013-09-17 20:08 UTC] tcushman at kidblog dot org
Thanks mattc at catalyst dot net dot nz.  I was experiencing this problem with the same configuration:  two memcached hosts, session_redundancy = 2, and sessions only being written to one host.  Based on code you spotted, setting session_redundancy = 3 "fixed" the issue for the time being.
 [2021-03-25 16:44 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-03-25 16:44 UTC] cmb@php.net
The official bug tracker for PECL/memcache is now at
<https://github.com/websupport-sk/pecl-memcache/issues>.

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 17:01:30 2024 UTC