Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Attach backend connection ID in the log

オープン
#310 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #349 @xhebox による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
go
領域
backend

調査の方向性

client/client_conn.go のバックエンド接続ログから始め、72 行目に示されているログの場所も含めて、TiDB 接続 ID を取得または関連付ける可能性のある handshake の経路を追跡します。バックエンド接続ログに、対応する TiDB ログと確実に照合できる ID が含まれるようになれば作業は完了です。issue では、評価すべき代替案としてローカルアドレスのログ記録も挙げています。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
73
フォーク
41
平均マージ
12時間 38分
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pingcap/tiproxy のほかの issue

pingcap/tiproxy の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。