Re: Exception thrown when saving metadata cache

3 messages Options
Embed this post
Permalink
Hector Virgen

Re: Exception thrown when saving metadata cache

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Just following up on this issue.

I ended up subclassing Zend_Db_Table_Abstract to catch and ignore this exception because it's not "critical". I'm not sure if there's a better way around this, but several times a day I am receiving reports of valid pages displaying an error message and they all trace back to this problem.

I think the original class is doing the right thing by throwing an exception, but it's very difficult to catch without subclassing it. Maybe it would help if there was an option we can pass in to setDefaultMetadataCache() to ignore this type of exception? I think the worst case scenario is the cache is not used and a "DESCRIBE [table]" query is run.

Here's my current solution (keep in mind this feels more like a hack than a solution):

<?php

class My_Db_Table extends Zend_Db_Table_Abstract
{
    protected function _setupMetadata()
    {
        try {
            return parent::_setupMetadata();
        } catch (Exception $e) {
            // Unable to save metadata
            return false;
        }
    }
}


Hector Virgen wrote:
Hello,

I have a production website running on the ZF framework and every few hours a (seemingly) random exception is thrown:

"Failed saving metadata to metadataCache"

The exception trace points to the _setupMetadata() method of Zend_Db_Table_Abstract, which ends up tracing back to random instantiations of Zend_Db_Table.

A var_dump of the exception doesn't give me a whole of information to work with, but the exception causes the visitor to be forwarded to the error controller on an otherwise working page.

Is there anything I can do to prevent this error?

Here's a snippet from my bootstrap where I set up the default metadata cache:

$frontendOptions = array(
   'lifetime' => 7200, // cache lifetime of 2 hours
   'automatic_serialization' => true
);

$backendOptions = array(
    'cache_db_complete_path' => ROOT_PATH . '/tmp/realtown/cache.sqlite' // Directory where to put the cache files
);

$cache = Zend_Cache::factory('Core', 'Sqlite', $frontendOptions, $backendOptions);

Zend_Registry::set('cache', $cache);

$cacheOptions = array(
    'frontend'          => 'Core',
    'backend'           => 'Sqlite',
    'frontendOptions'   => $frontendOptions,
    'backendOptions'    => $backendOptions
);

Zend_Registry::set('cacheOptions', $cacheOptions);

// Set this cache as the default metadata cache
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);


Thanks for your help :)

-Hector
Matej Humpal

Re: Exception thrown when saving metadata cache

Reply Threaded More More options
Print post
Permalink
Hi,

I just had an experience with the same problem - the cause was simple, no space left on / partition.
This one is indeed a very hard exception to trace AND to catch.

Hector Virgen wrote:
Just following up on this issue.

I ended up subclassing Zend_Db_Table_Abstract to catch and ignore this
exception because it's not "critical". I'm not sure if there's a better
way around this, but several times a day I am receiving reports of valid
pages displaying an error message and they all trace back to this problem.

I think the original class is doing the right thing by throwing an
exception, but it's very difficult to catch without subclassing it.
Maybe it would help if there was an option we can pass in to
setDefaultMetadataCache() to ignore this type of exception? I think the
worst case scenario is the cache is not used and a "DESCRIBE [table]"
query is run.

Here's my current solution (keep in mind this feels more like a hack
than a solution):

<?php

class My_Db_Table extends Zend_Db_Table_Abstract
{
    protected function _setupMetadata()
    {
        try {
            return parent::_setupMetadata();
        } catch (Exception $e) {
            // Unable to save metadata
            return false;
        }
    }
}
Ivan Shumkov

Re: Exception thrown when saving metadata cache

Reply Threaded More More options
Print post
Permalink
Matej Humpal wrote:
Hi,

I just had an experience with the same problem - the cause was simple, no space left on / partition.
This one is indeed a very hard exception to trace AND to catch.
Hello, what you mean "no space left on / partition" ??
May you give more detail?