Issue 1:
Migrated issue, originally created by Michael Bayer (@zzzeek)

stack trace for reserved bind names only on the second go, meaning the insert() has changed state upon compile():

import sqlalchemy as sa

meta = sa.MetaData()
table = sa.Table('mytable', meta,
sa.Column('foo', sa.String),
sa.Column('bar', sa.String, default='baz'),
)

select = sa.select([table.c.foo])
insert = table.insert().from_select(['foo'], select)

print insert.compile()
print insert.compile()

Issue 2:
Migrated issue, originally created by Michael Bayer (@zzzeek)

these may all be from test_baked not cleaning up connections

#!

_ ERROR at teardown of ResultTest_postgresql_psycopg2cffi.test_w_new_entities __
[gw0] linux2 -- Python 2.7.8 /var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/bin/python
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/testing/fixtures.py", line 273, in teardown_class
cls._teardown_once_metadata_bind()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/testing/fixtures.py", line 155, in _teardown_once_metadata_bind
drop_all_tables(cls.metadata, cls.bind)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/testing/engines.py", line 108, in drop_all_tables
metadata.drop_all(bind)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/sql/schema.py", line 3641, in drop_all
tables=tables)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 1850, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File "/opt/pypy-python2.7/lib-python/2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 1843, in _optional_conn_ctx_manager
with self.contextual_connect() as conn:
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2034, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2069, in _wrap_pool_connect
return fn()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 376, in connect
return _ConnectionFairy._checkout(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 708, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 480, in checkout
rec = pool._do_get()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 1042, in _do_get
(self.size(), self.overflow(), self._timeout))
TimeoutError: QueuePool limit of size 5 overflow 0 reached, connection timed out, timeout 0
--------------------------- Captured stdout teardown ---------------------------
2015-05-01 01:44:56,618 ERROR sqlalchemy.pool.QueuePool Exception during reset or similar
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 631, in _finalize_fairy
fairy._reset(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 765, in _reset
pool._dialect.do_rollback(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/default.py", line 412, in do_rollback
dbapi_connection.rollback()
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/connection.py", line 42, in check_closed_
raise exceptions.InterfaceError('connection already closed')
InterfaceError: connection already closed
2015-05-01 01:44:56,619 ERROR sqlalchemy.pool.QueuePool Exception during reset or similar
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 631, in _finalize_fairy
fairy._reset(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 765, in _reset
pool._dialect.do_rollback(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/default.py", line 412, in do_rollback
dbapi_connection.rollback()
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/connection.py", line 42, in check_closed_
raise exceptions.InterfaceError('connection already closed')
InterfaceError: connection already closed
2015-05-01 01:44:56,620 ERROR sqlalchemy.pool.QueuePool Exception during reset or similar
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 631, in _finalize_fairy
fairy._reset(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 765, in _reset
pool._dialect.do_rollback(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/default.py", line 412, in do_rollback
dbapi_connection.rollback()
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/connection.py", line 42, in check_closed_
raise exceptions.InterfaceError('connection already closed')
InterfaceError: connection already closed
2015-05-01 01:44:56,621 ERROR sqlalchemy.pool.QueuePool Exception during reset or similar
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 631, in _finalize_fairy
fairy._reset(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 765, in _reset
pool._dialect.do_rollback(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/default.py", line 412, in do_rollback
dbapi_connection.rollback()
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/connection.py", line 42, in check_closed_
raise exceptions.InterfaceError('connection already closed')
InterfaceError: connection already closed
2015-05-01 01:44:56,621 ERROR sqlalchemy.pool.QueuePool Exception during reset or similar
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 631, in _finalize_fairy
fairy._reset(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 765, in _reset
pool._dialect.do_rollback(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/default.py", line 412, in do_rollback
dbapi_connection.rollback()
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/connection.py", line 42, in check_closed_
raise exceptions.InterfaceError('connection already closed')
InterfaceError: connection already closed
=================================== FAILURES ===================================
________ ResultTest_postgresql_psycopg2cffi.test_spoiled_half_w_params _________
[gw0] linux2 -- Python 2.7.8 /var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/bin/python
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/test/ext/test_baked.py", line 341, in test_spoiled_half_w_params
bq.spoil().add_criteria(fn3)(sess).params(id=7).all(),
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/ext/baked.py", line 295, in all
return list(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/ext/baked.py", line 241, in __iter__
return iter(self._as_query())
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2515, in __iter__
return self._execute_and_instances(context)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2528, in _execute_and_instances
close_with_result=True)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2519, in _connection_from_session
**kw)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 882, in connection
execution_options=execution_options)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 887, in _connection_for_bind
engine, execution_options)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 334, in _connection_for_bind
conn = bind.contextual_connect()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2034, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2069, in _wrap_pool_connect
return fn()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 376, in connect
return _ConnectionFairy._checkout(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 708, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 480, in checkout
rec = pool._do_get()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 1042, in _do_get
(self.size(), self.overflow(), self._timeout))
TimeoutError: QueuePool limit of size 5 overflow 0 reached, connection timed out, timeout 0
________ ResultTest_postgresql_psycopg2cffi.test_subquery_eagerloading _________
[gw0] linux2 -- Python 2.7.8 /var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/bin/python
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/test/ext/test_baked.py", line 527, in test_subquery_eagerloading
self.assert_sql_count(testing.db, go, 2)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/testing/assertions.py", line 466, in assert_sql_count
db, callable_, assertsql.CountStatements(count))
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/testing/assertions.py", line 447, in assert_sql_execution
callable_()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/test/ext/test_baked.py", line 525, in go
result = bq(sess).all()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/ext/baked.py", line 295, in all
return list(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/ext/baked.py", line 257, in __iter__
with_session(self.session)._execute_and_instances(context)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2528, in _execute_and_instances
close_with_result=True)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2519, in _connection_from_session
**kw)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 882, in connection
execution_options=execution_options)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 887, in _connection_for_bind
engine, execution_options)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 334, in _connection_for_bind
conn = bind.contextual_connect()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2034, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2069, in _wrap_pool_connect
return fn()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 376, in connect
return _ConnectionFairy._checkout(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 708, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 480, in checkout
rec = pool._do_get()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 1042, in _do_get
(self.size(), self.overflow(), self._timeout))
TimeoutError: QueuePool limit of size 5 overflow 0 reached, connection timed out, timeout 0
____________ ResultTest_postgresql_psycopg2cffi.test_w_new_entities ____________
[gw0] linux2 -- Python 2.7.8 /var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/bin/python
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/test/ext/test_baked.py", line 368, in test_w_new_entities
bq(session).all(),
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/ext/baked.py", line 295, in all
return list(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/ext/baked.py", line 257, in __iter__
with_session(self.session)._execute_and_instances(context)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2528, in _execute_and_instances
close_with_result=True)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/query.py", line 2519, in _connection_from_session
**kw)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 882, in connection
execution_options=execution_options)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 887, in _connection_for_bind
engine, execution_options)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 334, in _connection_for_bind
conn = bind.contextual_connect()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2034, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 2069, in _wrap_pool_connect
return fn()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 376, in connect
return _ConnectionFairy._checkout(self)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 708, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 480, in checkout
rec = pool._do_get()
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/pool.py", line 1042, in _do_get
(self.size(), self.overflow(), self._timeout))
TimeoutError: QueuePool limit of size 5 overflow 0 reached, connection timed out, timeout 0
_________ ExecutionTest_postgresql_psycopg2cffi.test_parameter_execute _________
[gw0] linux2 -- Python 2.7.8 /var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/bin/python
Traceback (most recent call last):
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/test/orm/test_session.py", line 61, in test_parameter_execute
{"id": 8, "name": "u8"}
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/orm/session.py", line 1023, in execute
bind, close_with_result=True).execute(clause, params or {})
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
compiled_sql, distilled_params
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
context)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 1339, in _handle_dbapi_exception
exc_info
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/base.py", line 1116, in _execute_context
context)
File "/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.tox/full/site-packages/sqlalchemy/engine/default.py", line 439, in do_executemany
cursor.executemany(statement, parameters)
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 26, in check_closed_
return func(self, *args, **kwargs)
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 49, in check_async_
return func(self, *args, **kwargs)
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 286, in executemany
self.execute(query, params)
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 26, in check_closed_
return func(self, *args, **kwargs)
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 259, in execute
self._pq_execute(self._query, conn._async)
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 692, in _pq_execute
self._pq_fetch()
File "/opt/pypy-python2.7/site-packages/psycopg2cffi/_impl/cursor.py", line 753, in _pq_fetch
raise self._conn._create_exception(cursor=self)
IntegrityError: (psycopg2cffi._impl.exceptions.IntegrityError) duplicate key value violates unique constraint "users_pkey"
DETAIL: Key (id)=(7) already exists.
[SQL: u'INSERT INTO users (id, name) VALUES (%(id)s, %(name)s)'] [parameters: ({'id': 7, 'name': 'u7'}, {'id': 8, 'name': 'u8'})]