Re: [gnome-db] Threads.





2009/7/24 Bas Driessen <bas driessen xobas com>
On Fri, 2009-07-24 at 21:44 +1000, Bas Driessen wrote:
On Fri, 2009-07-24 at 21:39 +1000, Bas Driessen wrote:
Hello,

Question regarding libgda and threads.

I open a data source connection (ie: gda_connection_open_from_dsn) in thread 1 and then I try to perform any action on the connection (ie: gda_connection_statement_execute_select) in thread 2. If I do this in Postgresql all works fine. If I try to do this in MySQL then the system appears to hang in thread 2. I assume because thread 1 is holding a lock on the connection.

How can I remove the lock that is set by function gda_connection_open_from_dsn so I can access the connection information from thread 2?

Perhaps slightly out of libgda scope, but is there a difference between Postgresql and MySQL when it comes to threads and locking? It appears that Postgresql does not have that concept or perhaps by default configured not to use threads?

I think I found the answer in the manual:

"If MySQL client was not compiled with the --enable-thread-safe-client flag, then the database provider will only allow connections to be opened from the thread which initializes Libgda. Otherwise there is no limitation."
No, that is not it. The configure flags as follows:
 


--with-readline \
        --with-ssl=/usr \
        --without-debug \
        --enable-shared \
        --with-embedded-server \
        --localstatedir=/var/lib/mysql \
        --with-unix-socket-path=/var/lib/mysql/mysql.sock \
        --with-mysqld-user="mysql" \
        --with-extra-charsets=all \
        --with-big-tables \
        --with-innodb \
        --with-ndbcluster \
        --enable-local-infile \
        --enable-largefile \
        --enable-thread-safe-client \
        --disable-dependency-tracking \
        --with-named-thread-libs="-lpthread"

Sorry, it was just a general remark about PostgreSQL, not about your current settings.
 


The --enable-thread-safe-client flag is set. Therefore my original question. How can I remove the lock that is set by function gda_connection_open_from_dsn so I can access the connection information from thread 2?

Normally gda_connection_open_from_dsn() does not lock the connection, using the connection from a thread (for example running a statement) automatically locks it, and it's being unlocked only when the object is not used anymore.
 
You can check anytime if you can have a lock on a connection using gda_lockable_trylock().

Vivien




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