Skip to content

*: add tidb_enable_noop_functions to default disable get_lock()/release_lock()#10987

Merged
cfzjywxk merged 7 commits intopingcap:masterfrom
cfzjywxk:p4100
Jul 8, 2019
Merged

*: add tidb_enable_noop_functions to default disable get_lock()/release_lock()#10987
cfzjywxk merged 7 commits intopingcap:masterfrom
cfzjywxk:p4100

Conversation

@cfzjywxk
Copy link
Copy Markdown
Contributor

@cfzjywxk cfzjywxk commented Jun 28, 2019

What problem does this PR solve?

Fixes #10929

This adds the variable tidb_enable_noop_functions to control usage of NOOP funcs in tidb such as get_lock, release_lock (always return 1), since the current behavior could be dangerous for apps relying on these functions working correctly.

The default for tidb_enable_noop_functions is false, thus users must manually set session/global to true to have unsafe behavior.

What is changed and how it works?

add global/session variable "tidb_enable_noop_functions" to control usage of noop functions,
default these usage will report "function xxx has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions"". while set true, these functions can be
used like before

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has newly added system variable

Side effects

  • Breaking backward compatibility
    applications using former version of tidbs have to set "tidb_enable_noop_functions" to true to meet their needs

Related changes

  • Need to update the documentation
  • Need to be included in the release note

@cfzjywxk
Copy link
Copy Markdown
Contributor Author

/run-all-tests

Comment thread expression/builtin.go Outdated
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 28, 2019

CLA assistant check
All committers have signed the CLA.

@zz-jason
Copy link
Copy Markdown
Member

please follow the contributing guide to refactor the PR title: https://github.com/pingcap/community/blob/master/commit-message-pr-style.md

@cfzjywxk cfzjywxk changed the title issue#4100 add new variable to default disable usage of get_lock and … session, sysvar: issue#4100 add new variable to default disable usage of get_lock and … Jun 28, 2019
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 28, 2019

Codecov Report

Merging #10987 into master will decrease coverage by 0.514%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #10987        +/-   ##
================================================
- Coverage   81.6366%   81.1225%   -0.5141%     
================================================
  Files           420        420                
  Lines         91726      89472      -2254     
================================================
- Hits          74882      72582      -2300     
- Misses        11563      11636        +73     
+ Partials       5281       5254        -27

@cfzjywxk
Copy link
Copy Markdown
Contributor Author

@zz-jason PTAL

@morgo morgo changed the title session, sysvar: issue#4100 add new variable to default disable usage of get_lock and … session, sysvar: add new variable to default disable usage of get_lock and … Jun 28, 2019
@morgo
Copy link
Copy Markdown
Contributor

morgo commented Jun 28, 2019

@cfzjywxk I think a better behavior instead of "function not found" would be to suggest the user can change the setting to have syntax-only support. With the current behavior I don't believe many users will discover that such a setting exists (see #10065 for an example error).

I also prefer a name like tidb_skip_errors_for_unsupported_function (maybe this is a bit long, @kolbe do you have any other ideas?)

cc @pingcap/usability-team

@kolbe
Copy link
Copy Markdown
Contributor

kolbe commented Jun 28, 2019

I don't like tidb_use_fake_funcs very much. Having abbreviations in variable names is confusing, and I think using "fake" doesn't convey the right idea. But I also think tidb_skip_errors_for_unsupported_function is much too long. Since these are noop functions, I suggest we call the option tidb_noop_functions or tidb_enable_noop_functions or something along those lines.

@morgo
Copy link
Copy Markdown
Contributor

morgo commented Jun 28, 2019

tidb_enable_noop_functions

+1 for this name

@cfzjywxk
Copy link
Copy Markdown
Contributor Author

@morgo PTAL

@morgo
Copy link
Copy Markdown
Contributor

morgo commented Jun 30, 2019

LGTM

Comment thread executor/set_test.go Outdated
Copy link
Copy Markdown
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lysu lysu added status/LGT1 Indicates that a PR has LGTM 1. and removed status/WIP labels Jul 1, 2019
@lysu
Copy link
Copy Markdown
Contributor

lysu commented Jul 1, 2019

/run-all-tests

Comment thread executor/set_test.go Outdated
@zz-jason zz-jason changed the title session, sysvar: add new variable to default disable usage of get_lock and … *: add tidb_enable_noop_functions to default disable get_lock()/release_lock() Jul 1, 2019
@cfzjywxk
Copy link
Copy Markdown
Contributor Author

cfzjywxk commented Jul 1, 2019

/run-all-tests

@cfzjywxk
Copy link
Copy Markdown
Contributor Author

cfzjywxk commented Jul 5, 2019

/run-all-tests

1 similar comment
@cfzjywxk
Copy link
Copy Markdown
Contributor Author

cfzjywxk commented Jul 5, 2019

/run-all-tests

@lysu
Copy link
Copy Markdown
Contributor

lysu commented Jul 5, 2019

/run-all-tests

time.Sleep(time.Second)
c.Assert(failpoint.Disable("github.com/pingcap/tidb/store/tikv/panicInFailPendingRequests"), IsNil)
c.Assert(failpoint.Disable("github.com/pingcap/tidb/store/tikv/gotErrorInRecvLoop"), IsNil)
time.Sleep(time.Second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why adding a sleep?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zz-jason new case "client_fail_test" not stable may fail running "make test", like:

FAIL: client_fail_test.go:34: testClientSuite.TestPanicInRecvLoop

client_fail_test.go:59:
c.Assert(err, IsNil)
... value *errors.fundamental = injected error in batchRecvLoop ("injected error in batchRecvLoop")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TiDB 3.0 may also have this problem. /cc @hicqu

@cfzjywxk
Copy link
Copy Markdown
Contributor Author

cfzjywxk commented Jul 8, 2019

/run-all-tests

Copy link
Copy Markdown
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 8, 2019
@cfzjywxk cfzjywxk merged commit a737d26 into pingcap:master Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/session status/LGT2 Indicates that a PR has LGTM 2.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_lock() and release_lock() should produce errors

7 participants