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.
Assuming MemCacheDrupal::valid() is called with invalid data, and stampede protection kicks in, the original invalid data will be returned instead of the valid data:
public function get($cid) {
...
$cache = dmemcache_get($cid, $this->bin, $this->memcache);
// let's assume $cache is invalid now.
return $this->valid($cid, $cache) ? $cache : FALSE;
}
protected function valid($cid, $cache) {
if ($cache) {
... $cache will be FALSE if it's not valid
}
if (!$cache) {
if (variable_get('memcache_stampede_protection', FALSE) && $this->lockInit() && $this->stampedeProtected($cid) && !lock_acquire("memcache_$cid:$this->bin", variable_get('memcache_stampede_semaphore', 15))) {
...
static $lock_count = 0;
$lock_count++;
if ($lock_count <= variable_get('memcache_stampede_wait_limit', 3)) {
...
lock_wait("memcache_$cid:$this->bin", variable_get('memcache_stampede_wait_time', 5));
// here the cache will be loaded again, but this won't change $cache in the calling method.
$cache = $this->get($cid);
}
}
}
// this is computed according to the newly loaded $cache.
$valid = (bool) $cache;
...
return $valid;
}
Comment | File | Size | Author |
---|---|---|---|
#2 | 2993368-stampede-invalid-data-2.patch | 667 bytes | marco |
Comments
Comment #2
marco CreditAttribution: marco at Tag1 Consulting commentedComment #3
marco CreditAttribution: marco at Tag1 Consulting commentedTo be attributed to Fabian Franz.
Comment #6
Jeremy CreditAttribution: Jeremy at Tag1 Consulting commentedThanks! Fix applied.