Skip to content

Commit

Permalink
docs: add the hint of usage of the partition tables in mvcc/key API (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored Mar 28, 2024
1 parent 04c4506 commit 538352c
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions docs/tidb_http_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,25 @@

```protobuf
enum Op {
Put = 0;
Del = 1;
Lock = 2;
Rollback = 3;
// insert operation has a constraint that key should not exist before.
Insert = 4;
PessimisticLock = 5;
CheckNotExists = 6;
Put = 0;
Del = 1;
Lock = 2;
Rollback = 3;
// insert operation has a constraint that key should not exist before.
Insert = 4;
PessimisticLock = 5;
CheckNotExists = 6;
}
```

*Hint: On a partitioned table, use the `table(partition)` pattern as the table name, `t1(p1)` for example:*

```shell
$curl http://127.0.0.1:10080/mvcc/key/test/t1(p1)/1
```

*Hint: The method to convert the Hex format key returned by TiDB API into the format recognized by [tikv-ctl](https://docs.pingcap.com/tidb/stable/tikv-control).*

Step 1: Get the hex format of the key you need. For example you could find the key by the following TiDB API.

```shell
Expand Down Expand Up @@ -292,21 +298,21 @@

Step 3: Encode the key to make it memcomparable in tikv with [tikv-ctl](https://docs.pingcap.com/tidb/stable/tikv-control)

```
```shell
./tikv-ctl --encode 't\200\000\000\000\000\000\010\306_r\200\000\000\000\000\000\000\001'
7480000000000008FFC65F728000000000FF0000010000000000FA
```

Step 4: Convert the key from hex format to escaped format again since most `tikv-ctl` commands only accept keys in escaped format while the `--encode` command outputs the key in hex format.
```

```shell
./tikv-ctl --to-escaped '7480000000000008FFC65F728000000000FF0000010000000000FA'
t\200\000\000\000\000\000\010\377\306_r\200\000\000\000\000\377\000\000\001\000\000\000\000\000\372
```

Step 5: Add a prefix "z" to the key. Then the key can be recognized by [tikv-ctl](https://docs.pingcap.com/tidb/stable/tikv-control). For example, use the following command to scan from tikv.

```
```shell
./tikv-ctl --host "<tikv_ip>:<port>" scan --from 'zt\200\000\000\000\000\000\010\377\306_r\200\000\000\000\000\377\000\000\001\000\000\000\000\000\372' --limit 5 --show-cf write,lock,default
key: zt\200\000\000\000\000\000\010\377\306_r\200\000\000\000\000\377\000\000\001\000\000\000\000\000\372
write cf value: start_ts: 445971968923271174 commit_ts: 445971968923271175 short_value: 800002000000020308000900736869726C79613422
Expand Down Expand Up @@ -418,6 +424,7 @@ timezone.*
```shell
curl http://{TiDBIP}:10080/tables/{db}/{table}/scatter
```
*Hint: On a partitioned table, use the `table(partition)` pattern as the table name, `test(p1)` for example.*
**Note**: The `scatter-range` scheduler may conflict with the global scheduler, do not use it for long periods on the larger table.
Expand All @@ -427,6 +434,7 @@ timezone.*
```shell
curl http://{TiDBIP}:10080/tables/{db}/{table}/stop-scatter
```
*Hint: On a partitioned table, use the `table(partition)` pattern as the table name, `test(p1)` for example.*
1. Get TiDB server settings
Expand Down Expand Up @@ -537,7 +545,8 @@ timezone.*
```shell
curl http://{TiDBIP}:10080/ddl/history
```
**Note**: When the DDL history is very very long, it may consume a lot memory and even cause OOM. Consider adding `start_job_id` and `limit`.
**Note**: When the DDL history is very very long, it may consume a lot memory and even cause OOM. Consider adding `start_job_id` and `limit`.
1. Get count {number} TiDB DDL job history information.
Expand All @@ -547,26 +556,26 @@ timezone.*
1. Get count {number} TiDB DDL job history information, start with job {id}
```shell
curl http://{TIDBIP}:10080/ddl/history?start_job_id={id}&limit={number}
```
```shell
curl http://{TIDBIP}:10080/ddl/history?start_job_id={id}&limit={number}
```
1. Download TiDB debug info
```shell
curl http://{TiDBIP}:10080/debug/zip?seconds=60 --output debug.zip
```
zip file will include:
- Go heap pprof(after GC)
- Go cpu pprof(10s)
- Go mutex pprof
- Full goroutine
- TiDB config and version
Param:
- seconds: profile time(s), default is 10s.
1. Get statistics data of specified table.
Expand All @@ -580,6 +589,7 @@ timezone.*
```shell
curl http://{TiDBIP}:10080/stats/dump/{db}/{table}/{yyyyMMddHHmmss}
```
```shell
curl http://{TiDBIP}:10080/stats/dump/{db}/{table}/{yyyy-MM-dd HH:mm:ss}
```
Expand All @@ -592,22 +602,24 @@ timezone.*
Return value:
* timeout, return status code: 400, message: `timeout`
* If it returns normally, status code: 200, message example:
- timeout, return status code: 400, message: `timeout`
- If it returns normally, status code: 200, message example:
```text
{
  "Skipped": false,
  "SkippedCommitterCounter": 0
}
```
`Skipped`: false indicates that the current binlog is not in the skipped state, otherwise, it is in the skipped state
`SkippedCommitterCounter`: Represents how many transactions are currently being committed in the skipped state. By default, the API will return after waiting until all skipped-binlog transactions are committed. If this value is greater than 0, it means that you need to wait until them are committed .
Param:
* op=nowait: return after binlog status is recoverd, do not wait until the skipped-binlog transactions are committed.
* op=reset: reset `SkippedCommitterCounter` to 0 to avoid the problem that `SkippedCommitterCounter` is not cleared due to some unusual cases.
* op=status: Get the current status of binlog recovery.
- op=nowait: return after binlog status is recoverd, do not wait until the skipped-binlog transactions are committed.
- op=reset: reset `SkippedCommitterCounter` to 0 to avoid the problem that `SkippedCommitterCounter` is not cleared due to some unusual cases.
- op=status: Get the current status of binlog recovery.
1. Enable/disable async commit feature
Expand Down Expand Up @@ -638,7 +650,7 @@ timezone.*
# reset the size of the ballast object (2GB in this example)
curl -v -X POST -d "2147483648" http://{TiDBIP}:10080/debug/ballast-object-sz
```
1. Set deadlock history table capacity
```shell
Expand All @@ -656,7 +668,7 @@ timezone.*
```shell
curl -X POST -d "transaction_id_digest_min_duration={number}" http://{TiDBIP}:10080/settings
```
Unit of duration here is ms.
1. Set transaction summary table (`TRX_SUMMARY`) capacity
Expand Down

0 comments on commit 538352c

Please sign in to comment.