Hi there,

We're experiencing what I suspect to be a nasty bug with SQLObject
version 0.10.2 (and, it seems earlier) when using Postgresql. I have not
tested it with later versions.

Any pointers to a fix would be appreciated!


Here's what happens, (I attach source below that illustrates the issue):

When you call dropTable on a SQLObject class, _inside a transaction_,
sqlobject creates a second connection to postgresql.  This connection
later deadlocks randomly with the first (which is sometimes busy inside
a transaction).  

I can't figure out why the deadlock happens, but the second connection
should never have been created to start with.

If you run the code below, you'll see that createTable works correctly.
This code does not illustrate the deadlock, only the extra connection.



Using PDB, we've narrowed it to the following:

In pgconnection.py, line:
163             if self.server_version[:3] <= "7.2":

the attribute access to server_version results in a "poor mans
aquisition" call to the method server_version on the Transaction's
_dbConnection (a PostgresConnection).

In there, on line:
304                 server_version = self.queryOne("SELECT version()")[0]

A query is executed on the underlying db connection.

This is where the extra connection is created (the original is already
in a transaction at this point).  If this query is done manually on the
Transaction object, instead of on its underlying connection, everything
works as it should.

So, it seems (from our limited understanding) that it should not have
gone this far, and rather should have executed the query on the
Transaction object itself.

We'd be very grateful for a suggestion as to how we can fix this!

Thanks
- Iwan Vosloo

--------------------------
The code:

# The connections can be observed by running this in a window while 
# stepping through the code below with pdb:
#
# while true; do clear; ps ax | grep postgres: ; sleep 0.5; done
#

import sqlobject

# Just make this point to your DB:
connectionURI = 'postgres://rhug:r...@localhost/rhug' 

conn = sqlobject.connectionForURI(connectionURI).transaction()

class TestMe(sqlobject.SQLObject):
    pass


import pdb; pdb.set_trace()

TestMe.createTable(connection=conn)
TestMe.dropTable(connection=conn)





------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to