For the life of me I couldn't figure that one out. Though I got a concise test
programm for it. I applied your patch Michael, and it helps with the strange
errors on select. But still eventually the programm Segmentation Fauls, no
message and nothing.
* Threading myself without cherrypy I couldn't reproduce the problem
* Stressing cherrypy alone without sqlalchemy I couldn't reproduce the problem
* Stressing both in concert only shows the behavior.
So atached you find a test programm that is both a small cherrypy app (cherrypy
2.1) and a little web stress tester.
Cheers,
Florian
Quoting Michael Bayer <[EMAIL PROTECTED]>:
> just did a google for "cx_oracle threadsafe" and came up with this:
>
> http://mail.python.org/pipermail/db-sig/2004-January/003897.html
>
> but then there also seems to be a more improved way as of 4.0.1 which
> is this:
>
> http://starship.python.net/crew/atuining/cx_Oracle/html/module.html
>
> So, threading support is false by default since it has a 10-15%
> performance hit. would we like this flag to be on by default ?
>
> heres a patch to apply to oracle.py in the 0.1 series, which will add
> 'threaded' as a keyword parameter to oracle's create_engine. try
> setting it to true and see if that fixes your problem:
>
> --- lib/sqlalchemy/databases/oracle.py (revision 1407)
> +++ lib/sqlalchemy/databases/oracle.py (working copy)
> @@ -106,9 +106,10 @@
> ]}
>
> class OracleSQLEngine(ansisql.ANSISQLEngine):
> - def __init__(self, opts, use_ansi = True, module = None, **params):
> + def __init__(self, opts, use_ansi = True, module = None,
> threaded=False, **params):
> self._use_ansi = use_ansi
> self.opts = self._translate_connect_args((None, 'dsn',
> 'user', 'password'), opts)
> + self.opts['threaded'] = threaded
> if module is None:
> self.module = cx_Oracle
> else:
>
>
>
> On May 15, 2006, at 10:13 AM, Florian Boesch wrote:
>
> > Hi,
> >
> > Selecting from multiple threads with thread-count > 10 my app:
> > * crashes without any error message
> > * starts spweing out
> > cx_Oracle.DatabaseError: Error while trying to retrieve text for
> > error ORA-12520
> > * crashes with:
> > *** glibc detected *** double free or corruption (fasttop):
> > 0x3eeff0b8 ***
> > * all of the above
> >
> > With 10 threads it seems to run rock-solid. With 11 it gets the errors
> > occasionally. with 50 it gets them quite reliably, with 200 you could
> > practically bet on the errors to happen. Though they don't show up
> > regularly,
> > mostly they happen fast or not for a long time.
> >
> > I get the error as well on Linux as on Windows.
> >
> > Any ideas what I can do (other then limiting my web-server to 10
> > threads)?
> >
> > Example Atached
> >
> > Cheers,
> > Florian
> >
> >
> >
> > <segmentation_fault.py>
>
>
import cherrypy, urllib, sys, thread
from sqlalchemy import *
engine = create_engine('oracle://dsn=mydb&user=myuser&password=mypass')
port = 58181
server_threads = 200
test_threads = 50
foo = Table(
'foo',
engine,
Column('id', Integer, Sequence('foo_seq'), primary_key=True),
)
class Root:
def test(self):
foo.select().execute()
foo.select().execute()
return 'asdf'
test.exposed = True
if sys.argv[1] == 'server':
cherrypy.root = Root()
cherrypy.config.update(
{
'server.environment':'production',
'server.threadPool':server_threads,
'server.socketPort':port,
})
cherrypy.server.start()
elif sys.argv[1] == 'test':
def test():
while 1:
urllib.urlopen('http://localhost:%s/test'%port).read()
for _ in range(test_threads):
thread.start_new_thread(test, ())
raw_input()