<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Nag::listAlarms fails when called from the scripts/alarms.php cron job</title> 
  <pubDate>Fri, 10 Apr 2026 07:55:28 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/8671</link> 
  <atom:link rel="self" type="application/rss+xml" title="Nag::listAlarms fails when called from the scripts/alarms.php cron job" href="https://bugs.horde.org/ticket/8671/rss" /> 
  <description>Nag::listAlarms fails when called from the scripts/alarms.php cron job</description> 
 
   
   
  <item> 
   <title>The cron job that should trigger scheduled alarms constantly</title> 
   <description>The cron job that should trigger scheduled alarms constantly fails with this error:

Nov 02 16:32:32 HORDE [error] [nag] The Tasks backend is not currently available: DB Error: connect failed [pid 19885 on line 228 of &quot;/srv/webmail/www/lib/Horde/Alarm.php&quot;]

It seems the problem is in the call to Nag::listAlarms. This function creates a new database connection for each storage instance and after a few hundred users database returns the error &#039;Too many connections&#039;. Perhaps a single database connection could be used or old connections can be closed?</description> 
   <pubDate>Mon, 02 Nov 2009 15:49:45 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t56499</link> 
  </item> 
   
  <item> 
   <title>It seems that using factory instead of singleton when $taskl</title> 
   <description>It seems that using factory instead of singleton when $tasklist is set helps. Patch attached.</description> 
   <pubDate>Mon, 02 Nov 2009 16:09:18 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t56500</link> 
  </item> 
   
  <item> 
   <title>That doesn&#039;t make any sense because we use DB::connect() in </title> 
   <description>That doesn&#039;t make any sense because we use DB::connect() in the SQL driver which already is a singleton. Besides that we only have a single DB instance, the DB package also takes care of re-using open database connections.</description> 
   <pubDate>Sat, 07 Nov 2009 13:26:39 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t56560</link> 
  </item> 
   
  <item> 
   <title>&gt; That doesn&#039;t make any sense because we use DB::connect() i</title> 
   <description>&gt; That doesn&#039;t make any sense because we use DB::connect() in the SQL 
&gt; driver which already is a singleton. Besides that we only have a 
&gt; single DB instance, the DB package also takes care of re-using open 
&gt; database connections.

I added a print statement to connect and disconnect functions in DB/mysqli.php and called alarm cron job. It looks like DB connect get&#039;s called 2071 times (mostly from nag) without a single disconnect. And I would expect this as Nag::listAlarms gets called with a list of ~2000 users and for each user it calls Nag_Driver::singleton($user). Since the $user is part of the instance signature, it creates a new Nag_Driver_sql instance for each user. And I don&#039;t see it trying to reuse existing connections in DB.php or DB/mysqli.php. I think you can reproduce this just by creating kronolith and nag alarms for a large number of users.</description> 
   <pubDate>Thu, 12 Nov 2009 16:03:42 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t56700</link> 
  </item> 
   
  <item> 
   <title>DB::connect() is a singleton. Even if we create many Nag_Dri</title> 
   <description>DB::connect() is a singleton. Even if we create many Nag_Driver instances, DB::connect() should always return the same DB instance, and thus only use one db connection.</description> 
   <pubDate>Thu, 12 Nov 2009 16:36:21 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t56701</link> 
  </item> 
   
  <item> 
   <title>&gt; DB::connect() is a singleton. Even if we create many Nag_D</title> 
   <description>&gt; DB::connect() is a singleton. Even if we create many Nag_Driver 
&gt; instances, DB::connect() should always return the same DB instance, 
&gt; and thus only use one db connection.

I can&#039;t find any singleton functionality in DB.php. Perhaps you are talking about MDB2, but nag is still using the old DB interface.</description> 
   <pubDate>Thu, 12 Nov 2009 16:50:55 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t56702</link> 
  </item> 
   
  <item> 
   <title>DB::connect(), is indeed, not a singleton. Instead of using </title> 
   <description>DB::connect(), is indeed, not a singleton. Instead of using factory (which I&#039;m guessing helps because the object isn&#039;t cached), we should probably cache the DB object so we don&#039;t need to keep recreating it. 

This will be moot for Horde 4, though which will use Horde_Db.</description> 
   <pubDate>Sun, 15 Aug 2010 16:06:15 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t59623</link> 
  </item> 
   
  <item> 
   <title>Horde_Db + the injector solve this</title> 
   <description>Horde_Db + the injector solve this</description> 
   <pubDate>Sun, 20 Feb 2011 01:54:59 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8671#t61867</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
