Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: make expression TestGetLock test more stable #42815

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #35155

Problem Summary:

What is changed and how it works?

The error is not always terror errors.Cause(err).(*terror.Error).

The expected error in the test is mysql.ErrLockWaitTimeout, but sometimes the error got is
errors.New("pessimistic lock retry limit reached") which is not a terror.

So the assumption cause panic.

--- FAIL: TestGetLock (1.88s)
panic: interface conversion: error is *errors.fundamental, not *errors.Error [recovered]
        panic: interface conversion: error is *errors.fundamental, not *errors.Error [recovered]
        panic: interface conversion: error is *errors.fundamental, not *errors.Error

goroutine 100 [running]:
testing.tRunner.func1.2({0x48b9d40, 0xc006f54f90})
        /home/genius/project/go/src/testing/testing.go:1526 +0x24e
testing.tRunner.func1()
        /home/genius/project/go/src/testing/testing.go:1529 +0x39f
panic({0x48b9d40, 0xc006f54f90})
        /home/genius/project/go/src/runtime/panic.go:884 +0x213
github.com/pingcap/tidb/executor.(*Compiler).Compile.func1()
        /home/genius/project/src/github.com/pingcap/tidb/executor/compiler.go:54 +0x445
panic({0x48b9d40, 0xc006f54f90})
        /home/genius/project/go/src/runtime/panic.go:884 +0x213
github.com/pingcap/tidb/expression.(*builtinLockSig).evalInt(0xc008622d10, {0x0?, 0xc008622d10?})
        /home/genius/project/src/github.com/pingcap/tidb/expression/builtin_miscellaneous.go:232 +0x485
github.com/pingcap/tidb/expression.(*ScalarFunction).EvalInt(0xc004d45ae0, {0x55edc90, 0xc004d7e280}, {0x0?, 0x2718af5?})
        /home/genius/project/src/github.com/pingcap/tidb/expression/scalar_function.go:406 +0x9c
github.com/pingcap/tidb/expression.(*ScalarFunction).Eval(0xc004d45ae0, {0x0?, 0x55edc90?})
        /home/genius/project/src/github.com/pingcap/tidb/expression/scalar_function.go:362 +0x246
github.com/pingcap/tidb/expression.foldConstant({0x55eca40?, 0xc004d45ae0?})
        /home/genius/project/src/github.com/pingcap/tidb/expression/constant_fold.go:221 +0x9f5
github.com/pingcap/tidb/expression.FoldConstant({0x55eca40, 0xc004d45ae0})
        /home/genius/project/src/github.com/pingcap/tidb/expression/constant_fold.go:40 +0x27
github.com/pingcap/tidb/expression.newFunctionImpl({0x55edc90, 0xc004d7e280}, 0x1, {0x4e3d471?, 0x7f2b600e7108?}, 0xc004e4ba20, {0xc0075975e0, 0x2, 0xc006697a40?})
        /home/genius/project/src/github.com/pingcap/tidb/expression/scalar_function.go:243 +0x716
github.com/pingcap/tidb/expression.NewFunction(...)
        /home/genius/project/src/github.com/pingcap/tidb/expression/scalar_function.go:261
github.com/pingcap/tidb/planner/core.(*expressionRewriter).newFunction(0xc00780b860, {0x4e3d471?, 0x4e3d471?}, 0x8?, {0xc0075975e0?, 0x7f2b2c908938?, 0xc004fc1b50?})
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1321 +0xa6
github.com/pingcap/tidb/planner/core.(*expressionRewriter).funcCallToExpression(0xc00780b860, 0xc004e4b9e0)
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1993 +0x6fb
github.com/pingcap/tidb/planner/core.(*expressionRewriter).Leave(0xc00780b860, {0x558f980?, 0xc004e4b9e0?})
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:1166 +0x67d
github.com/pingcap/tidb/parser/ast.(*FuncCallExpr).Accept(0xc00780b790?, {0x556b0f8, 0xc00780b860})
        /home/genius/project/src/github.com/pingcap/tidb/parser/ast/functions.go:580 +0x178
github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteExprNode(0xc006467380?, 0xc00780b860, {0x559e6a0?, 0xc004e4b9e0?}, 0x1)
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:200 +0x129
github.com/pingcap/tidb/planner/core.(*PlanBuilder).rewriteWithPreprocess(0xc006467380, {0x55809e8?, 0xc000058078?}, {0x559e6a0, 0xc004e4b9e0}, {0x55be560?, 0xc00780b790?}, 0x0, 0x0, 0x1, ...)
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/expression_rewriter.go:146 +0x173
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildProjection(0xc006467380, {0x55809e8, 0xc000058078}, {0x55be560?, 0xc00780b790?}, {0xc0070317b8, 0x1, 0x1855805?}, 0x74170a0?, 0x0, ...)
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:1446 +0x5f2
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildSelect(0xc006467380, {0x55809e8, 0xc000058078}, 0xc004e4bb00)
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:4162 +0x14bb
github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build(0x1826d52?, {0x55809e8?, 0xc000058078?}, {0x5590ab0?, 0xc004e4bb00?})
        /home/genius/project/src/github.com/pingcap/tidb/planner/core/planbuilder.go:819 +0x34f
github.com/pingcap/tidb/planner.buildLogicalPlan({0x55809e8, 0xc000058078}, {0x55edc90?, 0xc004d7e280}, {0x5590ab0, 0xc004e4bb00}, 0x
c006467380)
        /home/genius/project/src/github.com/pingcap/tidb/planner/optimize.go:511 +0x12c
github.com/pingcap/tidb/planner.optimize({0x55809e8, 0xc000058078}, {0x55edc90?, 0xc004d7e280}, {0x5590ab0?, 0xc004e4bb00?}, {0x55b51
90, 0xc0066edb60})
        /home/genius/project/src/github.com/pingcap/tidb/planner/optimize.go:432 +0x3b3
github.com/pingcap/tidb/planner.Optimize({0x55809e8, 0xc000058078}, {0x55edc90, 0xc004d7e280}, {0x5590ab0, 0xc004e4bb00}, {0x55b5190,
 0xc0066edb60})
        /home/genius/project/src/github.com/pingcap/tidb/planner/optimize.go:295 +0x12de
github.com/pingcap/tidb/executor.(*Compiler).Compile(0xc004fc3728, {0x55809e8?, 0xc000058078?}, {0x5595f48?, 0xc004e4bb00})
        /home/genius/project/src/github.com/pingcap/tidb/executor/compiler.go:98 +0x459
github.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc004d7e280, {0x55809e8?, 0xc000058078?}, {0x5595f48?, 0xc004e4bb00})
        /home/genius/project/src/github.com/pingcap/tidb/session/session.go:2150 +0x4c5
github.com/pingcap/tidb/testkit.(*TestKit).ExecWithContext(0xc004dd4ff0, {0x55809e8, 0xc000058078}, {0x4e3d46a, 0x22}, {0x0, 0x0, 0x0
})
        /home/genius/project/src/github.com/pingcap/tidb/testkit/testkit.go:325 +0x675
github.com/pingcap/tidb/testkit.(*TestKit).MustQueryWithContext(0xc004dd4ff0, {0x55809e8, 0xc000058078}, {0x4e3d46a, 0x22}, {0x0, 0x0
, 0x0})
        /home/genius/project/src/github.com/pingcap/tidb/testkit/testkit.go:156 +0x145

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 4, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • hawkingrei
  • lance6716

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 4, 2023
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 4, 2023
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 4, 2023
@hawkingrei
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: d8d26b8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 4, 2023
@ti-chi-bot ti-chi-bot merged commit a0f2405 into pingcap:master Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstable test expression TestGetLock
4 participants