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

add skip isolation level check variable #10065

Merged
merged 13 commits into from
Apr 11, 2019

Conversation

marsishandsome
Copy link
Contributor

@marsishandsome marsishandsome commented Apr 8, 2019

What problem does this PR solve?

This patch (https://github.com/pingcap/tidb/pull/8625/files) breaks backward compatible.
When using tidb as hive's metastore, hive will set transaction isolation level to serializable, which will cause the following error:

ERROR 1105 (HY000): variable 'tx_isolation' does not yet support value: SERIALIZABLE

What is changed and how it works?

This PR provide a variable tidb_skip_isolation_level_check.
If tidb_skip_isolation_level_check == ON, tidb will not throw an error if hive call set session transaction isolation level serializable;. tidb_skip_isolation_level_check's default value is OFF.

Check List

Tests

  • Unit test

Related changes

  • Need to be included in the release note
  • Need to cherry-pick to the release branch

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2019

CLA assistant check
All committers have signed the CLA.

@marsishandsome
Copy link
Contributor Author

/run-all-tests

@codecov
Copy link

codecov bot commented Apr 8, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@ee99570). Click here to learn what that means.
The diff coverage is 35.7142%.

@@             Coverage Diff             @@
##             master     #10065   +/-   ##
===========================================
  Coverage          ?   78.1129%           
===========================================
  Files             ?        405           
  Lines             ?      82044           
  Branches          ?          0           
===========================================
  Hits              ?      64087           
  Misses            ?      13254           
  Partials          ?       4703

@marsishandsome
Copy link
Contributor Author

/run-all-tests

@marsishandsome marsishandsome force-pushed the feature/strict_compatibility branch 4 times, most recently from c594105 to 6740581 Compare April 8, 2019 14:56
@marsishandsome
Copy link
Contributor Author

/run-all-tests

1 similar comment
@marsishandsome
Copy link
Contributor Author

/run-all-tests

@marsishandsome
Copy link
Contributor Author

@jackysp @zhexuany please review

@morgo
Copy link
Contributor

morgo commented Apr 8, 2019

@marsishandsome thank you for looking into this. I would like to suggest that we don't call it strict, since in other MySQL contexts strict means "more safe". Here it means "less safe" because an error is downgraded.

The MySQL-like name for this would be "ignore" or "skip". I would also prefer to have a purposeful name here, because it is a very specific feature being disabled which is unsafe (versus a generic name, which may be better if they are just general changes).

So perhaps skip-isolation-level-checks?

PTAL @kolbe

@zhexuany
Copy link
Contributor

zhexuany commented Apr 8, 2019

@morgo Agreed. I guess the intention of tidb_strict_compatibility is that when it on throws an error on unsupported isolation level. skip_isolation_level_check maybe a better name. /cc @marsishandsome WDUT?

@marsishandsome
Copy link
Contributor Author

@morgo @jackysp PTAL

tk.MustExec("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE")
tk.MustQuery("show warnings").Check(testkit.Rows(
"Warning 1105 The isolation level 'SERIALIZABLE' is not supported. Set tidb_skip_isolation_level_check=1 to skip this error",
"Warning 1105 The isolation level 'SERIALIZABLE' is not supported. Set tidb_skip_isolation_level_check=1 to skip this error"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to see just one warning here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zhexuany @jackysp any suggestions about how to elegantly deduplicate two same warnings?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should debug it, why the warning was appended twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SET TRANSACTION ISOLATION LEVEL will affect two internal variables:

  1. tx_isolation
  2. transaction_isolation

So the function ValidateSetSystemVar is called twice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the error message does not mention which variable was set now, it is easy to fix by wrapping an if around transaction_isolation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@morgo @jackysp PTAL again

tk.MustExec("SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")
tk.MustQuery("show warnings").Check(testkit.Rows(
"Warning 1105 The isolation level 'READ-UNCOMMITTED' is not supported. Set tidb_skip_isolation_level_check=1 to skip this error",
"Warning 1105 The isolation level 'READ-UNCOMMITTED' is not supported. Set tidb_skip_isolation_level_check=1 to skip this error"))
Copy link
Contributor

Choose a reason for hiding this comment

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

And here too

Copy link
Contributor

@morgo morgo left a comment

Choose a reason for hiding this comment

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

LGTM

@marsishandsome
Copy link
Contributor Author

/run-all-tests

2 similar comments
@marsishandsome
Copy link
Contributor Author

/run-all-tests

@marsishandsome
Copy link
Contributor Author

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants