php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80013 session handler memcached is unstable
Submitted: 2020-08-24 12:58 UTC Modified: 2020-08-25 16:45 UTC
From: angelo dot courtel at laposte dot net Assigned:
Status: Not a bug Package: memcached (PECL)
PHP Version: 8.0.0beta2 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: angelo dot courtel at laposte dot net
New email:
PHP Version: OS:

 

 [2020-08-24 12:58 UTC] angelo dot courtel at laposte dot net
Description:
------------
Hello, 

We note a broken behavior of session_start() function, configured with below config :
session
Session Support	enabled
Registered save handlers	files user memcached
Registered serializer handlers	php_serialize php php_binary
Directive	Local Value	Master Value

session.save_handler	memcached	files
session.save_path	memcached.local:11211	no value

session.auto_start	Off	Off
session.cache_expire	180	180
session.cache_limiter	nocache	nocache
session.cookie_domain	no value	no value
session.cookie_httponly	1	1
session.cookie_lifetime	0	0
session.cookie_path	/	/
session.cookie_samesite	no value	no value
session.cookie_secure	0	0
session.gc_divisor	100	100
session.gc_maxlifetime	14400	14400
session.gc_probability	1	1
session.lazy_write	Off	Off
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.serialize_handler	php	php
session.sid_bits_per_character	4	4
session.sid_length	32	32
session.upload_progress.cleanup	On	On
session.upload_progress.enabled	On	On
session.upload_progress.freq	1%	1%
session.upload_progress.min_freq	1	1
session.upload_progress.name	PHP_SESSION_UPLOAD_PROGRESS	PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix	upload_progress_	upload_progress_
session.use_cookies	1	1
session.use_only_cookies	1	1
session.use_strict_mode	1	1
session.use_trans_sid	0	0

Some time session start works fine, but in ~50% of case a new session id is spawned.
There are no warning displayed about session_start failed.

Test script:
---------------
<?php
error_reporting(E_ALL);
session_start();
?><pre><?php
var_dump('sessid in $_COOKIE :', $_COOKIE["PHPSESSID"]);
var_dump('session_id() : ', session_id());
var_dump($_SESSION);
$_SESSION['marker'] = date('Y-m-d H:i:s');
var_dump($_SESSION);
session_write_close();

//our memcached.local service run with this config :
//docker run --name my-memcache -d memcached memcached -m 64 -p 11211:11211
//we reproduce this bug in both 1.5.20 and 1.6.6 version (latest)
//pecl memcached library is memcached-3.1.5
//this test script works fine in php 7.4.9 with same pecl and memcached server versions

Expected result:
----------------
string(20) "sessid in $_COOKIE :"
string(32) "a6f0a72f144fa887ad90d2bd75781030"
string(15) "session_id() : "
string(32) "a6f0a72f144fa887ad90d2bd75781030"
array(1) {
  ["marker"]=>
  string(19) "2020-08-24 14:47:21"
}
array(1) {
  ["marker"]=>
  string(19) "2020-08-24 14:48:25"
}

Actual result:
--------------
string(20) "sessid in $_COOKIE :"
string(32) "a6f0a72f144fa887ad90d2bd75781030"
string(15) "session_id() : "
string(32) "44826965ac893f140b99806f74762d13"
array(0) {
}
array(1) {
  ["marker"]=>
  string(19) "2020-08-24 14:49:08"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-24 13:49 UTC] angelo dot courtel at laposte dot net
And you can see my memcached config below :

memcached
memcached support	enabled
Version	3.1.4
libmemcached version	1.0.18
SASL support	yes
Session support	yes
igbinary support	no
json support	no
msgpack support	no
Directive	Local Value	Master Value
memcached.compression_factor	1.3	1.3
memcached.compression_threshold	2000	2000
memcached.compression_type	fastlz	fastlz
memcached.default_binary_protocol	Off	Off
memcached.default_connect_timeout	0	0
memcached.default_consistent_hash	Off	Off
memcached.serializer	php	php
memcached.sess_binary_protocol	On	On
memcached.sess_connect_timeout	0	0
memcached.sess_consistent_hash	On	On
memcached.sess_consistent_hash_type	ketama	ketama
memcached.sess_lock_expire	0	0
memcached.sess_lock_max_wait	not set	not set
memcached.sess_lock_retries	70	70
memcached.sess_lock_wait	not set	not set
memcached.sess_lock_wait_max	500	500
memcached.sess_lock_wait_min	200	200
memcached.sess_locking	On	On
memcached.sess_number_of_replicas	0	0
memcached.sess_persistent	Off	Off
memcached.sess_prefix	memc.sess.key.	memc.sess.key.
memcached.sess_randomize_replica_read	Off	Off
memcached.sess_remove_failed_servers	Off	Off
memcached.sess_sasl_password	no value	no value
memcached.sess_sasl_username	no value	no value
memcached.sess_server_failure_limit	0	0
memcached.store_retry_count	2	2
 [2020-08-25 14:35 UTC] angelo dot courtel at laposte dot net
Hello,

I can't reproduce this bug on version 8.0.0beta2 on an isolated development environment. We must have a bad configuration somewhere in the environment that was a problem yesterday.

You can close the ticket. Thanks
 [2020-08-25 14:35 UTC] angelo dot courtel at laposte dot net
-Status: Open +Status: Closed
 [2020-08-25 14:35 UTC] angelo dot courtel at laposte dot net
I can't reproduce the bug on version 8.0.0beta2 in an isolated development environment. We must have a bad configuration somewhere in the environment that was a problem yesterday.

You can close the ticket. Thanks
 [2020-08-25 16:45 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC