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

*: preload load frequent use variable #10463

Merged
merged 5 commits into from
May 29, 2019
Merged

*: preload load frequent use variable #10463

merged 5 commits into from
May 29, 2019

Conversation

lysu
Copy link
Contributor

@lysu lysu commented May 14, 2019

What problem does this PR solve?

fixes #10388, preload JDBC used variable into memory as default value

this will improve to java based application that frequent establish new connections to TiDB.

What is changed and how it works?

preload those variable:

	variable.InitConnect,
	variable.TxnIsolation,
	variable.TxReadOnly,
	variable.TransactionIsolation,
	variable.TransactionReadOnly,
	variable.NetBufferLength,
	variable.QueryCacheType,
	variable.QueryCacheSize,
	variable.CharacterSetServer,
	variable.AutoIncrementIncrement,
	variable.CollationServer,
	variable.NetWriteTimeout,

so, they can preload into session.

change MaxAllowedPacket as global + session scope https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_allowed_packet

also change InitConnect, QueryCacheSize from global scope to global + session scope, this is not same with mysql, but doesn't break behave. why we need change this is TiDB will access kv every time if it's a global only variable, but for this two variable we no need do that in performance reason.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
add log in GetGlobalSys method and start a jdbc app and connect to tidb and should not see any log output any more.

Code changes

  • impl change

Side effects

  • N/A

Related changes

  • N/A

This change is Reviewable

@lysu
Copy link
Contributor Author

lysu commented May 14, 2019

/run-all-tests

@lysu
Copy link
Contributor Author

lysu commented May 15, 2019

/run-all-tests

@codecov
Copy link

codecov bot commented May 15, 2019

Codecov Report

Merging #10463 into master will increase coverage by 0.032%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##             master     #10463       +/-   ##
===============================================
+ Coverage   77.6801%   77.7121%   +0.032%     
===============================================
  Files           413        413               
  Lines         87505      87559       +54     
===============================================
+ Hits          67974      68044       +70     
+ Misses        14378      14363       -15     
+ Partials       5153       5152        -1

@@ -325,6 +325,8 @@ func (s *testSuite2) TestSetVar(c *C) {
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))

tk.MustExec("SET GLOBAL transaction_isolation='REPEATABLE-READ'")
Copy link
Member

Choose a reason for hiding this comment

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

What's this test case used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should reset tx_isolation back to rr before reset tidb_skip_isolation_level_check.

if we keep global tx_isolation in rc and reset tidb_skip_isolation_level_check to 0, when new session start and retry load global config into the session will meet UnsupportedIsolationLevel error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add some comments but maybe we should cascade reset tx_isolation to rr when tidb_skip_isolation_level_check be set to 0? 🤔

@lysu lysu requested review from jackysp and tiancaiamao May 20, 2019 04:30
@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label May 29, 2019
Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp jackysp added the status/LGT2 Indicates that a PR has LGTM 2. label May 29, 2019
@jackysp jackysp merged commit 7cf35f1 into pingcap:master May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server status/LGT1 Indicates that a PR has LGTM 1. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

avoid read kv for each new session's first select @@variable
4 participants