Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Attach backend connection ID in the log

Đang mở
#310 0 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 1 ngày

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

  • #349 của @xhebox — đã đóng, không merge

Đá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
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với việc ghi log kết nối backend trong client/client_conn.go, bao gồm vị trí log được hiển thị ở dòng 72, và lần theo luồng handshake có thể lấy hoặc liên kết ID kết nối TiDB. Công việc hoàn tất khi log kết nối backend chứa một ID có thể được đối chiếu một cách đáng tin cậy với log TiDB tương ứng; issue cũng xác định việc ghi log địa chỉ cục bộ là một phương án thay thế cần đánh giá.

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

Mô tả

enhancement

Development Task

Sometimes it's hard to troubleshoot without the backend connection ID.

E.g. when TiProxy prints

[2023/06/12 22:43:19.576 +00:00] [INFO] [main.proxy.conn] [client/client_conn.go:72] [fails to relay the connection] [connID=77] [client_addr=172.30.5.201:44527] [proxy-protocol=false] [backend_addr=db-tidb-1.db-tidb-peer.tidb1379661944646167024.svc:4000] ["quit source"="backend quit"] [error="this is an error from client: failed to read the connection: read tcp 172.30.5.9:6000->172.30.5.201:44527: i/o timeout"] [errorVerbose="this is an error from client: failed to read the connection: read tcp 172.30.5.9:6000->172.30.5.201:44527: i/o timeout\ngithub.com/pingcap/TiProxy/pkg/proxy/net.(*PacketIO).wrapErr\n\t/proxy/pkg/proxy/net/packetio.go:115\ngithub.com/pingcap/TiProxy/pkg/proxy/net.(*PacketIO).ReadPacket\n\t/proxy/pkg/proxy/net/packetio.go:199\ngithub.com/pingcap/TiProxy/pkg/proxy/client.(*ClientConnection).processMsg\n\t/proxy/pkg/proxy/client/client_conn.go:79\ngithub.com/pingcap/TiProxy/pkg/proxy/client.(*ClientConnection).Run\n\t/proxy/pkg/proxy/client/client_conn.go:62\ngithub.com/pingcap/TiProxy/pkg/proxy.(*SQLServer).onConn\n\t/proxy/pkg/proxy/proxy.go:190\ngithub.com/pingcap/TiProxy/pkg/proxy.(*SQLServer).Run.func2.1\n\t/proxy/pkg/proxy/proxy.go:132\ngithub.com/pingcap/TiProxy/lib/util/waitgroup.(*WaitGroup).Run.func1\n\t/proxy/lib/util/waitgroup/waitgroup.go:33\nruntime.goexit\n\t/usr/lib/go/src/runtime/asm_arm64.s:1172"]

It's hard to find why TiDB closes the connection, until I find this log in TiDB:

[2023/06/12 22:42:23.064 +00:00] [INFO] [conn.go:1124] ["read packet timeout, close this connection"] [conn=8770920803001697179] [idle=8h0m0.000026656s] [waitTimeout=28800] [error="read tcp 172.30.4.121:4000->172.30.5.9:60016: i/o timeout"]

If we have the backend connection ID in the log, we can quickly find the TiDB log through the backend connection ID.

Since TiDB connection is 8 bytes but it returns 4 bytes to TiProxy in the handshake, it's not easy to figure out the real backend connection ID. I think it's fine to query TiDB with select connection_id() once the handshake succeeds.

An alternative is to log the local address(especially the port) to the backend connection, because TiDB also prints the TiProxy address.

Ngôn ngữ chính
Go
Star
73
Fork
41
Merge trung bình
10 giờ 52 phút
Pull request đã merge (30 ngày)
20

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

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 pingcap/tiproxy

Tất cả issue của pingcap/tiproxy

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.