Re: transaction abort with multiple threads

Joachim Worringen <[email protected]> Wed, 19 May 2010 13:55:53 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Organization IAT GmbH
Message-ID <[email protected]>
On 05/19/2010 01:26 PM, Daniele Varrazzo wrote:
> Do you call commit()/rollback() in your threads or just cur.execute()?

I only call execute(), and close() when I'm done.

> If you don't, the only race condition possible seems if two threads
> call the first command concurrently and two begin are sent (which is
> only possible if we have broken the lock). In this case a workaround
> would be to force the transaction start outside the threaded part
> (e.g. executing a "select 1" on a cursor before starting the thread).
> You could make this check to test what is the more efficient way to
> run your code.

Will do so.

> If you could run psycopg in debug mode (compiled with PSYCOPG_DEBUG in
> the setup.cfg flags and running with the PSYCOPG_DEBUG env var), the
> debug log in case of crash would be very useful.

I can do this, maybe today.

  Joachim