php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73112 memcache session lock seems to cause random 30s delays
Submitted: 2016-09-19 10:27 UTC Modified: 2021-03-25 16:39 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jonathan dot roberts at nccgroup dot trust Assigned: cmb (profile)
Status: Closed Package: memcache (PECL)
PHP Version: 5.6.26 OS: CentOS 6
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: jonathan dot roberts at nccgroup dot trust
New email:
PHP Version: OS:

 

 [2016-09-19 10:27 UTC] jonathan dot roberts at nccgroup dot trust
Description:
------------
We're using the memcache extension to handle our session storage. We have the following configuration:

memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 32768 => 32768
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 5 => 5

Session Support => enabled
Registered save handlers => files user memcache 
session.auto_start => On => On
session.bug_compat_42 => Off => Off
session.bug_compat_warn => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_httponly => Off => Off
session.cookie_lifetime => 43200 => 43200
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.entropy_file => no value => no value
session.entropy_length => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 43200 => 43200
session.gc_probability => 1 => 1
session.hash_bits_per_character => 5 => 5
session.hash_function => 0 => 0
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => memcache => memcache
session.save_path => tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15 => tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://xxx:11211?persistent=1&weight=1&timeout=1&retry_interval=15
session.serialize_handler => php => php
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_trans_sid => 0 => 0

Apparently randomly, we sometimes see a 15s or 30s delay before the server will return data to the client. 

While debugging, we have tried changing the value of memcache.lock_timeout, and find we can manipulate how long the delay lasts for by fiddling with this. e.g. changing from the 15s to 2s results in delays of 2 or 4s. 

We do not believe this is caused by a single session being accessed multiple times concurrently, as we can reproduce the issue by executing the Linux command curl against the landing page, so no login required and presumably a new session initiated for each connection. 

Expected result:
----------------
Every time we initiate a new connection without a session present, the lock timeout should not be hit and the page should return normally.

Actual result:
--------------
Randomly, new connections hit the lock timeout and return in either 15 or 30s. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-25 16:39 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-03-25 16:39 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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC