Skip to content

Commit

Permalink
memory: Fix formatting of memory usage error for analyze table (#45696)
Browse files Browse the repository at this point in the history
close #45690
  • Loading branch information
dveeden authored Aug 17, 2023
1 parent 9f23bae commit 6174973
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions executor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ go_test(
srcs = [
"adapter_test.go",
"analyze_test.go",
"analyze_utils_test.go",
"batch_point_get_test.go",
"benchmark_test.go",
"brie_test.go",
Expand Down
2 changes: 1 addition & 1 deletion executor/analyze_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func getAnalyzePanicErr(r interface{}) error {
return errAnalyzeOOM
}
if strings.Contains(msg, memory.PanicMemoryExceedWarnMsg) {
return errors.Errorf(msg, errAnalyzeOOM)
return errors.Errorf("%s, %s", msg, errAnalyzeOOM)
}
}
if err, ok := r.(error); ok {
Expand Down
29 changes: 29 additions & 0 deletions executor/analyze_utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package executor

import (
"fmt"
"testing"

"github.com/pingcap/tidb/util/memory"
"github.com/stretchr/testify/require"
)

// https://github.com/pingcap/tidb/issues/45690
func TestGetAnalyzePanicErr(t *testing.T) {
errMsg := fmt.Sprintf("%s", getAnalyzePanicErr(memory.PanicMemoryExceedWarnMsg))
require.NotContains(t, errMsg, `%!(EXTRA`)
}

0 comments on commit 6174973

Please sign in to comment.