Commit ·
204b4bc
1
Parent(s): 5e8c558
緊急修正: SET statement_timeout 直後にcommitしないとinitialize_dbが起動失敗
Browse files_set_statement_timeout の SET文がトランザクションを開始したまま
残るため、直後の initialize_db() の autocommit=True 切替が
"set_session cannot be used inside a transaction" で失敗していた。
SET実行後にcommitしてトランザクションを確定させる。
- db/database.py +5 -0
db/database.py
CHANGED
|
@@ -104,6 +104,11 @@ class Connection:
|
|
| 104 |
cur = self._conn.cursor()
|
| 105 |
cur.execute("SET statement_timeout = 15000")
|
| 106 |
cur.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
except Exception:
|
| 108 |
try:
|
| 109 |
self._conn.rollback()
|
|
|
|
| 104 |
cur = self._conn.cursor()
|
| 105 |
cur.execute("SET statement_timeout = 15000")
|
| 106 |
cur.close()
|
| 107 |
+
# SET はトランザクション内で発行されるため、ここで確定させておく
|
| 108 |
+
# (直後に autocommit を切り替える initialize_db 等が
|
| 109 |
+
# "set_session cannot be used inside a transaction" で
|
| 110 |
+
# 失敗するのを防ぐ)
|
| 111 |
+
self._conn.commit()
|
| 112 |
except Exception:
|
| 113 |
try:
|
| 114 |
self._conn.rollback()
|