[horde] SQL cache in Horde_Core-2.5.0-beta1 and -beta2 broken?

Michael M Slusarz slusarz at horde.org
Tue May 14 04:06:15 UTC 2013


Quoting Arjen de Korte <arjen+horde at de-korte.org>:

> After upgrading from the latest PEAR -stable to -beta, it wasn't  
> possible to login to Horde anymore. The following message was  
> displayed (lines 12 to 15 are repeated many, so I omitted them):

Although not the solution to the problem, please heed the following  
practical advice:

DO NOT USE THE SQL DRIVER FOR CACHING.

It makes no sense.  In many cases, caching with SQL will be SLOWER  
than without caching at all.  I've gone back and tried to make this  
very clear in the documentation.

> A fatal error has occurred
> Could not instantiate PDO with DSN  
> "mysql:persistent=1;protocol=unix;unix_socket=/var/run/mysql/mysql.sock;dbname=horde5". PDOException: SQLSTATE[08004] [1040] Too many  
> connections
>
>   1. Horde_Registry::appInit()  
> /srv/www/htdocs/horde/admin/config/index.php:19
>   2. Horde_Registry->__construct()  
> /usr/share/php5/PEAR/Horde/Registry.php:246
>   3. Horde_Registry->_loadApplications()  
> /usr/share/php5/PEAR/Horde/Registry.php:493
>   4. Horde_Registry->_loadCache() /usr/share/php5/PEAR/Horde/Registry.php:617
>   5. Horde_Injector->getInstance()  
> /usr/share/php5/PEAR/Horde/Registry.php:1984
>   6. Horde_Injector->createInstance()  
> /usr/share/php5/PEAR/Horde/Injector.php:247
>   7. Horde_Injector_Binder_Factory->create()  
> /usr/share/php5/PEAR/Horde/Injector.php:213
>   8. Horde_Core_Factory_Cache->create()  
> /usr/share/php5/PEAR/Horde/Injector/Binder/Factory.php:111
>   9. Horde_Core_Factory_Db->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Cache.php:82
>  10. Horde_Core_Factory_Db->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:68
>  11. Horde_Core_Factory_Db->createDb()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:99
>  12. Horde_Core_Factory_Cache->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:162
>  13. Horde_Core_Factory_Db->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Cache.php:82
>  14. Horde_Core_Factory_Db->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:68
>  15. Horde_Core_Factory_Db->createDb()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:99
>
> [...]
>
> 596. Horde_Core_Factory_Cache->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:162
> 597. Horde_Core_Factory_Db->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Cache.php:82
> 598. Horde_Core_Factory_Db->create()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:68
> 599. Horde_Core_Factory_Db->createDb()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:99
> 600. Horde_Db_Adapter_Base->__construct()  
> /usr/share/php5/PEAR/Horde/Core/Factory/Db.php:156
> 601. Horde_Db_Adapter_Pdo_Mysql->connect()  
> /usr/share/php5/PEAR/Horde/Db/Adapter/Base.php:143
> 602. Horde_Db_Adapter_Pdo_Base->connect()  
> /usr/share/php5/PEAR/Horde/Db/Adapter/Pdo/Mysql.php:63
>
> After starting from scratch on a test system (which worked out of  
> the box), I started changing the configuration to the old one, one  
> parameter at a time. As soon as I changed the $conf[cache][driver]  
> to SQL, the problem occurred again. Although a MySQL cache probably  
> sucks in terms of performance, this used to work on -stable version,  
> so this might be a bug.

There's a chicken/egg issue.  When instantiating the cache driver, we  
need an SQL object before we can create the cache object.  However,  
the SQL object requires a cache object (if configured), so it tries to  
create the cache object.  Since the cache object hasn't been fully  
created in step 1, another cache object is attempted to be created,  
etc. etc.

The problem is now exposing itself since the Cache driver was  
previously broken.  It was ignoring the configured SQL parameters in  
the cache configuration and ALWAYS using the default Horde  
configuration.  However, the cache SQL has always been allowed to be  
separately configured.

The only solution I see is to ignore caching for a DB object *if* the  
cache object is a DB object (using a SQL DB to cache SQL DB results  
sort of defeats the whole purpose of caching anyway.  The overhead in  
caching is more than just doing the damn query in the first place).

But really, the correct solution is NOT to use SQL driver for caching.  
  I'm tempted to remove that driver all together.

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the horde mailing list