[patch] Premature close of postgres connection with multiple threads
|Reported by:||Maniac <Maniac@…>||Owned by:||adrian|
|Component:||Database layer (models, ORM)||Version:|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Postgres back-end shares one connection for many requests. This is generally okay since psycopg handles this correctly. It looks like somewhere (I haven't found exact place yet) users of shared connection close it explicitly while other processes working with it. This results in other processes crash with the exception "already closed".
I'm seeing this in action on a page with many images where each image generated by a view looking into database. When running under development server everything is ok since it' single-process. But when running under Apache with each reload some of the images sometimes turn blank. Exceptions of course aren't shown inside 'img' tags but I replaced them with <object data="..." type="text/plain"> and got the messages :-)
I use apache2, mod_python, postgresql 7.4
For now as a workaround I just commented out whole DatabaseWrapper.close() so the connection is destroyed when Apache child is dying and killing the Interpreter (as I'm guessing). So my Postgres complains periodically about dropped connection. Is there any place where the destruction can be hooked at (I'm not familiar with WSGI and all this handlers stuff that close)?
Change History (16)
comment:8 Changed 10 years ago by Maniac <Maniac@…>
- Summary changed from Premature close of postgres connection with multiple threads to [patch] Premature close of postgres connection with multiple threads
comment:10 Changed 10 years ago by Maniac <Maniac@…>
- Component changed from Admin interface to Database wrapper