This has taken several hours of testing and fiddling to debug, but I think I've got to the bottom of it.
Here's my setup:
Memcache 1.2.5
Memcache Pecl 3.0.3
Memcache module 6.x-1.5
I'm not 100% hot on what the latest versions are, but guessing those aren't probably up to date, but that's not where the issue is...
Upon calling dmemcache_get, because I'm using the memcache extension, the following will be called to set the value in memcache:
$mc->set($full_key, $value, MEMCACHE_COMPRESSED, $exp);
In most cases this is fine, but seemingly, this fails if the $value is an integer; Strings, arrays and objects seem to work fine. Change the flags to 0 and suddenly integers can be stored.
This isn't a massive issue at first glance, because almost all the data stored by the drupal is a cache object, except for one type of data: The counters for the prefixes for cache flushing, they are plain vanilla integers. This basically has the side effect of making it impossible to flush the cache! The '.prefix.' . $cid value never gets set, and doesn't seem to get incremented either.
I'm just finishing up a patch to the module that will not attempt to store integers compressed and will post it shortly.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | memcache-872338.patch | 1.2 KB | steven jones |
Comments
Comment #1
steven jones commentedPatch attached.
Comment #2
steven jones commentedI should probably say, that this is probably a bug in Memcache or the Memcache PECL extension, and this is just a bit of a workaround.
Comment #3
jeremy commentedReminding myself to try and duplicate this later -- the specific issue described is now fixed with the new wildcard support (replacing the "prefixes" logic), however I'm curious as I did run into something similar earlier when I was testing and before I saw this issue.
Comment #4
catchBumping this one.
Comment #5
c960657 commentedIt is a known limitation that $mc->increment() does not work with MEMCACHE_COMPRESSED, see http://php.net/manual/en/function.memcache-increment.php.
However, I was not able to reproduce the problem on my machine. The following code works without problems:
Whether compression takes place or not may be related to the compression threshold, see
http://php.net/manual/en/memcache.setcompressthreshold.php. I don't know what the default value is, if it has not been specified using $mc->setCompressThreshold().
Comment #6
jeremy commentedI wrote a quick drush script to try and duplicate this, but found that a cache_set of an integer (1, 0, TRUE and FALSE) followed by a cache_get returns the correct value. I am using the Memcache PECL extension to test, per the original bug report.
Furthermore, the Simpletest suite does perform a test validating that we are able to set and then get an plain integer, and this test also succeeds.
I suspect this has been fixed in the PECL extension, as I see similar older bug reports here: http://php.tonnikala.org/manual/ru/function.memcache-set.php
I'm going to go ahead and mark this as fixed, noting that you should use the latest Memcache PECL extension with the Drupal memcache module.
Comment #7
jeremy commentedTrying again to mark it fixed...
Comment #9
slashrsm commentedReopening this, as I ran into the same issue with 7.x-1.0.
It is pretty nasty bug, since it causes incorrect behaviour of wildcard flushes. I was flushing some cache item, but it was not flushed, since the wildcard flushing counter was not updated properly. It was a really hard one to debug....
I *think* that this also has something to do with PHP version, since I was trying with the following combinations:
- PHP 5.3.1, Memcache 3.0.6
- PHP 5.3.2, Memcache 3.0.4
- PHP 5.3.6, Memcache 3.0.5
The latter was working OK. First two had problems. When I applied a workaround suggested at http://www.php.net/manual/en/memcache.set.php#100971, thing started to work properly on all machines.
I think we should implement some workaround for this bug. We should at least document PHP/Memcache versions, that are required for this to work properly if not.
Comment #10
jeremy commentedThe memcache module does specify minimum version requirements.