-
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
Discussion/opinions: query comments or specialized SQL syntax? #6782
Comments
|
As a developer I would request you go with the query comments because:
As a way of preventing certain errors in the in query comment I would argue VTExplain could be used, including the part of a warning for a missing "+". If someone is planning on sending special messages to vitess then he/she should have access to the other VT tools and would use them to test and verify. |
|
@harshit-gangal question: regarding OK packet, this seems orthogonal to the question of comments/syntax, correct? |
Another potential risk with comments is that the official mysql CLI strips comments by default. That seems like it could lead to accidents or confusion if removing comments could cause different or incorrect behavior. |
@dweitzman thank you! In interesting timing I just found out the same, thanks @systay for pairing with me to find this. This is a serious problem. To reiterate, the standard
This behavior is only (to the best of my knowledge right now) found in the For both Thus, if we're to use query comments, we will have to use the MySQL special comment syntax, Related side note on MySQL commentsThe MySQL syntax, which includes an exclamation mark, is also a bit problematic with This is simple enough with This is all to say: the end user's experience is going to become more unpleasant. summary of this commentWe must either:
|
If we're to use MySQL special query comments, things get even more complicated. That's because we'll need to strip them out -- MySQL accepts those comments as query text. But now we must remove those, and only if we match them to be vitess hints. |
I have to say I can't converge on the correct approach. The fact that the standard |
I've had this idea of embedding comments within comments by way of bypassing the MySQL comment issue, e.g. |
Controversial idea: what if, in |
Another idea: how about this gets sorted out by a session variable? That is, a special session variable intercepted by Vitess (and does not get forwarded to MySQL). Consider:
|
I like this approach.
|
#7042 added:
|
#7069 removed |
Documentation PR: vitessio/website#598 |
We've made a decision with online DDL, and will use similar approach to safe |
On the topics of online schema migrations and managed DROP TABLE, there is the question of how to tell vitess we want an online migration vs normal migration, managed table drop vs. normal table drop. There's two major options, and both have pros and cons, The more I think of it, the less sure I am which approach is more correct. Let's begin with a few examples and then discuss advantages and risks.
Specialized syntax examples:
ALTER WITH 'gh-ost' TABLE mytable ADD COLUMN c INT
ALTER WITH 'gh-ost' '--critical-load Threads_running=500 --critical-load-hibernate-seconds=60' TABLE mytable ADD COLUMN c INT
DROP IN '24h' TABLE mytable
DROP IN NOWAIT TABLE mytable
Query comments examples:
ALTER /*vt+ WITH=gh-ost */ TABLE mytable ADD COLUMN c INT
ALTER /*vt+ WITH=gh-ost ARGS='--critical-load Threads_running=500 --critical-load-hibernate-seconds=60' */ TABLE mytable ADD COLUMN c INT
DROP /*vt+ IN=24h */ TABLE mytable
DROP /*vt+ IN=NOWAIT */ TABLE mytable
Now let's consider advantages and risks.
ALTER /*vt+ WITH=gh-ost */ TABLE mytable ADD COLUMN c INT
on a standard MySQL server, that's just a normalALTER TABLE
. If you run this on Vitess, that's an online alter table.a. This is a great advantage because you can deploy the same migration command on all environments and each will behave as you expect.
b. This is also a great risk, because if the user makes a tiny typo, e.g.
ALTER /*vt WITH=gh-ost */ TABLE mytable ADD COLUMN c INT
, then there's no syntax error, nothin gto tell the user "did you actually intend to..." and what happens is that Vitess does not see a Vitess hint, skips the comment, and actually runs normalALTER TABLE
in production (see 1.)That's actually what frightens me the most. I want users to have a great experience, and this lets users shoot themselves in the foot.
I'd like to have a reasonable discussion before making a decision, and getting as many viewpoints as possible. (4b.) is to me the main risk and reason to not using query comments. But perhaps I'm not seeing a simple way around the risk.
The text was updated successfully, but these errors were encountered: