-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
support transaction isolation modification through reserved connection system settings #11987
Conversation
Signed-off-by: Harshit Gangal <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else looks good, but isn't this like a breaking change? Previously setting the transaction isolation would only apply to the next query, but now it applies to the session, if I understand correctly. Shouldn't this be added to the release notes?
@@ -597,10 +597,10 @@ func (session *SafeSession) SetPreQueries() []string { | |||
first := true | |||
for _, k := range keys { | |||
if first { | |||
preQuery.WriteString(fmt.Sprintf("set @@%s = %s", k, sysVars[k])) | |||
preQuery.WriteString(fmt.Sprintf("set %s = %s", k, sysVars[k])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLDR; previously it was broken.
@@ without any scope represents session
scope. Only for the case of transaction_isolation
it means the next transaction. This gets applied only once.
With the implementation of settings pool
these settings will not be applied again and the connection will be reused, which means the next query the connection will see, will have the session level isolation level and not the next transaction isolation level.
So, the user expectation will turn out to be wrong.
The RFC already states that the next transaction isolation statements will be converted to the session level setting.
Now the other part of it, If the user would have set the transaction_isolation
at the session level. This will get only applied for the next transaction in case of reserved connection
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small suggestion, rest LGTM
|
||
// setting to different value. | ||
utils.Exec(t, conn, "set @@transaction_isolation = 'read-committed'") | ||
utils.AssertMatches(t, conn, "select @@transaction_isolation", `[[VARCHAR("READ-COMMITTED")]]`) | ||
utils.AssertMatches(t, conn, "select @@transaction_isolation", `[[VARCHAR("read-committed")]]`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are some values uppercase and some lowercase?
Line 437 - REPEATABLE-READ
. But everything else is lowercase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it may be an artifact of how the test input is provided. To avoid confusion, my suggestion is to make them all uniform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will raise a separate PR to handle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any other comments than the ones already answered.
* add support for transaction isolation level and make it vitess aware setting (#11673) * feat: add support for tx_isolation and make it vitess aware setting Signed-off-by: Harshit Gangal <[email protected]> * feat: rewrite tx_isolation and transaction_isolation in select query Signed-off-by: Harshit Gangal <[email protected]> * feat: added support for set session transaction isolation level <value> Signed-off-by: Harshit Gangal <[email protected]> * feat: add nextTxScope for transaction variables Signed-off-by: Harshit Gangal <[email protected]> * refactor: use constants over magic literals Signed-off-by: Harshit Gangal <[email protected]> * kept old support for next transaction scope transaction system variables Signed-off-by: Harshit Gangal <[email protected]> * test: added e2e test Signed-off-by: Harshit Gangal <[email protected]> Signed-off-by: Harshit Gangal <[email protected]> * Fix: return allowed transaction isolation level value on select query (#11804) * test: added e2e test Signed-off-by: Harshit Gangal <[email protected]> * test: added unit test Signed-off-by: Harshit Gangal <[email protected]> * fix: transaction_isolation to return connection default when not set Signed-off-by: Harshit Gangal <[email protected]> * test: addressed review comments Signed-off-by: Harshit Gangal <[email protected]> Signed-off-by: Harshit Gangal <[email protected]> * feat: support transaction isolation through reserved connection (#11987) Signed-off-by: Harshit Gangal <[email protected]> Signed-off-by: Harshit Gangal <[email protected]> * store transaction isolation level in upper case (#12099) * store transaction isolation level in upper case Signed-off-by: Harshit Gangal <[email protected]> * store system variables in the case as provided in StorageCase type Signed-off-by: Harshit Gangal <[email protected]> Signed-off-by: Harshit Gangal <[email protected]> Signed-off-by: Harshit Gangal <[email protected]>
Description
This PR moves the transaction isolation system variables (transaction_isolation or set transaction isolation level) from vitess aware to reserved connection.
Earlier it used to only work with transactions. With this change, support will be added for read queries.
Related Issue(s)
Checklist
Deployment Notes