0

We recently started using the Memcached cache adapter provided by ZF2. While the server appears to be running perfectly when using the web browser (Apache HTTP Server), I have seen two different exceptions when running the application from the CLI. The exception appears to occur when Zend\Session\SaveHandler\Cache writes the session to memory.

The first exception returned an error code of 47 (MEMCACHED_SERVER_TEMPORARILY_DISABLED). After exhausting many options, I decided to try recompiling Memcached, libmemcached, and the PECL extension. After doing this, I started getting a different result code—26 (MEMCACHED_ERRNO). The result message for this code reads "SYSTEM ERROR: Broken pipe."

In the cache adapter, the internalSetItem($normalizedKey, $value) method checks the boolean value returned by Memcached::set($key, $value, $expiration). If it is false, a failure has occurred, and the ZF2 adapter will throw an exception based on the Memcached::getResultCode() and Memcached::getResultMessage() methods. Prior to this, we simply weren't checking for result codes or messages, so it is possible that it has been happening all along.

My development environment specifications are as follows:

  • PHP 5.5 with Memcached 2.2.0 (PECL)
  • Memcached 1.4.20
  • Libmemcached 1.0.18
  • Zend Framework 2

EDIT: I have narrowed the problem down to a single action in a single controller, but I am still at a loss as to why this is happening. We have a ZF2 controller action that basically loops through a bunch of cron jobs and forks them off in their own processes. It goes like this...

  1. Loop through cron jobs
  2. Run pcntl_fork() to create new process
  3. Run exec('/usr/bin/php index.php JOB_NAME')

As it turns out, the third step executes without any problems. Each job is running exactly as expected, but it seems like the forking is creating a problem with Memcached in the parent process. That's where I am now.

webjawns.com
  • 2,300
  • 2
  • 14
  • 34

0 Answers0