-
Notifications
You must be signed in to change notification settings - Fork 2.3k
WIP: add optional flag to enable multi shard autocommit by default #17635
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
Conversation
Adds a new vtgate flag --default-multi-shard-autocommit which, as the name implies, opts the query engine into using multi-shard autocommit semantics by default, even if the plan does not contain the query directive MULTI_SHARD_AUTOCOMMIT. Signed-off-by: Michael Demmer <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17635 +/- ##
==========================================
+ Coverage 67.68% 67.69% +0.01%
==========================================
Files 1586 1586
Lines 255647 255654 +7
==========================================
+ Hits 173034 173075 +41
+ Misses 82613 82579 -34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
How about we use |
|
Great question -- I considered that as well and if that's what we all think would be a better way to do this, I could try it out and see how it goes.
That said, I opted for a separate option for a couple reasons:
1. Conceptually, a new "MULTI_AUTOCOMMIT_ALLOWED" transaction mode would be basically the same as MULTI just with this one tweak.
So, the change seemed more like the `--no-scatter` option which was added a while back in that it affects a particular behavior of the vtgate rather than defining a whole new "mode".
2. Pragmatically, doing a new transaction mode would be a more involved patch to plumb down into all the right places and would involve a lot more boilerplate changes to end up in the 2-3 places that we actually have to change the executor.
|
|
This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:
If no action is taken within 7 days, this PR will be closed. |
|
@harshit-gangal @deepthi This PR sat kinda idle. Is this something that we feel ok about moving forward? I'm happy to work on the test conflicts if so. |
|
|
||
| func (dml *DML) execMultiShard(ctx context.Context, primitive Primitive, vcursor VCursor, rss []*srvtopo.ResolvedShard, queries []*querypb.BoundQuery) (*sqltypes.Result, error) { | ||
| autocommit := (len(rss) == 1 || dml.MultiShardAutocommit) && vcursor.AutocommitApproval() | ||
| autocommit := (len(rss) == 1 || vcursor.DefaultMultiShardAutocommit() || dml.MultiShardAutocommit) && vcursor.AutocommitApproval() |
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.
dml.MultiShardAutocommit should be authoritative over the default, so if we want to override the default let's say true with a false we have to consider that.
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 would need to store like a enum or a pointer bool in the plan to know if this is set or not.
|
|
||
| // DefaultMultiShardAutocommit will opt into autocommit semantics even for multi shard DMLs | ||
| DefaultMultiShardAutocommit 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.
nit: This is not used by executor, it is only passed to vcusor. We can set on the vcursor config directly.
@demmer Sorry for the delay. I have reviewed the code now. |
|
This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:
If no action is taken within 7 days, this PR will be closed. |
|
This PR was closed because it has been stale for 7 days with no activity. |
Description
Note this is a RFC Draft PR -- soliciting feedback on the idea / proposed implementation.
Adds a new vtgate flag
--default-multi-shard-autocommitwhich, as the name implies, opts the query engine into using multi-shard autocommit semantics by default, even if the plan does not contain the query directive MULTI_SHARD_AUTOCOMMIT.The aim of this change is to help protect Slack or other large scale Vitess adopters that use autocommit from inadvertently expensive extra round trips on scatter DMLs.
As a general rule, Slack avoids scatter DMLs, but on occasion when they are needed, prefer the semantics of the MULTI_SHARD_AUTOCOMMIT=1 query directive (in which each shard executes its own autocommit DML) as opposed to the default behavior (in which each shard runs the DML in a transaction and vtgate issues a second round trip to commit).
We generally apply this as a directive in the application code, but that doesn't prevent mistakes where developers can inadvertently forget to apply the directive.
This PR adds an option to change the default behavior so that this is opted in by default. It should not affect any semantics on explicit transactions, nor should it affect any deployments that don't enable the feature.
Related Issue(s)
None.
Checklist
Deployment Notes