is_connected and ping() report a dead connection as live (since 2.1.0)
Maintainer thường phản hồi trong vòng 5 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu với Connection.ping() trong src/datajoint/connection.py và kiểm tra các phương thức ping() của bộ điều hợp MySQL và PostgreSQL. Kiểm tra cách is_connected xử lý lỗi ping và tìm các bài kiểm thử kết nối hiện có để mở rộng; issue không nêu tên tệp kiểm thử nào. Công việc hoàn tất khi kết nối đã ngắt khiến ping() phát sinh ngoại lệ và is_connected trả về False, bao gồm cả trường hợp PostgreSQL.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 198
- Fork
- 107
- Merge trung bình
- 4 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của datajoint/datajoint-python
-
MySQL: with use_tls=False, 2.3.6 needs the cryptography package to log in to MySQL 8Có thể đã có người làm @dimitri-yatsenko đã nhận 5 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
datajoint/datajoint-python#1750 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
datajoint/datajoint-python#1747 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Reject constant defaults on primary-key attributesCó thể đã có người làm @godara-alt đã nhận 4 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
datajoint/datajoint-python#1712 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Decoding a <blob> value in an unknown format returns None instead of raising an errorCó thể đã có người làm @godara-alt đã nhận 9 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
datajoint/datajoint-python#1703 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
staged_insert1 stores object paths with the class name and an empty store name, so garbage collection can delete its objectsCó thể đã có người làm @godara-alt đã nhận 9 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
datajoint/datajoint-python#1701 ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của datajoint/datajoint-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
QuantConnect/lean-cli#792 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-webui/open-webui#35360 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100