TIKV_REGION_PEERS

The TIKV_REGION_PEERS table shows detailed information of a single Region node in TiKV, such as whether it is a learner or leader.

TIKV_REGION_PEERS - 图1

Note

This table is not available on TiDB Serverless clusters.

  1. USE INFORMATION_SCHEMA;
  2. DESC TIKV_REGION_PEERS;

The output is as follows:

  1. +--------------+-------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +--------------+-------------+------+------+---------+-------+
  4. | REGION_ID | bigint(21) | YES | | NULL | |
  5. | PEER_ID | bigint(21) | YES | | NULL | |
  6. | STORE_ID | bigint(21) | YES | | NULL | |
  7. | IS_LEARNER | tinyint(1) | NO | | 0 | |
  8. | IS_LEADER | tinyint(1) | NO | | 0 | |
  9. | STATUS | varchar(10) | YES | | 0 | |
  10. | DOWN_SECONDS | bigint(21) | YES | | 0 | |
  11. +--------------+-------------+------+------+---------+-------+
  12. 7 rows in set (0.01 sec)

For example, you can query the specific TiKV addresses for the top 3 Regions with the maximum value of WRITTEN_BYTES using the following SQL statement:

  1. SELECT
  2. address,
  3. tikv.address,
  4. region.region_id
  5. FROM
  6. TIKV_STORE_STATUS tikv,
  7. TIKV_REGION_PEERS peer,
  8. (SELECT * FROM tikv_region_status ORDER BY written_bytes DESC LIMIT 3) region
  9. WHERE
  10. region.region_id = peer.region_id
  11. AND peer.is_leader = 1
  12. AND peer.store_id = tikv.store_id;

Fields in the TIKV_REGION_PEERS table are described as follows:

  • REGION_ID: The Region ID.
  • PEER_ID: The ID of the Region peer.
  • STORE_ID: The ID of the TiKV store where the Region is located.
  • IS_LEARNER: Whether the peer is learner.
  • IS_LEADER: Whether the peer is leader.
  • STATUS: The statuses of a peer:
    • PENDING: Temporarily unavailable.
    • DOWN: Offline and converted. This peer no longer provides service.
    • NORMAL: Running normally.
  • DOWN_SECONDS: The duration of being offline, in seconds.