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

go client reports `invalid connection` after idle for wait_timeout

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

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
20/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
go

調査の方向性

Issue にある Go の再現手順を実行し、続いて packets.go:37 と packets.go:122 を、リンク先の sql.go の 1536-1546 行における database/sql の retry 動作と併せて調査してください。Issue では提案されているコード変更は指定されていません。先に進むには、観測された wait_timeout の動作が正しく処理されるように invalid-connection path を変更できるかどうかを判断する必要があります。

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

説明

wontfix

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)
dbt.mustExec("SET @@SESSION.wait_timeout = 2")

// wait for TiDB to close our connection
time.Sleep(3 * time.Second)

tx, err := dbt.db.Begin()
if err != nil {
	dbt.Fatal(err)
}
2. What did you expect to see? (Required)

The driver logs packets.go:122: closing bad idle connection: EOF 3 times but dbt.db.Begin doesn't report any errors because it creates a new connection internally and then retry.

3. What did you see instead (Required)

The driver logs packets.go:37: unexpected EOF and dbt.db.Begin reports invalid connection.

4. What is your version? (Required)

master.

The reason:
TiProxy doesn't close the connection immediately after wait_timeout and still receives requests. After it receives the request, it finds that TiDB has disconnected and then closes the client connection. So the client encounters an ErrInvalidConn in readPacket instead of ErrBadConn in writePacket.
The client will retry by creating a new connection if encounters ErrBadConn but won't retry if encounters ErrInvalidConn, see https://github.com/golang/go/blob/master/src/database/sql/sql.go#L1536-1546
I think there's no way to solve it.

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

環境構築

はじめの一歩

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

pingcap/tiproxy のほかの issue

pingcap/tiproxy の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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