We included "memcache.inc" and are using ImageField 6.x-3.0 (and FileField 6.x-3.0) to upload an image on a node add/edit page.

Browsing for the image and uploading it works as expected, but always when we try do perform more than one AHAH action on the same field (e.g. remove the image after uploading it) we get the error "An unrecoverable error occurred. This form was missing from the server cache. Try reloading the page and submitting again."

It turned out that the form_get_cache() call in filefield_js() function of filefield.module returns a $form object only for the first AHAH action, because thereafter the $form object has disappered from the 'cache_form' bin. When working with normal database caching the form remains in the 'cache_form' database table. Surprisingly, however, it also works as expected if "memcache.db.inc" is used, and indeed I found that there is a different behaviour between that and the "memcache.inc" implementation.

In "memcache.db.inc" dmemcache_flush() is called for the conditions

if (!empty($cid) && $wildcard && $cid == '*') ...

while in "memcache.inc" the conditions are

if (!empty($cid) && !($cid == '*' && $wildcard !== TRUE) && ($cid == '*' || $wildcard === TRUE)) ...

I think the "||" in the third clause must be an "&&".

We are currently using Memcache 6.x-1.2, but I've seen the same issue with the current 6.x-1.x-dev version.

Comments

dicreat’s picture

I have the same error with memcache 6.x-1.x-dev and filefield 6.x-3.1 modules.

Jeremy’s picture

Status: Active » Postponed (maintainer needs more info)

There is no way to do a partial flush with memcache, as you can't search/match a set of keys. Memcache can only perform hash lookups. As such, we treat a partial flush of multiple wildcard items from a bin the same as a total flush of the entire bin. The behavior in memcache.db.inc is to just ignore a partial flush, which I'm not sure is a particularly good idea.

In your specific example, I'm going to guess that someone is doing a partial flush of the 'cache_form' bin? Perhaps provide more of the code?

DamienMcKenna’s picture

mindgame and dicreat: have you tried talking with quicksketch on IRC about this, or adding an issue to the FileField/ImageField queue?

asb’s picture

A similar issue hit me immediately after enabling memcache.module. This steps might help to reproduce the error:

* upload an image into an imagefield
* clone the node containing the imagefield with node_clone.module
* try removing/replacing the file from the imagefield, voila!

Steps to pro the involvement of memcache.module:

* disable/mutilate your memcache, e.g. by setting localhost:11211 to localhost:11212 in settings.php, if you're only running one memcache at localhost:11212

  'memcache_servers' => array('localhost:11211' => 'default',
                              'localhost:11212' => 'pages'),

Replacing images in Imagefield will immediately start to work again.

Related issues:

* #539476: "Unrecoverable error" is giving *me* a headache, too!
* #500220: Wrong conditions for cache flush in memcache.inc?
* #486880: I can't upload second image

Any ideas or suggestions?

Thanks & greetings,
-asb

ckng’s picture

Status: Postponed (maintainer needs more info) » Active

I'm facing the same problem, using memcache.db.inc solves the problem.
The problem lies in the memcache.inc.

rapsli’s picture

confirm. memcache.db.inc works.

Whats the different between those two files?

Scott Reynolds’s picture

make sure that you have cache_form in its own bin. That is how we fix this on our side.

Once it was separated all AHAH stuff worked well.

aries’s picture

+1, i separated the forms into a different bin and the problem is solved.

mrfelton’s picture

but you need two servers if you are to separate out the bins. We only have one, and I can;t find a way to start more than one memcached on just one server.

DamienMcKenna’s picture

You need to start multiple copies of memcached with each on a different port. For one site I wrote a tiny script that ran the following:

#!/bin/sh
# Launch all of the memcache processes

memcached -m 16 -p 11500 -d
memcached -m 16 -p 11501 -d

(and eight more buckets..)

andypost’s picture

Is there plans to implement "wildcard flush"?

mrfelton’s picture

yeas, but this is difficult to get running from an init script - out of the box. Anyway, we shouldn't need to have to do this, surely.

scroogie’s picture

I hit the same problem today. It should really be advertised on the modules page! A lot of modules do partial flushes, among those I had installed alone it was CCK, content_profile, date, filefield, imagecache, img_assist and logintoboggan.
I've also read up on the issue on the memcache side, and indeed there is no way to do a partial flush without using some tricks (see http://code.google.com/p/memcached/wiki/FAQ#Namespaces). This trick will slow down all caches if it's used generally, though, so this could only be solved by replacing wildcards in the drupal cache API with namespaces. Perhaps this should be considered in D7? Or is it too late already?

moshe weitzman’s picture

Status: Active » Closed (duplicate)

economist.com now bitten by this. lets consolidate conversation in #224772: problem with cache_clear_all

borgo’s picture

Problem with filefield AHAH seems to disappear after switching memcache to DB mode

$conf = array(  
  'cache_inc' => './sites/all/modules/memcache/memcache.db.inc',                                     															 
);

And disabling 'Show memcache statistics at the bottom of each page; at admin/settings/memcache. The moment I turn statistics display ON again, I get nasty loong JS alerts back after hitting 'Upload'.

fuzzy76’s picture

Status: Closed (duplicate) » Active

Sorry for reopening, but I don't think #224772: problem with cache_clear_all is related to this issue at all. That issue is about how a wildcard flush is triggered, while this issue is about what a wildcard flush is supposed to do. We get these alerts from time to time, though not consistently. I guess #801348: Some caches are not caches really. might be more related.