2013-03-12 124 views
1

由於某種原因,sqlalchemy處置連接池時出現問題,我不知道爲什麼。 這是日誌我:sqlalchemy在創建新連接後立即處理連接池

2013-03-12 15:04:28 [19800] [DEBUG] Arbiter booted 
2013-03-12 15:04:28 [19800] [INFO] Listening at: http://127.0.0.1:8000 (19800) 
2013-03-12 15:04:28 [19800] [INFO] Using worker: gevent 
2013-03-12 15:04:28 [19881] [INFO] Booting worker with pid: 19881 
2013-03-12 15:04:29 [19881] [DEBUG] Created new connection <_mysql.connection open to 'XXX' at 8fb07a4> 
2013-03-12 15:04:29 [19881] [INFO] SELECT DATABASE() 
2013-03-12 15:04:29 [19881] [INFO]() 
2013-03-12 15:04:29 [19881] [INFO] Pool disposed. Pool size: 10 Connections in pool: 0 Current Overflow: -10 Current Checked out connections: 0 
2013-03-12 15:04:29 [19881] [INFO] Pool recreating 

這是最新的0.8.0版本的SQLAlchemy和Solaris上的MySQL 5.5的Oracle Solaris 10 9/10 s10x_u9wos_14a X86

編輯:

這裏是一個更詳細的轉儲失敗:

Created new connection <_mysql.connection open to 'XXXX' at 8bcb704> 
SELECT DATABASE() 
() 
Pool disposed. Pool size: 10 Connections in pool: 0 Current Overflow: -10 Current Checked out connections: 0 
Pool recreating 
Traceback (most recent call last): 
    File "/test/test_sqlalchemy.py", line 31, in <module> 
    result = db.session.execute("select * from app_config") 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 149, in do 
    return getattr(self.registry(), name)(*args, **kwargs) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 931, in execute 
    return self._connection_for_bind(bind, close_with_result=True).execute(
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 801, in _connection_for_bind 
    return self.transaction._connection_for_bind(engine) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 297, in _connection_for_bind 
    conn = bind.contextual_connect() 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1669, in contextual_connect 
    self.pool.connect(), 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 272, in connect 
    return _ConnectionFairy(self).checkout() 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 425, in __init__ 
    rec = self._connection_record = pool._do_get() 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 777, in _do_get 
    con = self._create_connection() 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 225, in _create_connection 
    return _ConnectionRecord(self) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/pool.py", line 322, in __init__ 
    exec_once(self.connection, self) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/event.py", line 392, in exec_once 
    self(*args, **kw) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/event.py", line 409, in __call__ 
    fn(*args, **kw) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 167, in first_connect 
    dialect.initialize(c) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2055, in initialize 
    default.DefaultDialect.initialize(self, connection) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 171, in initialize 
    self._get_default_schema_name(connection) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2022, in _get_default_schema_name 
    return connection.execute('SELECT DATABASE()').scalar() 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 664, in execute 
    params) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 808, in _execute_text 
    statement, parameters 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 878, in _execute_context 
    context) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 871, in _execute_context 
    context) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 320, in do_execute 
    cursor.execute(statement, parameters) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute 
    self.errorhandler(self, exc, value) 
    File "/test/bss/server/bss/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler 
    raise errorclass, errorvalue 
sqlalchemy.exc.InterfaceError: (InterfaceError) (0, '') 'SELECT DATABASE()'() 

任何想法是什麼問題?

+0

你能告訴我們一些關於你如何創建引擎,會話等的代碼,並且你可以跟蹤它在哪裏配置你的池嗎? – javex 2013-03-13 22:44:45

+0

它看起來像你的MySQL-python適配器出現故障,就像它的構建不正確,或者你的數據庫出了問題。它建立了一個連接,但是在發出第一個SQL時失敗了。 – zzzeek 2013-03-14 18:43:53

+0

我正面臨同樣的問題。 – wakeup 2013-06-04 09:20:53

回答

0

我不知道是什麼原因導致這個問題,但用MySQL而不是mysql-python一切正常。

+0

任何其他解決方案,然後更改適配器? – wakeup 2013-06-04 09:21:11