[imp] Hi guys - DESPERATE plea for help here...

Liam Hoekenga liamr at umich.edu
Thu May 1 09:31:54 PDT 2003


> I'm guessing it's because I've set connection timeout to be 10 seconds in
> mysql - Which I believe I set because I was under the impression that this
> was good practice as you can never guarantee that the same apache daemon
> will perform every operation that a user does anyway.

While that's true.. it's not applicable.  It doesn't matter for database
connections. Horde connects to your database as the user you defined in
the config files (usually "horde").  It does all database transactions as
/that/ user, regardless of the end user using IMP.

We'd tried doing something similar to limit the number of open connections
that our database would have to support... because each apache process
doing horde stuff will open a connection, and that can add up (especially
in large installations).  The better way to guarentee that each
transaction for each user got a fresh database connection would be to
prevent horde from opening persistant database connections rather than
setting an idle timeout for the database.

Horde expects to have a persistant database connection - it's really good
at opening a new database connection when a new apache child process has
been spawned, but not particularly good at reopening a connection that has
been closed for some reason (eg your database rebooted, or you set a
connection time out on the database side).  I'm not sure if that's a PHP
function or the way the Horde database stuff is written, but once the
connection's there, it's doesn't handle loosing it particularly
gracefully.

Probably the easiest way to keep it from using persistant connections is
to disable them in php.ini...

    ; Allow or prevent persistent links.
    mysql.allow_persistent = On

Otherewise, you'd have to go into the horde/lib/Prefs/sql.php and change

    $this->db = &DB::connect($this->params, true)

to

    $this->db = &DB::connect($this->params, false)

You have to weigh a large number of connections that are open all the time
verses PHP constantly opening and closing database connections.  Reusing
one connection for many actions has less overhead than opening and closing
a connection for every action.

Liam


More information about the imp mailing list