pingcap / pingcap/tidb-operator

TiProxy does not support lifecycle hooks (preStop) causing downtime during config updates

Open
#6,596 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contribution first-time-contributor
Dominant language
Go
Stars
1.3k
Forks
540
Avg merge
3d 2h
Merged PRs (30d)
18

Description

Hello!
We have encountered an availability issue related to TiProxy when running TiDB in Kubernetes.
TiProxy v1.3.2
TiDB-operator v1.6.3

Problem Description:
When updating the TiProxy configuration in a TiDB cluster managed by TiDB Operator, i consistently observe short but real downtime for applications connecting through TiProxy.

Unlike TiDB, the TiProxy component currently does not support any lifecycle hooks in the CRD.
Specifically, the field:
spec.tiproxy.lifecycle
is not present in the CRD schema, so i cannot define a preStop hook.

This makes it impossible to perform a graceful shutdown or introduce a delay before the pod is terminated. As a result, during rolling updates, even with multiple replicas, there is a brief accessibility loss when a TiProxy pod is killed immediately.

To mitigate the problem, i tried to add a preStop hook:

spec:
  tiproxy:
    lifecycle:
      preStop:
        exec:
          command: ["/bin/sh", "-c", "sleep 30"]

This works correctly for spec.tidb.lifecycle but fails for TiProxy.

Feature Request:

Would it be possible to add lifecycle hook support to TiProxy, similar to what already exists for TiDB?
preStop support would allow us to delay shutdown and avoid losing connection during regular updates.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TiProxy CRD schema and the existing spec.tidb.lifecycle implementation in the tidb-operator repository. Compare how lifecycle hooks are represented and propagated for TiDB, then inspect the TiProxy update path and related tests. Done means the TiProxy CRD accepts the requested lifecycle configuration and a preStop hook is preserved during updates without disrupting existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.