Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Close connections to a TiDB that the health check has marked down, instead of waiting for TCP to time out

未关闭
#1,239 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
go

调研方向

Start by reading TiProxy's health-check handling and backend/client connection lifecycle, especially where a backend is marked down and where processLock governs socket handling. The issue does not name specific files or tests, so locate those entry points and existing failure tests first. Done means an opt-in behavior closes idle connections when a backend goes down and applies the requested failover-timeout behavior to in-flight connections.

由索引模型根据 Issue 内容生成。

描述

contribution first-time-contributor type/enhancement

Feature Request

Describe your feature request related problem

When a TiDB instance fails without closing its sockets (node/instance failure, network partition, or a pod killed before TiDB can drain), TiProxy detects it (health check marks the backend down) but does nothing to the client connections that are already on that backend.

Measured on TiProxy v1.3.2 + TiDB v8.5.8 on Kubernetes (2 TiDB, 2 TiProxy), client with pool_pre_ping. Test: the EC2 instance hosting tidb-0 was terminated.

  | Time (from failure) | Event |
  |---|---|
  | 0 s | Node hosting tidb-0 terminated; TiDB logs nothing further (no shutdown, no FIN to TiProxy) |
  | +14 s | `update backend ... cur="down, err: connect status port failed: ... context deadline exceeded"` |
  | +16.3–16.5 s | Short statements sent right after the failure: `backend disconnects ... execute_time=15.45–15.51s cmd=Query`, client gets EOF |
  | +46 s | Long query started 17 s before the failure: `backend disconnects ... execute_time=1m3.2s cmd=Query query="select sleep(?)"`, client gets EOF |
Describe the feature you'd like

When the health check marks a TiDB down, we'd like TiProxy to:

  1. Close idle client connections on that TiDB right away, so the application's next ping fails instantly and its pool reconnects to a healthy TiDB.
  2. After failover-timeout, also close connections that still have a command in flight. This should break the wait on the TiDB side too (close the backend socket or put a deadline on it), so the client gets an error in seconds rather than a minute.
  3. Apply the unhealthy keepalive to the backend socket immediately when the TiDB is marked down, without waiting for processLock, so even connections with a stuck command get the shorter timeouts.
Teachability, Documentation, Adoption, Migration Strategy

Keep it off by default so current behaviour doesn't change. It's most useful for OLTP applications behind connection pools, where each pooled connection to a dead TiDB costs one full TCP timeout.

主要语言
Go
星标
73
派生
41
平均合并
2 小时 21 分钟
30 天内合并 PR
20

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pingcap/tiproxy 的其他 Issue

查看 pingcap/tiproxy 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。