From 4b076331523ae630b4abd2a6edc553690ac75c1c Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Mon, 4 Nov 2024 14:31:01 +0800 Subject: [PATCH] fix: fix not show plan issue (#1748) (#1751) --- pkg/apiserver/slowquery/service.go | 10 ++++++---- pkg/apiserver/statement/service.go | 10 ++++++---- .../src/apps/SlowQuery/pages/Detail/index.tsx | 2 +- .../src/apps/Statement/pages/Detail/PlanDetail.tsx | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/apiserver/slowquery/service.go b/pkg/apiserver/slowquery/service.go index 08ff2c0443..3ee089fa7c 100644 --- a/pkg/apiserver/slowquery/service.go +++ b/pkg/apiserver/slowquery/service.go @@ -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) diff --git a/pkg/apiserver/statement/service.go b/pkg/apiserver/statement/service.go index 64169b7246..8f1a360448 100644 --- a/pkg/apiserver/statement/service.go +++ b/pkg/apiserver/statement/service.go @@ -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) diff --git a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx index bc4130f561..875261cfe4 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx +++ b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/pages/Detail/index.tsx @@ -170,7 +170,7 @@ function DetailPage() { ) })()} - {(binaryPlanObj || !!data.plan) && ( + {(!!data.binary_plan_text || !!data.plan) && ( <> {t('slow_query.detail.plan.title')} diff --git a/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx b/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx index 0e9c47b626..bfce9df824 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx +++ b/ui/packages/tidb-dashboard-lib/src/apps/Statement/pages/Detail/PlanDetail.tsx @@ -175,7 +175,7 @@ function PlanDetail({ query }: IPlanDetailProps) { ) : null} - {(binaryPlanObj || !!data.plan) && ( + {(!!data.binary_plan_text || !!data.plan) && ( <> {t('statement.pages.detail.desc.plans.execution.title')}