Server can report standby activation before MySQL listener is ready
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
1. Start TiDB in standby mode, or start TiDB with forced stats initialization enabled.
2. Activate the standby TiDB instance.
3. Connect to the MySQL port immediately after the activation request returns success.
### 2. What did you expect to see? (Required)
After the activation request returns success, the TiDB MySQL listener should already be bound and ready to accept TCP connections.
### 3. What did you see instead (Required)
The activation request can return before the MySQL listener is initialized. During that window, clients can receive `connection refused` when connecting to the TiDB MySQL port.
In the current code, `Server.Run` waits for forced stats initialization before calling `initTiDBListener`. In standby startup, `EndStandby(nil)` can notify activation completion before the standby controller is attached to the created server.
Suggested labels: type/bug, component/server, component/mysql-protocol, severity/minor
### 4. What is your TiDB version? (Required)
Current master branch.
Contributor guide
Assessment
This issue has not been assessed yet.