zzzeek / test_sqlalchemy

0 stars 0 forks source link

ResultProxy fetches don't wrap DBAPI exceptions #978

Closed sqlalchemy-bot closed 16 years ago

sqlalchemy-bot commented 16 years ago

Issue created by Anonymous


I was using SQLALchemy 0.4.3 to read a simple Oracle table in an endless loop when I shut down the server (on purpose). Apparently this was noticed after the query was executed but during the fetches on the ResultProxy. The resulting cx_Oracle exception was not wrapped in a subclass of DBAPIError. The following code reproduces the problem reliably if you have the server up at the start then take it down before hitting Return.

import sys

from sqlalchemy import (create_engine, MetaData, Table, Column,
                        Integer, String)

engine = create_engine(sys.argv[1](1))
meta = MetaData(bind=engine)
example = Table("example",
                meta,
                Column("id", Integer, primary_key=True),
                Column("name", String(20))
                )
meta.drop_all()
meta.create_all()
example.insert().execute(id=1, name="George")
example.insert().execute(id=2, name="Ursula")
example.insert().execute(id=3, name="Ape")
example.insert().execute(id=4, name="Shep")
example.insert().execute(id=5, name="TookieTookie")

rows = example.select().execute()
raw_input("Type return when the server is down.")
print list(rows)

Type return when the server is down.
Traceback (most recent call last):
  File "sabug.py", line 23, in <module>
    print list(rows)
  File "/tmp/SQLAlchemy-0.4.3/lib/sqlalchemy/engine/base.py", line 1533, in __iter__
    row = self.fetchone()
  File "/tmp/SQLAlchemy-0.4.3/lib/sqlalchemy/engine/base.py", line 1633, in fetchone
    row = self._fetchone_impl()
  File "/tmp/SQLAlchemy-0.4.3/lib/sqlalchemy/engine/base.py", line 1608, in _fetchone_impl
    return self.cursor.fetchone()
cx_Oracle.DatabaseError: ORA-03113: end-of-file on communication channel

Attachments: result_catches.patch

sqlalchemy-bot commented 10 years ago

Michael Bayer (zzzeek) wrote:


Removing milestone: 0.4.6 (automated comment)

sqlalchemy-bot commented 16 years ago

Michael Bayer (zzzeek) wrote:


going to leave 0.3 alone

sqlalchemy-bot commented 16 years ago

Michael Bayer (zzzeek) wrote:


0.4 version is fixed in 47418e0f87cb432e0d813c7c30e43822fa479e9e

sqlalchemy-bot commented 16 years ago

Michael Bayer (zzzeek) wrote:


er, 0.3 doesn't have the infrastructure needed for this in place; theres several other places the catch is needed including set_input_sizes(), which is used by oracle. The reconnect logic itself was also overhauled in 0.4 as it wasn't working that great in 0.3...so a backport from 0.4 into 0.3 would be a significant job. It would be less work overall if you could upgrade to 0.4, its a pretty easy upgrade path since you can move to 0.3.11, make your app forwards-compatible with 0.4, then move to 0.4.

sqlalchemy-bot commented 16 years ago

Michael Bayer (zzzeek) wrote:


ive attached a patch for this, i was wondering can you just test this out with your particular setup ? I think we can probably add tests to test/engine/reconnect.py for this particular issue as well.

sqlalchemy-bot commented 16 years ago

Anonymous wrote:


That works, thanks. By the way, I see the same thing in 0.3.6 so you may need to patch 0.3.11 as well.

sqlalchemy-bot commented 10 years ago

Changes by Michael Bayer (zzzeek): removed "0.4.6" milestone

sqlalchemy-bot commented 16 years ago

Changes by Michael Bayer (zzzeek): set state to "resolved"

sqlalchemy-bot commented 16 years ago

Changes by Michael Bayer (zzzeek): changed component from "(none)" to "sql"; set milestone to "0.4.4"