-
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
Better handling of partial dml query exec in transaction #9269
Conversation
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…erse the affect of partial dml exec Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…rmal) with correct commit order Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
b639caf
to
204cb1c
Compare
…ack to a savepoint Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…erriding it in nested execute calls Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
…tant accross different vcursors Signed-off-by: Manan Gupta <manan@planetscale.com>
dd18d1d
to
21eb1b7
Compare
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…ns when there is already an open transaction Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
@@ -40,6 +40,11 @@ type SafeSession struct { | |||
mustRollback bool | |||
autocommitState autocommitState | |||
commitOrder vtgatepb.CommitOrder | |||
savepointState savepointState | |||
// rollbackOnPartialExec is set if any DML was successfully |
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.
set to what? why is this a string?
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.
rollbackOnPartialExec will store the rollback to <savepoint>
sql query which is generated randomly when doing MarkSavepoint.
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.
we should add ☝️ to the comment
go/vt/vtgate/vcursor_impl.go
Outdated
@@ -423,6 +421,8 @@ func (vc *vcursorImpl) StreamExecutePrimitive(primitive engine.Primitive, bindVa | |||
return vterrors.New(vtrpcpb.Code_UNAVAILABLE, "upstream shards are not available") | |||
} | |||
|
|||
const txRollback = "Rollback Transaction" |
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.
nit: weird placement for a const
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.
earlier it was near to usage, then the code the moved,
now moved it back to the usage.
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…ecord partial rollback query if the query even succeeds in one shard Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…ries Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
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 good to me. Agreed with @systay on #9269 (comment), we should avoid the repetition in the test suite to make adding/changing tests easier
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
} | ||
|
||
func specialHandlingOfSavepoints(q *MysqlQuery) error { | ||
if !strings.Contains(q.SQL, "savepoint") { |
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.
nit: can't we just skip this string check since we are looking at the type of the AST below?
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.
This is just to avoid parsing overhead.
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.
in vtexplain? doesn't feel like it's part of the code where we need to squeeze extra drops of performance.
¯_(ツ)_/¯
// Default state is savepointStateNotSet, | ||
// if savepoint needed (spNeed true) then it will be set to savepointNeeded otherwise savepointNotNeeded. | ||
|
||
func (session *SafeSession) SetSavepointState(spNeed bool) { |
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.
comment missing
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.
there was extra line, comments are there :)
return len(session.ShardSessions) > 0 || len(session.PreSessions) > 0 || len(session.PostSessions) > 0 | ||
} | ||
|
||
func (session *SafeSession) GetSessions() []*vtgatepb.Session_ShardSession { |
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.
comment missing
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.
added in #9294
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 was too late to accept it, but I would have if given the chance :)
LGTM 👍
Description
This PR reverses the effect of partial dml query execution instead of rolling back the complete transaction when the transaction is explicitly created by the user.
Related Issue(s)
Checklist
Deployment Notes