How to Obtain the startTs of All DDL Operations in TiDB

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

Original topic: 如何拿到TiDB所有ddl操作的startTs

| username: TiDBer_hWeMryFA

How to get the startTs of a batch of DDL operations in TiDB

| username: wakaka | Original post link

The “num” in “admin show ddl jobs [num]” represents the most recent number of entries, and the “start_time” in the result is

| username: TiDBer_hWeMryFA | Original post link

Actually, what is needed is the TSO value, not the time value.

| username: neilshen | Original post link

You can use the Dashboard to download the full DDL history.

Dashboard address: http://${PD_ADDR}/dashboard

| username: TiDBer_hWeMryFA | Original post link

This can indeed be obtained, but the DDL history in our production is too large to download. Is there a way to get the most recent batch of DDL history information, mainly including the startTs?

| username: ShawnYan | Original post link

Add a limit, for example, to get the most recent 100 DDLs:

curl -s localhost:10080/ddl/history?limit=100 | jq '.[] | {start_ts, query}'
| username: TiDBer_hWeMryFA | Original post link

I tested this in the testing environment and it worked, but in the production environment, it returns empty. I think it’s because the historical DDL in the production environment is too large. We have 500,000 tables in production, and there have been many DDL modification operations in the past. Even with a limit of 100, it still doesn’t work. Is there any other way?

| username: TiDBer_hWeMryFA | Original post link

Testing works, but it doesn’t work in production. There might be some issues in the production environment causing the request to fail. Are there any other solutions?

| username: tiancaiamao | Original post link

Adding a limit is correct… However, there is currently a bug that causes all data to be fetched even with a limit (resulting in poor performance and potential OOM). I’ll take some time to fix it soon.

| username: tiancaiamao | Original post link

*: optimize DDL history http API, reduce memory by tiancaiamao · Pull Request #36859 · pingcap/tidb · GitHub Let’s do it!

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.