Re: [gnome-db] GDA3 and forked application





2009/3/11 Piotr Pokora <piotrek pokora gmail com>
Hi!

I started to talk with Vivien offlist but thought this place will be
better, as more heads to think is faster problem resolving :) Basically,
I am running PHP5 module with Apache2 forked (traditional) model and
GDA3 as DB abstraction layer. Problems starts to appear when child
processes die (or killed explicitly). I started to debug issue a bit and
now I found this:

1. I lost connection to MySQL provider when child dies.
2. gda_mysql_provider_close_connection is executed (101% sure), though
no idea where

       I used such wrap function:

       static void __gda_mysql_close(MYSQL *mysql, const gchar *msg)
       {
               g_warning("CLOSING MYSQL CONNECTION BECAUSE : %s", msg);
               mysql_close(mysql);
       }

       in gda_mysql_provider_close I replace mysql_close with:
        __gda_mysql_close (mysql, "provider_close_conn");

       And it's invoked any time, child is killed.

3. 'conn-closed' signal is not emitted

Now I wonder, why connection is closed explicitly when child dies? I
opened it in parent and want to keep it opened as long as parent exists.

I used such callback to conn-closed:

static void _disconnect_cnc_callback(GdaConnection *cnc,
               GdaConnectionEvent *event, gpointer ud)
{
       g_warning("DISCONNECT CALLBACK!");

       return;
}

g_signal_connect(G_OBJECT(connection), "error",
                       G_CALLBACK(_disconnect_cnc_callback), (gpointer)
ptr);

I am not sure this signal is never emitted. I am sure a callback is
never executed.
I must say I feel blind here, as there's nothing I could take control over.

Last, but not least: GDA3 3.0.4 self compiled with default flags.

I've just had the time to do some quick checks and found out that creating a connection, forking and using the connection in the child(ren) and parent processes is not safe and never will be. What you need to do is fork and open connections in the forked process(es).

Another solution which I have not tested but may work is create the connection, close it, fork and re-open the connection in the child(ren) (after usage, each child should then close its connection).

In any case, each child (and parent) need to have their own connection known to the database server.

Vivien


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]