title | summary | aliases | |
---|---|---|---|
CHANGE DRAINER |
An overview of the usage of CHANGE DRAINER for the TiDB database. |
|
The CHANGE DRAINER
statement modifies the status information for Drainer in the cluster.
Tip:
Drainer's state is automatically reported to PD while running. Only when Drainer is under abnormal circumstances and its state is inconsistent with the state information stored in PD, you can use the
CHANGE DRAINER
statement to modify the state information stored in PD.
{{< copyable "sql" >}}
SHOW DRAINER STATUS;
+----------|----------------|--------|--------------------|---------------------|
| NodeID | Address | State | Max_Commit_Ts | Update_Time |
+----------|----------------|--------|--------------------|---------------------|
| drainer1 | 127.0.0.3:8249 | Online | 408553768673342532 | 2019-04-30 00:00:03 |
+----------|----------------|--------|--------------------|---------------------|
| drainer2 | 127.0.0.4:8249 | Online | 408553768673345531 | 2019-05-01 00:00:04 |
+----------|----------------|--------|--------------------|---------------------|
2 rows in set (0.00 sec)
It can be seen that drainer1's state has not been updated for more than a day, the Drainer is in an abnormal state, but the State
remains Online
. After using CHANGE DRAINER
, the Drainer's State
is changed to 'paused':
{{< copyable "sql" >}}
CHANGE DRAINER TO NODE_STATE ='paused' FOR NODE_ID 'drainer1';
Query OK, 0 rows affected (0.01 sec)
{{< copyable "sql" >}}
SHOW DRAINER STATUS;
+----------|----------------|--------|--------------------|---------------------|
| NodeID | Address | State | Max_Commit_Ts | Update_Time |
+----------|----------------|--------|--------------------|---------------------|
| drainer1 | 127.0.0.3:8249 | Paused | 408553768673342532 | 2019-04-30 00:00:03 |
+----------|----------------|--------|--------------------|---------------------|
| drainer2 | 127.0.0.4:8249 | Online | 408553768673345531 | 2019-05-01 00:00:04 |
+----------|----------------|--------|--------------------|---------------------|
2 rows in set (0.00 sec)
This statement is a TiDB extension to MySQL syntax.