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;
  }
CommentFileSizeAuthor
#2 2993368-stampede-invalid-data-2.patch667 bytesmarco
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marco created an issue. See original summary.

marco’s picture

Status: Active » Needs review
FileSize
667 bytes
marco’s picture

To be attributed to Fabian Franz.

  • Jeremy committed d613243 on 7.x-1.x authored by Fabianx
    Issue #2993368 by marco, Fabianx: Stampede protection will not load new...

Jeremy credited Fabianx.

Jeremy’s picture

Status: Needs review » Fixed

Thanks! Fix applied.

Status: Fixed » Closed (fixed)

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