6.0.0-beta1
7/18/25

[#8671] Nag::listAlarms fails when called from the scripts/alarms.php cron job
Summary Nag::listAlarms fails when called from the scripts/alarms.php cron job
Queue Nag
Queue Version 2.3.3
Type Bug
State Resolved
Priority 2. Medium
Owners
Requester Valentin.Vidic (at) carnet (dot) hr
Created 11/02/2009 (5737 days ago)
Due
Updated 02/20/2011 (5262 days ago)
Assigned 02/20/2011 (5262 days ago)
Resolved 02/20/2011 (5262 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
02/20/2011 01:54:59 AM Chuck Hagenbuch Comment #8
Taken from Horde DevelopersHorde Developers
State ⇒ Resolved
Reply to this comment
Horde_Db + the injector solve this
02/20/2011 01:54:36 AM Chuck Hagenbuch Assigned to Horde DevelopersHorde Developers
State ⇒ Assigned
 
08/15/2010 04:06:15 PM Michael Rubinsky Comment #7 Reply to this comment
DB::connect(), is indeed, not a singleton. Instead of using factory 
(which I'm guessing helps because the object isn't cached), we should 
probably cache the DB object so we don't need to keep recreating it.

This will be moot for Horde 4, though which will use Horde_Db.
11/12/2009 04:50:55 PM Valentin (dot) Vidic (at) carnet (dot) hr Comment #6 Reply to this comment
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.
I can't find any singleton functionality in DB.php. Perhaps you are 
talking about MDB2, but nag is still using the old DB interface.
11/12/2009 04:36:21 PM Jan Schneider Comment #5 Reply to this comment
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.
11/12/2009 04:03:42 PM Valentin (dot) Vidic (at) carnet (dot) hr Comment #4 Reply to this comment
That doesn'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.
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'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'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.
11/07/2009 01:26:39 PM Jan Schneider Comment #3
State ⇒ Feedback
Summary ⇒ Nag::listAlarms fails when called from the scripts/alarms.php cron job
Reply to this comment
That doesn'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.
11/02/2009 04:09:18 PM Valentin (dot) Vidic (at) carnet (dot) hr Comment #2
New Attachment: nag.diff Download
Reply to this comment
It seems that using factory instead of singleton when $tasklist is set 
helps. Patch attached.
11/02/2009 03:49:45 PM Valentin (dot) Vidic (at) carnet (dot) hr Comment #1
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Queue ⇒ Nag
Summary ⇒ Nag::listAlarms fails when called from the scritps/alarms.php cron job
Type ⇒ Bug
Reply to this comment
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 
"/srv/webmail/www/lib/Horde/Alarm.php"]

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 'Too many connections'. 
Perhaps a single database connection could be used or old connections 
can be closed?

Saved Queries