How to Elect the Owner of TiDB?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 如何选举tidb的owner ?

| username: CAICAI

[Problem Encountered]:
Currently, there are three TiDB nodes, but there is no owner node, resulting in the inability to execute DDL. How can I select an owner node?

The situation that caused this problem was that the owner node tidb-tidb-1 crashed. Since it is a stateless service, I restarted it, but it still couldn’t select an owner.

Using curl -X POST http://10.20.186.225:10080/ddl/owner/resign prompts that it cannot connect, or This node is not a ddl owner, can’t be resigned:

curl -X POST http://10.20.186.225:10080/ddl/owner/resign
This node is not a ddl owner, can't be resigned./ # curl -X POST http://10.20.186.225:10080/ddl/owner/resign
curl: (28) Failed to connect to 10.20.186.225 port 10080 after 131920 ms: Operation timed out

According to the official documentation, there is another method:

tidb-ctl etcd delowner [LeaseID] [flags] + ownerKey

But how do I know the LeaseID and flags?

Using admin show ddl, the result is as follows:

| username: CAICAI | Original post link

The document uses delowner:

 tidb-ctl etcd delowner [LeaseID] [flags] + ownerKey

But the actual command does not have delowner:

/tmp/tidb-community-server-v5.4.0-linux-amd64 # ./tidb-ctl etcd delowner 7fe29d0d-1376-49f3-918f-37f6e8057c9d
control the info about etcd by grpc_gateway

Usage:
  tidb-ctl etcd [command]

Available Commands:
  ddlinfo     Show All Information about DDL
  delkey      Delete the key associated with DDL by `delkey [key]`
  putkey      [ONLY FOR TEST!] put a key in the path of TiDB schema versions by `putkey [key] [value]`

Flags:
  -h, --help   help for etcd

Global Flags:
      --ca string         TLS CA path
      --host ip           TiDB server host (default 127.0.0.1)
      --pdhost ip         PD server host (default 127.0.0.1)
      --pdport uint16     PD server port (default 2379)
      --port uint16       TiDB server port (default 10080)
      --ssl-cert string   TLS Cert path
      --ssl-key string    TLS Key path

Use "tidb-ctl etcd [command] --help" for more information about a command.
subcommand is required

Could it be that the document is incorrect?
Do we need to delete the etcd key to automatically select the owner?

| username: ddhe9527 | Original post link

First, use the ddlinfo command to check and find the name of the key, then try deleting it with delkey, for example:

tidb-ctl etcd delkey "/tidb/ddl/fg/owner/XXXXXXXXXXXXXXXX"
| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.