Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There is a discrepancy in the way the memcache servers and their stats are built up in memcache_admin_stats() when the servers connect with Unix sockets. They key returned by dmemcache_stats() includes the port number 0 even though it shouldn't be included in the memcache_servers variable.
The simplest fix seems to be to add ':0' to the $server variable if it represents a Unix socket.
Comment | File | Size | Author |
---|---|---|---|
#12 | memcache_unix_server_stats-1547390-12.patch | 753 bytes | imclean |
#3 | patch-memcache-memcache_admin-socket-support.patch | 444 bytes | unitedwallabies |
#2 | patch-memcache-memcache_admin-socket-support.patch | 366 bytes | unitedwallabies |
unix_stats.patch | 799 bytes | Island Usurper |
Comments
Comment #1
Island Usurper CreditAttribution: Island Usurper commentedHa, I forgot to describe what the problem is. The stats page shows the "Failed to connect to server at unix:///tmp/memcached.sock." message, but it still has numbers in the Total column. Everything under the actual server just shows up as 0, but it's obviously finding numbers somewhere.
Comment #2
unitedwallabies CreditAttribution: unitedwallabies commentedThis fix helped me as well. Thank you.
My version of the patch uses substr instead of strpos -- because strpos() looks through the entire server name.
Both fixes appear to be work-arounds, of course, until the maintainer implements it properly.
Comment #3
unitedwallabies CreditAttribution: unitedwallabies commentedDuh... Even better is to use strncmp().
Comment #4
cn_gd CreditAttribution: cn_gd commentedif you're using PECL Memcached should use patch in :http://drupal.org/node/1690130#comment-6323518
Comment #5
adammaloneThe patch in #3 works for me.
Could this issue and http://drupal.org/node/1690130#comment-6323518 be merged?
Comment #6
Phizes CreditAttribution: Phizes commentedWith regards to comment #5: The 2 issues are currently dealing with different parts of the various Memcached and sockets functionality troubles.
#1690130: Memcache fails to connect when using Unix sockets and PECL Memcached is only dealing with the memcache module and PECL memcached, this issue is dealing with the memcache_admin module (which is a sub-module that comes with the Drupal memcache module) and PECL memcache.
Pecl memcache is a seperate project to PECL memcached, the presence or lack of the d is significant as it means that a different string needs to be passed to the respective addServer methods. ('unix:///path/to/socket' for PECL memcache versus '/path/to/socket' for PECL memcached) (This is of course an oversimplification of their differences, but it is the difference that is causing problems.)
When / If the first patch (in the opening post) of the original issue of #1690130: Memcache fails to connect when using Unix sockets and PECL Memcached is reviewed or commented on, and someone of power is happy with the way I have done it there, or proposed a more suitable solution, I am willing to patch the memcache_admin module so that it can handle sockets and produce statistics for both PECL memcache and PECL memcached (provided I have a little time). Unfortunately #1690130: Memcache fails to connect when using Unix sockets and PECL Memcached has not been reviewed or commented on, so I do not know if what I have done is acceptable (I don't see why it would be unacceptable though).
With regards to this original post: As far as I remember this patch fixed the stats page only for PECL Memcache and not PECL Memcached as well, so marking as needs work. This is due to memcache defaulting to using PECL memcached over PECL memcache when both are available and one is not specifically set for use.
Comment #7
adammaloneSo to clarify, this issue needs a patch that fixes memcache_admin stats page for both memcache and memcached?
Comment #8
Phizes CreditAttribution: Phizes commentedI believe so as this is currently on the project home page:
The module is supposed to support both of the PECL libraries, so I think socket support should be fixed for both of them.
Comment #9
rares CreditAttribution: rares commentedThis issue still persists, at least in 6.x. The issues mentioned in #6 have all been closed. Can someone comment on whether this has been fixed in 7.x?
Comment #10
Phizes CreditAttribution: Phizes commentedWith regards to #9, it has not been fixed as far as I am aware, at least not by me. (Un)fortunately I have been very busy with work for the past several months, and any patches I have written have been work related. As soon as I have time for recreational coding, I'll get onto this if someone else hasn't taken care of it already.
Comment #11
imclean CreditAttribution: imclean commented@typhonius, I don't think it supports memcached, which expects just the path to the socket without the protocol.
@rares, I've created a 6.x patch in another issue. Please see: #2085299: Support unix sockets with PECL memcached
Comment #12
imclean CreditAttribution: imclean commentedThe issues mentioned in #6 have been resolved. This patch should fix the stats for both memcache and memcached extensions.
Comment #13
Jeremy CreditAttribution: Jeremy commentedThis was close, but didn't quite work with the Memcached extension which apparently expects ":11211" instead of ":0". Fixed and committed:
http://drupalcode.org/project/memcache.git/commitdiff/b138d4a
Comment #15
rodricels CreditAttribution: rodricels commentedAre you sure about the expected :11211 port with Memcached?
I have a memcached working with a :0 port. With a :11211 port, the stats page don't work.
Settings:
$conf['memcache_servers'] = array('unix:///var/run/memcached/memcached.sock' => 'default');
#12 patch works well
Comment #16
Jeremy CreditAttribution: Jeremy commentedHave you tested with 7.x-1.1-beta4, without any patches applied?
If yes, a few questions:
Comment #17
rodricels CreditAttribution: rodricels commentedYes, 7.x-1-1-beta4 without any patches.
debian 7.3
memcached debian package 1.4.13-0.2+deb7u1
PHP 5.4.24-1~dotdeb.1
pecl memcached 2.1.0 stable
memcached started with this config in service mode
cat /etc/memcached.conf
-d
-m 128
-u nobody
# For memcached socket
-s /var/run/memcached/memcached.sock
-a 0766
Comment #18
Jeremy CreditAttribution: Jeremy commentedI reworked the admin stats overview to make the port irrelevant:
http://drupalcode.org/project/memcache.git/commitdiff/5211f36