Skip to content

Commit

Permalink
fix read failure from system tables tiflash_segments and `tiflash_t…
Browse files Browse the repository at this point in the history
…ables` when some tiflash node is down (#19714)

Co-authored-by: crazycs <crazycs520@gmail.com>
Co-authored-by: ti-srebot <66930949+ti-srebot@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 3, 2020
1 parent 66de018 commit d0dfc77
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1892,8 +1892,16 @@ func (e *TiFlashSystemTableRetriever) initialize(sctx sessionctx.Context, tiflas
if len(tiflashInstances) > 0 && !tiflashInstances.Exist(id) {
continue
}
// TODO: Support https in tiflash
url := fmt.Sprintf("http://%s", ev.Value)
url := fmt.Sprintf("%s://%s", util.InternalHTTPSchema(), ev.Value)
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return errors.Trace(err)
}
_, err = util.InternalHTTPClient().Do(req)
if err != nil {
sctx.GetSessionVars().StmtCtx.AppendWarning(err)
continue
}
e.instanceInfos = append(e.instanceInfos, tiflashInstanceInfo{
id: id,
url: url,
Expand Down Expand Up @@ -1933,7 +1941,6 @@ func (e *TiFlashSystemTableRetriever) dataForTiFlashSystemTables(ctx sessionctx.
}
sql = fmt.Sprintf("%s LIMIT %d, %d", sql, e.rowIdx, maxCount)
notNumber := "nan"
httpClient := http.DefaultClient
instanceInfo := e.instanceInfos[e.instanceIdx]
url := instanceInfo.url
req, err := http.NewRequest(http.MethodGet, url, nil)
Expand All @@ -1943,7 +1950,7 @@ func (e *TiFlashSystemTableRetriever) dataForTiFlashSystemTables(ctx sessionctx.
q := req.URL.Query()
q.Add("query", sql)
req.URL.RawQuery = q.Encode()
resp, err := httpClient.Do(req)
resp, err := util.InternalHTTPClient().Do(req)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit d0dfc77

Please sign in to comment.