Hello,

I'm currently using sqlobject (current svn) in conjunction with cherrypy
(also current svn) and postgresql 8.1 for a project where I experienced
some problems while using transactions with quite a few concurrent users.

Basically, after committing a transaction it won't get cleared from
memory. As it, too, won't get marked obsolete by
ConnectionHub.doInTransaction() the connection associated for it won't get
disconnected either. But although marked obsolete, the transactions-object
won't get deleted by the garbage collector, though, by a quick look at the
code, not being referenced anywhere else.

Here's a sketch of code for reproducing the problem:

import cherrypy
from sqlobject import *
from sqlobject.postgres.pgconnection import PostgresConnection

conn = dbconnection.ConnectionHub()

class FieldUserStart(SQLObject):
    class sqlmeta:
        cacheValues = False

    _connection = conn
    x = IntCol()
    y = IntCol()

def doInTrans(f):
    def ret(*args, **kwargs):
        return conn.doInTransaction(f, *args, **kwargs)
    return ret

class Root:
    @cherrypy.expose
    @doInTrans
    def index(self):
        FieldUserStart(x=1, y=2)
        data = FieldUserStart.select()
        for i in data:
            pass
        return ''

def connect(threadId):
    conn.threadConnection = PostgresConnection(...)

cherrypy.config.update({'server.thread_pool': 5})

# Connection will be established on thread start
cherrypy.server.onStartThreadList = [connect]

cherrypy.root = Root()
cherrypy.server.start()

While running this programm and calling "ab -n 100 -c 5 localhost:8080"
with an unpatched version of sqlobject, new connections will be created
until the limit of postgresql for a non-super-user is reached.

When ensuring obsoletion of the transaction-object by modifying
ConnectionHub.doInTransaction (first argument of Transaction.commit:
close=True) and continously running ab, a significant increase of memory
use can be observed. (cacheValues = False!)

By adding a print to Transaction.__del__ I can confirm that no
transaction-object actually ever gets cleared!

So whats wrong here? ;)

Franz


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to