Skip to content

Commit

Permalink
fix: fix not show plan issue (#1748) (#1750)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Nov 4, 2024
1 parent 00b8142 commit 7d37156
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 6 additions & 4 deletions pkg/apiserver/slowquery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ func (s *Service) getDetails(c *gin.Context) {
// See: https://github.com/pingcap/tidb-dashboard/issues/1515
if result.BinaryPlan != "" {
// may failed but it's ok
result.BinaryPlanText, _ = utils.GenerateBinaryPlanText(db, result.BinaryPlan)
result.BinaryPlanText, err = utils.GenerateBinaryPlanText(db, result.BinaryPlan)
// may failed but it's ok
result.BinaryPlanJSON, _ = utils.GenerateBinaryPlanJSON(result.BinaryPlan)

// reduce response size
result.BinaryPlan = ""
result.Plan = ""
if err == nil {
// reduce response size
result.BinaryPlan = ""
result.Plan = ""
}
}

c.JSON(http.StatusOK, *result)
Expand Down
10 changes: 6 additions & 4 deletions pkg/apiserver/statement/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,15 @@ func (s *Service) planDetailHandler(c *gin.Context) {

if result.AggBinaryPlan != "" {
// may failed but it's ok
result.BinaryPlanText, _ = utils.GenerateBinaryPlanText(db, result.AggBinaryPlan)
result.BinaryPlanText, err = utils.GenerateBinaryPlanText(db, result.AggBinaryPlan)
// may failed but it's ok
result.BinaryPlanJSON, _ = utils.GenerateBinaryPlanJSON(result.AggBinaryPlan)

// reduce response size
result.AggBinaryPlan = ""
result.AggPlan = ""
if err == nil {
// reduce response size
result.AggBinaryPlan = ""
result.AggPlan = ""
}
}

c.JSON(http.StatusOK, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function DetailPage() {
)
})()}
</Descriptions>
{(binaryPlanObj || !!data.plan) && (
{(!!data.binary_plan_text || !!data.plan) && (
<>
<Space size="middle" style={{ color: '#8c8c8c' }}>
{t('slow_query.detail.plan.title')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function PlanDetail({ query }: IPlanDetailProps) {
) : null}
</Descriptions>

{(binaryPlanObj || !!data.plan) && (
{(!!data.binary_plan_text || !!data.plan) && (
<>
<Space size="middle" style={{ color: '#8c8c8c' }}>
{t('statement.pages.detail.desc.plans.execution.title')}
Expand Down

0 comments on commit 7d37156

Please sign in to comment.