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.

CommentFileSizeAuthor
#1 memcache-872338.patch1.2 KBsteven jones

Comments

steven jones’s picture

StatusFileSize
new1.2 KB

Patch attached.

steven jones’s picture

I 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.

jeremy’s picture

Assigned: Unassigned » jeremy
Priority: Critical » Normal

Reminding 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.

catch’s picture

Bumping this one.

c960657’s picture

It 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:

$memcache->set('dummy', 123, MEMCACHE_COMPRESSED, time() + 3600);
$memcache->increment('dummy', 3);
$memcache->increment('dummy', 5);
var_dump($memcache->get('dummy'));

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().

jeremy’s picture

Status: Needs review » Postponed

I 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.

jeremy’s picture

Status: Postponed » Fixed

Trying again to mark it fixed...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

slashrsm’s picture

Version: 6.x-1.x-dev » 7.x-1.0
Status: Closed (fixed) » Active

Reopening 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.

jeremy’s picture

Issue summary: View changes
Status: Active » Fixed

The memcache module does specify minimum version requirements.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.