MySQL: idle pool connections die after wait_timeout, log shows broken pipe

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

Maintainer thường phản hồi trong vòng 4 ngày

@AdzerKI đang làm issue này rồi.

Từ ngày 19/11/2026.

  • #4841 của @AdzerKI — đang mở

Đá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
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go, mysql
Lĩnh vực
database

Hướng nghiên cứu

The issue identifies getEntDriver as the entry point and links the go-sql-driver/mysql guidance on SetConnMaxLifetime; start by locating that function and checking how it configures the MySQL driver. The issue proposes a three-minute connection lifetime. Done means MySQL connections receive that setting and the reported broken-pipe log stops recurring; an open pull request already addresses the issue.

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

Mô tả

kind/bug needs/triage

With a MySQL backend, crowdsec keeps idle connections in the database/sql pool with no lifetime limit. After the server-side wait_timeout (600s here) MySQL closes them, and the next query on such a connection logs:

[mysql] packets.go:155 write tcp 127.0.0.1:55054->127.0.0.1:3310: write: broken pipe
[mysql] connection.go:803 closing bad idle connection: unexpected read from socket

database/sql retries on a fresh connection, so queries still succeed, but the log gets these lines every time the pool picks a dead connection (about a dozen a day on our host, crowdsec 1.8.2).

go-sql-driver/mysql asks for SetConnMaxLifetime shorter than the server and middleware timeouts and suggests under 5 minutes: https://github.com/go-sql-driver/mysql#important-settings

Fix: set ConnMaxLifetime to 3 minutes for the mysql driver in getEntDriver. PR follows.

Ngôn ngữ chính
Go
Star
15.1k
Fork
726
Merge trung bình
4 ngày 23 giờ
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 crowdsecurity/crowdsec

Tất cả issue của crowdsecurity/crowdsec

Issue tương tự

Thêm issue về Go

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.