TCP connection not closing properly leading to dangling CLOSE_WAIT state and system overload

Đang mở
#471 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python, sql
Lĩnh vực
databases, networking

Hướng nghiên cứu

Tái hiện cả hai trường hợp bằng Python 3.10.15, databricks-sql-python 3.1.2, các lệnh gọi sql.connect được hiển thị và netstat để quan sát trạng thái socket. Hoàn tất khi các kết nối được đóng đúng cách sau context manager hoặc các lệnh gọi close rõ ràng, không có socket CLOSE_WAIT nào bị giữ vô thời hạn và tài nguyên phía client được giải phóng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Testcase 1

Python 3.10.15 (main, Sep  7 2024, 18:35:33) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from databricks import sql
>>> sql.__version__
'3.1.2'
>>> with sql.connect(server_hostname = "<HIDE>", http_path = "<HIDE>", access_token = "<HIDE>") as connection:
...     with connection.cursor() as cursor:
...             cursor.execute("select * from table")
...             column_names = [desc[0] for desc in cursor.description]
...             query_out = [dict(zip(column_names, row)) for row in cursor.fetchall()]
...             
... 
<databricks.sql.client.Cursor object at 0x7f88551c14e0>
>>> query_out
[{"sometime" : "something}]


On the sidelines, the network connection for this process (after with clause gets finished), remain in ESTABLISHED state and then moves to CLOSE_WAIT state indefinitely. 

Every 1.0s: netstat -apn | grep 1070099                                                                                          asinha-vm-ubuntu-20-04-1: Wed Nov 20 02:43:13 2024

tcp       25      0 10.5.220.4:58078        so:me:ip:add:443      CLOSE_WAIT  1070099/python3

Testcase 2

Python 3.10.15 (main, Sep  7 2024, 18:35:33) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from databricks import sql
>>> sql.__version__
'3.1.2'
>>> connection = sql.connect(server_hostname = "<HIDE>", http_path = "<HIDE>", access_token = "<HIDE>")
>>> ## at this point a TCP connection got made as ESTABLISHED state ##
>>> cursor = connection.cursor()
>>> cursor.execute("select * from table")
<databricks.sql.client.Cursor object at 0x7f9d65db26b0>
>>> column_names = [desc[0] for desc in cursor.description]
>>> query_out = [dict(zip(column_names, row)) for row in cursor.fetchall()]
>>> cursor.close()
>>> connection.close()
>>> # even after close being called, the connection remains in ESTABLISHED state (for a long time) and then finally moves to CLOSE_WAIT state, which never changes.

Every 1.0s: netstat -apn | grep 1074808                                                                                          asinha-vm-ubuntu-20-04-1: Wed Nov 20 02:49:36 2024

tcp       25      0 10.5.220.4:53810        so:me:ip:add:443      CLOSE_WAIT  1074808/python3

Connections should be closed properly, and all client resources should be freed properly.

Ngôn ngữ chính
Python
Star
233
Fork
152
Merge trung bình
21 giờ 5 phút
Pull request đã merge (30 ngày)
10

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của databricks/databricks-sql-python

Tất cả issue của databricks/databricks-sql-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.