Use 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands' content within a certain range (n+1, n+m) #36198
Labels
feature/accepted
This feature request is accepted by product managers
type/feature-request
Categorizes issue or PR as related to a new feature.
Feature Request
Is your feature request related to a problem? Please describe:
The feature is related to an issue from TiFlow: pingcap/tiflow#4689
dm-worker keeps retrying to execute ddl when encounter "invalid connection" error, which is caused by the DDL costs a long duration or the DDL is queuing.
Proposed solution:
When encoutering "invalid connection", execute the 'ADMIN SHOW DDL' command every 10 seconds to check the status of the required DDL command in TiDB, and use the retrieved status to carry on the corresponding operation:
To check the the current state of the specified DDL command (running/none/synced...), we use 'ADMIN SHOW DDL JOBS' to retrive the JOB_ID corresponding to each DDL command. Then use 'ADMIN SHOW DDL JOB QUERIES JOB_ID' to find the content of each DDL command. By matching the database name, table name, and content with those of the specified DDL that we want to query, we can retrieve its state.
Describe the feature you'd like:
https://docs.pingcap.com/tidb/stable/sql-statement-admin-show-ddl#examples
Now the 'ADMIN SHOW DDL JOB QUERIES JOB_ID' command can only use JOB_ID to retrieve the last ten rows of DDL commands' content. Just like described in the website: 'You can only search the running DDL job corresponding to job_id within the last ten results in the DDL history job queue.'
I would like to request a feature that the users can use commands like 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands' content within a certain range (n+1, n+m) that the users can assign themselves instead of only the last ten results.
Example:
Details and possible outcomes of this request can refer to this link:
https://docs.google.com/document/d/1shMk7UdczcWEdvd5YCPN7Ywr4L4JCbIWKtLEGZYSKD8/edit#heading=h.lj3nhy183z6n
Describe alternatives you've considered:
Alternative solution:
When encoutering "invalid connection", execute the 'ADMIN SHOW DDL' command every 10 seconds to check the status of the required DDL command in TiDB.
Select the current time of TiDB everytime a DDL command is executed.
Use 'ADMIN SHOW DDL JOBS' command to retrieve CREATE_TIME of every DDL command ('ADMIN SHOW DDL JOBS' can show more than 10 results), then retrieve those DDL commands whose CREATE_TIME are later than the create time of the required DDL command.
Then match the DB_NAME, TABLE_NAME, JOB_TYPE of those retrieved DDLs with the corresponding variables of the required DDL, if all the corresponding variables are equal, then return the state of the DDL that meets this requirement.
Obviously, we can see that this solution is not quite rigorous. If the content of the selected DDL cannot be guaranteed to be exactly the same as that of the required DDL, only matching other variables would probably return the wrong state.
Besides, since dm does not use TiDB HTTP API, the solution related to it does not work.
Teachability, Documentation, Adoption, Migration Strategy:
The users can use commands like 'ADMIN SHOW DDL JOB QUERIES LIMIT m OFFSET n' to retrieve DDL commands' content within a certain range (n+1, n+m) that the users can assign themselves instead of only the last ten results.
The text was updated successfully, but these errors were encountered: