-
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
Atomic Transactions handling with Online DDL #16585
Conversation
44117cc
to
7e49963
Compare
Signed-off-by: Harshit Gangal <[email protected]>
…y rules Signed-off-by: Harshit Gangal <[email protected]>
7e49963
to
0be1027
Compare
…or prepare transactions Signed-off-by: Harshit Gangal <[email protected]>
0a00811
to
9710dc0
Compare
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
506422a
to
12e2dc5
Compare
@@ -80,12 +84,48 @@ func (dte *DTExecutor) Prepare(transactionID int64, dtid string) error { | |||
return vterrors.VT10002("cannot prepare the transaction on a reserved connection") | |||
} | |||
|
|||
// Fail Prepare if any query rule disallows it. | |||
// This could be due to ongoing cutover happening in vreplication workflow |
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.
Does vtgate attempt to buffer these queries?
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 a prepare call for a distributed transaction that is trying to be committed. If this call fails, then the transaction will be rollbacked.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16585 +/- ##
==========================================
- Coverage 68.99% 68.92% -0.07%
==========================================
Files 1562 1562
Lines 200754 200850 +96
==========================================
- Hits 138508 138435 -73
- Misses 62246 62415 +169 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Harshit Gangal <[email protected]>
…wo pc is disabled Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
} | ||
} | ||
return true | ||
} |
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.
Let's discuss the race condition again: this function is called when query buffering is already in place, which technically prevents a new prepared transaction. And given we also intentionnal sleep(100*time.Milisecond)
in between, I don't see how realistically this might happen, but:
- Say a prepared transaction gets as far as this line:
https://github.com/vitessio/vitess/pull/16585/files#diff-a1efa75583f31e230076c9385a551deb725040bbbf85085833be7c14a7a18055R102 - Say Online DDL cut-over begins and starts buffering.
- The prepared transaction above proceeds a bit further.
- When Online DDL invokes
IsEmpty()
, will it see the prepared transaction above? If yes, fine. If not, then it might kill 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.
Now we give even prepared pool to get empty in 100ms. This will handle the case a transaction gets added to prepared pool after query rules are added.
Within this 100ms, it will recheck the rules and fail the prepare step, allowing online ddl cutover to proceed.
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.
the other check if if if gets past the first query rule check and not added to prepared pool list, then online DDL will kill the connection. This is also handled as we check if the MySQL connection is closed before proceeding.
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.
the other check if if if gets past the first query rule check and not added to prepared pool list
The race condition is what happens if it gets past the first check, then Online DDL doesn't see it in the prepared pool list and proceeds towards the killing function, then the query gets into the prepared pool list, then Online DDL actually finds it and kills 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.
The list is just a first check point.
The prepare happens latter on when we update the database with the redo logs. Till then any failure is accepted
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Description
This PR handles the case for atomic transactions and online ddl to work together during cutover so that atomic guarantees are not broken.
Online DDL will wait for any existing prepared atomic transactions to be completed and prevent any new transactions from being prepared.
Related Issue(s)
Checklist