Closed
Description
Migrated issue, originally created by Anonymous
Occasionally we've hit this KeyError
with Oracle 8i:
return Query.__iter__(self)
File 'build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py', line 2205 in __iter__
File 'build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py', line 2218 in _execute_and_instances
File 'build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py', line 2209 in _connection_from_session
File 'build/bdist.linux-x86_64/egg/sqlalchemy/orm/session.py', line 732 in connection
File 'build/bdist.linux-x86_64/egg/sqlalchemy/orm/session.py', line 736 in _connection_for_bind
File 'build/bdist.linux-x86_64/egg/sqlalchemy/orm/session.py', line 266 in _connection_for_bind
File 'build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py', line 2476 in contextual_connect
File 'build/bdist.linux-x86_64/egg/sqlalchemy/pool.py', line 224 in connect
File 'build/bdist.linux-x86_64/egg/sqlalchemy/pool.py', line 387 in __init__
File 'build/bdist.linux-x86_64/egg/sqlalchemy/pool.py', line 739 in _do_get
File 'build/bdist.linux-x86_64/egg/sqlalchemy/pool.py', line 188 in _create_connection
File 'build/bdist.linux-x86_64/egg/sqlalchemy/pool.py', line 273 in __init__
File 'build/bdist.linux-x86_64/egg/sqlalchemy/event.py', line 282 in exec_once
File 'build/bdist.linux-x86_64/egg/sqlalchemy/event.py', line 291 in __call__
File 'build/bdist.linux-x86_64/egg/sqlalchemy/engine/strategies.py', line 167 in first_connect
File 'build/bdist.linux-x86_64/egg/sqlalchemy/dialects/oracle/cx_oracle.py', line 564 in initialize
File 'build/bdist.linux-x86_64/egg/sqlalchemy/dialects/oracle/base.py', line 696 in initialize
KeyError: <class 'sqlalchemy.types.Interval'>
The initialize()
code is here:
def initialize(self, connection):
super(OracleDialect, self).initialize(connection)
self.implicit_returning = self.__dict__.get(
'implicit_returning',
self.server_version_info > (10, )
)
if self._is_oracle_8:
self.colspecs = self.colspecs.copy()
self.colspecs.pop(sqltypes.Interval)
self.use_ansi = False
Question: is there a legitimate reason to be inside initialize()
more than once? Apparently that is what has happened here because the .pop(sqltypes.Interval) has already been run on self.colspecs.
I'm guessing the real problem is with the connection pool or something and sqlalchemy thinks it needs to initialize this since it isn't properly connected?
Attachments: 2776.patch | 2776_test.patch
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
sqlalchemy-bot commentedon Jul 9, 2013
Anonymous wrote:
Note that this was preceded by
OperationalError: (OperationalError) ORA-03113: end-of-file on communication channel
, but the question is: does SQLAlchemy usually have no problem reconnecting and this is an Oracle 8i problem because of the pop code above?''I've answered my question: "Yes, usually SQLAlchemy will reconnect and invoke initialize() a subsequent time."''
sqlalchemy-bot commentedon Jul 9, 2013
Anonymous wrote:
Possible patch
sqlalchemy-bot commentedon Jul 9, 2013
Changes by Anonymous:
sqlalchemy-bot commentedon Jul 9, 2013
Michael Bayer (@zzzeek) wrote:
intiialize() on a dialect shouldn't be called more than once, so if this is a side effect of engine/pool recycle, I'd want to look into that at a more fundamental level.
sqlalchemy-bot commentedon Jul 9, 2013
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jul 9, 2013
Anonymous wrote:
Note that I ran this test on an Oracle 10 database and bounced the database. The same dialect object's initialize() ''was'' invoked a subsequent time and it continued working fine thereafter. So apparently, this works this way "normally" but the oracle 8 clause is messing it up:
sqlalchemy-bot commentedon Jul 9, 2013
Michael Bayer (@zzzeek) wrote:
i've attached a unit test for this.
sqlalchemy-bot commentedon Jul 11, 2013
Anonymous wrote:
let me know if i could/should help on this ticket.
sqlalchemy-bot commentedon Jul 11, 2013
Michael Bayer (@zzzeek) wrote:
OK...well should be resolved:
9a95a39 0.8.3
fd55be0 master
sqlalchemy-bot commentedon Jul 11, 2013
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jul 12, 2013
Anonymous wrote:
Certainly stops Dialect.initialize() from being invoked again, thanks!
P.S. Not functionally important, but in
lib/sqlalchemy/util/langhelpers.py
you stuck thedef only_once()
decorator in between thechop_traceback()
definition and its constants:sqlalchemy-bot commentedon Jul 12, 2013
Michael Bayer (@zzzeek) wrote:
yup, 269a166 1e332e0, thanks
2 remaining items