Hey ashaner,
Sorry for the delay, Ive been off work for a while (taking 3 days
holiday to get 11 days off is awesome :)).
Anyway, Im looking at it again now and any help is much appreciated.
On Apr 21, 6:41 pm, ashaner <
asha...@chumpland.org> wrote:
> I feel your pain, however it might help to state exactly which version
> freetds, unixodbc, etc. you are using. I probably can't give you a
Woops, didnt think to include those! I went through and got all the
versions I could find:
SQL Server - 2005/2008 (results were identical)
Ubuntu - 10.04.2 LTS
FreeTDS - 0.82 (tried 0.91.dev.20110415RC2 but it was seg-faulting)
UnixODBC - 2.2.11-21
PyODBC - 2.1.8
Django PyODBC - ? (see below)
Django - 1.3.0
uWSGI - 0.9.7.2
Nginx - 0.8.54
I couldnt find a version for Django PyODBC so compared the latest svn
trunk to the version I used for the tests and there were no
significant changes.
> definitive answer, however I will say that I've experienced a lot of
> problems with python threads and/or pyodbc, freetds and unixodbc
> (especially the 0.82 versions of freetds). Most of my pain was when
> unixODBC jumped to 2.3.0 on my distro, but freetds is still 0.82.
> Ultimately I ended up getting a nightly build of freetds (0.83 series)
> working with unix ODBC 2.3.0 that seemed to resolve the threading
> issues, however I've also rewritten my big threaded apps to multi
> process instead since the python GIL makes threading kind of a pain in
> some cases.
Yeah, I tried compiling a newer version of FreeTDS but either I went
for a version that was too new or I did something wrong. I didnt see
any of the errors I was getting previously but it started seg-faulting
after a random amount of DB hits. Ill see if I can get source for an
earlier version (probably start with 0.83 and work up) - even though
my UnixODBC is still 2.2, it could still work.
> Though not necessarily thread/process issue, you may want to try this
> simple test in a python shell:
>
> conn = pyodbc.connect(dsn)
> cursor1 = conn.cursor()
> cursor1.execute('select null')
> cursor2 = conn.cursor()
> cursor2.execute('select null')
>
> When you stated you where sharing connections/cursors between
> threads/processes, I believe you would definitely have an issue if you
> try to use 2 cursors on the same connection unless each cursor is
> explicitly closed before the next one is used. In my example above, I
> get an error on the last line, but not if I call cursor1.close()
> before doing the cursor2 work.
Yeah, after I ran my tests with sharing connections/cursors, I realise
this doesnt (& probably shouldnt) work.
> Unless I missed it, can you provide the exact error when your calls
> fail? Maybe it's in your nginx error log?
Woops, forgot that too!
The nginx errors probably arent very useful but they are:
~64%: connect() failed (111: Connection refused) while connecting to
upstream, client: 172.17.125.153, server: localhost, request: "POST /
common/ajax/set_component_state/ HTTP/1.1", upstream: "uwsgi://
127.0.0.1:3035", host: "aam-webtest-1", referrer: "
http://aam-
webtest-1/complex/553/hub/"
~32%: upstream prematurely closed connection while reading response
header from upstream, client: 172.17.125.153, server: localhost,
request: "GET /alert/ajax/get_hub_alerts_datatable/complex/153/?
_=1303232433932 HTTP/1.1", upstream: "uwsgi://
127.0.0.1:3031", host:
"aam-webtest-1", referrer: "
http://aam-webtest-1/complex/153/hub/"
~4%: recv() failed (104: Connection reset by peer) while reading
response header from upstream, client: 172.17.125.153, server:
localhost, request: "POST /login/ HTTP/1.1", upstream: "uwsgi://
127.0.0.1:3031", host: "aam-webtest-1", referrer: "
http://aam-
webtest-1/login/?next=/complex/553/hub/"
I think the connect() and upstream errors are actually the same but it
shows the upstream error when I configure it with an upstream cluster.
The SQL errors only get printed to the uWSGI shell at the moment so
Ive lost them from my extensive testing before. So, Ive just done some
more testing (using the js console way) and the results are:
~53%: pyodbc.Error: ('08S01', '[08S01] [FreeTDS][SQL Server]Write to
the server failed (20006) (SQLPrepare)')
~44%: pyodbc.Error: ('01000', '[01000] [FreeTDS][SQL Server]Unexpected
EOF from the server (20017) (SQLPrepare)')
~3%: pyodbc.Error: ('HY000', 'The driver did not supply an error!')
I also remember getting one about 'could not find prepared statement
0' before. I think they all happen pretty randomly.
On the SQL server, there's nothing in event viewer or the logs in the
management section in management studio. Not sure if there are any
other logs I can look at?
Ill try compiling various FreeTDS versions after lunch & see if that
helps.
Thanks again,
Nick