@@ -207,21 +207,11 @@ type ProfileHandler struct {
207207 * handler.TikvHandlerTool
208208}
209209
210- // AdminCheckIndexHandler is the handler for admin check index inconsistency summary.
211- type AdminCheckIndexHandler struct {
212- store kv.Storage
213- }
214-
215210// NewProfileHandler creates a new ProfileHandler.
216211func NewProfileHandler (tool * handler.TikvHandlerTool ) * ProfileHandler {
217212 return & ProfileHandler {tool }
218213}
219214
220- // NewAdminCheckIndexHandler creates a new AdminCheckIndexHandler.
221- func NewAdminCheckIndexHandler (store kv.Storage ) * AdminCheckIndexHandler {
222- return & AdminCheckIndexHandler {store : store }
223- }
224-
225215// DDLHookHandler is the handler for use pre-defined ddl callback.
226216// It's convenient to provide some APIs for integration tests.
227217type DDLHookHandler struct {}
@@ -1196,8 +1186,9 @@ func (h DDLResignOwnerHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
11961186 handler .WriteData (w , "success!" )
11971187}
11981188
1199- // ServeHTTP handles request of triggering admin check index.
1200- // This endpoint is used for online diagnosis and relies on fast check table mode.
1189+ // ServeHTTP handles both:
1190+ // 1. /ddl/check/{db}/{table}/{index} (legacy DDL check endpoint)
1191+ // 2. /admin/check/index (inconsistency summary endpoint)
12011192func (h DDLCheckHandler ) ServeHTTP (w http.ResponseWriter , req * http.Request ) {
12021193 if req .Method != http .MethodPost {
12031194 handler .WriteError (w , errors .Errorf ("This api only support POST method" ))
@@ -1208,6 +1199,14 @@ func (h DDLCheckHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
12081199 dbName := params [handler .DBName ]
12091200 tableName := params [handler .TableName ]
12101201 indexName := params [handler .IndexName ]
1202+ if dbName != "" || tableName != "" || indexName != "" {
1203+ h .serveDDLCheckByPath (w , req , dbName , tableName , indexName )
1204+ return
1205+ }
1206+ h .serveAdminCheckIndexSummary (w , req )
1207+ }
1208+
1209+ func (h DDLCheckHandler ) serveDDLCheckByPath (w http.ResponseWriter , req * http.Request , dbName , tableName , indexName string ) {
12111210 if dbName == "" || tableName == "" || indexName == "" {
12121211 handler .WriteError (w , errors .Errorf ("db, table and index are required" ))
12131212 return
@@ -1257,6 +1256,35 @@ func (h DDLCheckHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
12571256 handler .WriteData (w , result )
12581257}
12591258
1259+ func (h DDLCheckHandler ) serveAdminCheckIndexSummary (w http.ResponseWriter , req * http.Request ) {
1260+ dbName := req .FormValue (handler .DBName )
1261+ tableName := req .FormValue (handler .TableName )
1262+ indexName := req .FormValue (handler .IndexName )
1263+ if dbName == "" || tableName == "" || indexName == "" {
1264+ handler .WriteError (w , errors .Errorf ("db, table and index are required" ))
1265+ return
1266+ }
1267+
1268+ limit , err := parseAdminCheckIndexLimit (req )
1269+ if err != nil {
1270+ handler .WriteError (w , err )
1271+ return
1272+ }
1273+
1274+ summary , err := h .checkIndexByName (dbName , tableName , indexName , limit )
1275+ if err != nil && summary == nil {
1276+ handler .WriteError (w , err )
1277+ return
1278+ }
1279+ if summary == nil {
1280+ summary = & executor.AdminCheckIndexInconsistentSummary {}
1281+ }
1282+
1283+ // For inconsistency errors from `admin check index`, summary already contains
1284+ // mismatched handles and mismatch types required by this API.
1285+ handler .WriteData (w , summary )
1286+ }
1287+
12601288func collectRecordSetRows (ctx context.Context , se sessionapi.Session , rss []sqlexec.RecordSet ) ([][]string , error ) {
12611289 rows := make ([][]string , 0 )
12621290 for _ , one := range rss {
@@ -1273,8 +1301,8 @@ func collectRecordSetRows(ctx context.Context, se sessionapi.Session, rss []sqle
12731301 return rows , nil
12741302}
12751303
1276- func (h AdminCheckIndexHandler ) checkIndexByName (dbName , tableName , indexName string , limit int ) (* executor.AdminCheckIndexInconsistentSummary , error ) {
1277- se , err := session .CreateSession (h .store )
1304+ func (h DDLCheckHandler ) checkIndexByName (dbName , tableName , indexName string , limit int ) (* executor.AdminCheckIndexInconsistentSummary , error ) {
1305+ se , err := session .CreateSession (h .Store )
12781306 if err != nil {
12791307 return nil , err
12801308 }
@@ -1316,41 +1344,6 @@ func (h AdminCheckIndexHandler) checkIndexByName(dbName, tableName, indexName st
13161344 return summary , execErr
13171345}
13181346
1319- // ServeHTTP handles request of admin check index summary.
1320- func (h AdminCheckIndexHandler ) ServeHTTP (w http.ResponseWriter , req * http.Request ) {
1321- if req .Method != http .MethodPost {
1322- handler .WriteError (w , errors .Errorf ("This api only support POST method" ))
1323- return
1324- }
1325-
1326- dbName := req .FormValue (handler .DBName )
1327- tableName := req .FormValue (handler .TableName )
1328- indexName := req .FormValue (handler .IndexName )
1329- if dbName == "" || tableName == "" || indexName == "" {
1330- handler .WriteError (w , errors .Errorf ("db, table and index are required" ))
1331- return
1332- }
1333-
1334- limit , err := parseAdminCheckIndexLimit (req )
1335- if err != nil {
1336- handler .WriteError (w , err )
1337- return
1338- }
1339-
1340- summary , err := h .checkIndexByName (dbName , tableName , indexName , limit )
1341- if err != nil && summary == nil {
1342- handler .WriteError (w , err )
1343- return
1344- }
1345- if summary == nil {
1346- summary = & executor.AdminCheckIndexInconsistentSummary {}
1347- }
1348-
1349- // For inconsistency errors from `admin check index`, summary already contains
1350- // mismatched handles and mismatch types required by this API.
1351- handler .WriteData (w , summary )
1352- }
1353-
13541347func parseAdminCheckIndexLimit (req * http.Request ) (int , error ) {
13551348 limitValue := req .FormValue (handler .Limit )
13561349 if len (limitValue ) == 0 {
0 commit comments