is_connected and ping() report a dead connection as live (since 2.1.0)
メンテナーはふだん 5 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
調査の方向性
src/datajoint/connection.py の Connection.ping() から始め、MySQL および PostgreSQL アダプターの ping() メソッドを調べてください。is_connected が ping の失敗をどのように処理するかを確認し、拡張できる既存の接続テストを探してください。issue にはテストファイルの指定がありません。切断された接続によって ping() が例外を発生させ、is_connected が False を返すこと(PostgreSQL の場合も含む)を完了条件とします。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
Description
Connection.ping() no longer raises when the connection is dead, so Connection.is_connected stays True after the server kills the connection or stops. It only turns False after close(). We check is_connected in a health endpoint, and it reported a stopped server as connected.
Connection.ping() calls self.adapter.ping(self._conn) and discards the result. MySQLAdapter.ping() catches every exception and returns False, so ping() never raises, and is_connected never reaches its except branch.
Reproducibility
Include:
- OS: Linux (Ubuntu on WSL2)
- Python 3.12.13
- MySQL 8.4.11
- local-docker
- DataJoint 2.3.6 (the code is unchanged on master)
Steps:
import datajoint as dj
import pymysql
conn = dj.conn()
config = dj.config
admin = pymysql.connect(host=config['database.host'], port=config['database.port'],
user=config['database.user'], password=config['database.password'])
with admin.cursor() as cursor:
cursor.execute(f'KILL {conn.connection_id}')
print(conn.adapter.ping(conn._conn)) # False
print(conn.is_connected) # True
conn.ping() # does not raise
print(conn) # DataJoint connection (connected) root@...
Expected Behavior
ping() raises and is_connected returns False once the server has dropped the connection, as in 0.14.4 and 2.0.0, where ping() called self._conn.ping(reconnect=False) directly.
Additional Research and Context
- Introduced in 2.1.0, when ping() started going through the backend adapters.
- Connection.ping() ignores the adapter's result: https://github.com/datajoint/datajoint-python/blob/v2.3.6/src/datajoint/connection.py#L392-L401
- The adapters return False instead of raising: MySQL, PostgreSQL (the PostgreSQL case is not tested).
- repr (L251) and in_transaction (L531) read is_connected, so they are wrong in the same way.
- #1734 relies on is_connected noticing a dead connection ("Closed by close(), or found dead by is_connected").
- Possible fix: in Connection.ping(), raise errors.LostConnectionError when self.adapter.ping(self._conn) returns False.
- 主要言語
- Python
- スター
- 198
- フォーク
- 107
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 12
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
datajoint/datajoint-python のほかの issue
-
MySQL: with use_tls=False, 2.3.6 needs the cryptography package to log in to MySQL 8対応中かも @dimitri-yatsenko が 5 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
datajoint/datajoint-python#1750 ·
メンテナーはふだん 5 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
datajoint/datajoint-python#1747 ·
メンテナーはふだん 5 日以内に返信
-
Reject constant defaults on primary-key attributes対応中かも @godara-alt が 4 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
datajoint/datajoint-python#1712 ·
メンテナーはふだん 5 日以内に返信
-
Decoding a <blob> value in an unknown format returns None instead of raising an error対応中かも @godara-alt が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
datajoint/datajoint-python#1703 ·
メンテナーはふだん 5 日以内に返信
-
staged_insert1 stores object paths with the class name and an empty store name, so garbage collection can delete its objects対応中かも @godara-alt が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
datajoint/datajoint-python#1701 ·
メンテナーはふだん 5 日以内に返信
datajoint/datajoint-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
QuantConnect/lean-cli#792 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
open-webui/open-webui#35360 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)オープン
難易度 1/5 1時間未満 初心者へのやさしさ 68/100