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

*: modify 'session transaction isolation level' to take effect once #6175

Merged
merged 9 commits into from
Apr 4, 2018

Conversation

tiancaiamao
Copy link
Contributor

session transaction isolation level is not the same with
session session transaction isolation level, it should take effect
only once to the next transaction.

@coocood @zz-jason

'session transaction isolation level' is not the same with
'session session transaction isolation level', it should take effect
only once to the next transaction.

// set transaction isolation level read committed take effect just one time.
tk2.MustExec("update t set v = 43 where k = 1")
tk1.MustQuery("select v from t where k = 1").Check(testkit.Rows("43"))
Copy link
Member

Choose a reason for hiding this comment

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

This test does not verify that the desired isolation level is set.

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood
/run-all-tests

@coocood
Copy link
Member

coocood commented Apr 2, 2018

@tiancaiamao
Since it's not allowed to change transaction level in a transaction and the set statement does not trigger commit, there is no need to maintain a state.

@tiancaiamao
Copy link
Contributor Author

set statement still run into doCommitWithRetry, if I don't maintain a state for tx_isolation_one_shot, it will be reset immediately, in the set statement itself. @coocood

@coocood
Copy link
Member

coocood commented Apr 3, 2018

LGTM

@zimulala zimulala added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 4, 2018
@@ -448,6 +457,9 @@ func (s *SessionVars) deleteSystemVar(name string) error {
// SetSystemVar sets the value of a system variable.
func (s *SessionVars) SetSystemVar(name string, val string) error {
switch name {
case "tx_isolation_one_shot":
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we define a constant as tx_isolation_one_shot ?

executor/set.go Outdated
@@ -150,6 +150,9 @@ func (e *SetExecutor) setSysVariable(name string, v *expression.VarAssignment) e
return errors.Trace(err)
}
oldSnapshotTS := sessionVars.SnapshotTS
if name == "tx_isolation_one_shot" && sessionVars.InTxn() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a test for it?

@@ -125,7 +125,13 @@ func (builder *RequestBuilder) SetKeepOrder(order bool) *RequestBuilder {
}

func (builder *RequestBuilder) getIsolationLevel(sv *variable.SessionVars) kv.IsoLevel {
isoLevel, _ := sv.GetSystemVar(variable.TxnIsolation)
var isoLevel string
if sv.TxnIsolationLevelOneShot.State == 2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does it need special handling?

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 statement still run into doCommitWithRetry, if I don't maintain a state for tx_isolation_one_shot, it will be reset immediately, in the set statement itself.
@zimulala

@tiancaiamao
Copy link
Contributor Author

PTAL @zimulala

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 4, 2018
@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

@coocood coocood merged commit 6287cfb into pingcap:master Apr 4, 2018
@tiancaiamao tiancaiamao deleted the isolation-one-shot branch April 4, 2018 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants