Skip to content

Commit

Permalink
infoschema: use ListTablesWithSpecialAttribute instead of `SchemaTa…
Browse files Browse the repository at this point in the history
…bleInfos` (#55686)

* infoschema: use `ListTablesWithSpecialAttribute` instead of `SchemaTableInfos`

* revert

* refactor
  • Loading branch information
CbcWestwolf authored Aug 29, 2024
1 parent f2856e3 commit 47ca7be
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions pkg/server/handler/tikvhandler/tikv_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,28 +637,23 @@ func (h FlashReplicaHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
return
}
replicaInfos := make([]*TableFlashReplicaInfo, 0)
allDBs := schema.AllSchemaNames()
for _, db := range allDBs {
tbls, err := schema.SchemaTableInfos(context.Background(), db)
if err != nil {
handler.WriteError(w, err)
return
}
for _, tbl := range tbls {
replicaInfos = h.getTiFlashReplicaInfo(tbl, replicaInfos)
schemas := schema.ListTablesWithSpecialAttribute(infoschema.TiFlashAttribute)
for _, schema := range schemas {
for _, tbl := range schema.TableInfos {
replicaInfos = appendTiFlashReplicaInfo(replicaInfos, tbl)
}
}

dropedOrTruncateReplicaInfos, err := h.getDropOrTruncateTableTiflash(schema)
droppedOrTruncateReplicaInfos, err := h.getDropOrTruncateTableTiflash(schema)
if err != nil {
handler.WriteError(w, err)
return
}
replicaInfos = append(replicaInfos, dropedOrTruncateReplicaInfos...)
replicaInfos = append(replicaInfos, droppedOrTruncateReplicaInfos...)
handler.WriteData(w, replicaInfos)
}

func (FlashReplicaHandler) getTiFlashReplicaInfo(tblInfo *model.TableInfo, replicaInfos []*TableFlashReplicaInfo) []*TableFlashReplicaInfo {
func appendTiFlashReplicaInfo(replicaInfos []*TableFlashReplicaInfo, tblInfo *model.TableInfo) []*TableFlashReplicaInfo {
if tblInfo.TiFlashReplica == nil {
return replicaInfos
}
Expand Down Expand Up @@ -718,7 +713,7 @@ func (h FlashReplicaHandler) getDropOrTruncateTableTiflash(currentSchema infosch
return false, nil
}
uniqueIDMap[tblInfo.ID] = struct{}{}
replicaInfos = h.getTiFlashReplicaInfo(tblInfo, replicaInfos)
replicaInfos = appendTiFlashReplicaInfo(replicaInfos, tblInfo)
return false, nil
}
dom := domain.GetDomain(s)
Expand Down

0 comments on commit 47ca7be

Please sign in to comment.