-
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
Add initial support for capabilities #4987
Conversation
This eliminates the need to set MYSQL_FLAVOR Signed-off-by: Morgan Tocker <tocker@gmail.com>
It will cause backwards compatibility problems, since many users set "MySQL56" for any MySQL system. Signed-off-by: Morgan Tocker <tocker@gmail.com>
918dbe7
to
030c2fd
Compare
I have changed the design slightly since the previous behavior broke backward compatibility: now The problem was that I have changed Percona Server to include "mysql" config files, and tested on Percona Server/MySQL from 5.6-8.0. For MariaDB I tested 10.0-10.4. 10.4 breaks, but I believe this issue is pre-existing. The idea to allow |
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 the first time I've seen a capabilities implementation, so forgive me if this is standard practice for reasons I don't understand, but at a high level I have doubts about the use of constants here. I'll describe this high level concern in this top-level thread. The rest of the line comments are assuming we keep the constants.
Currently, the only way we're using the Capability constants is in hard-coded calls to HasCapability(foo)
which simply selects a particular case from this switch. If this is the way we expect capabilities to be used, this switch statement seems like an unnecessarily roundabout way to allow callers to select a specific code path. We could instead just define a function for each capability, perhaps as a method on a Capabilities object.
That is, instead of mysqld.HasCapability(MySQLUpgradeInServer)
, the call site would be mysqld.Capabilities.HasMySQLUpgradeInServer()
. That gets rid of all the constants and avoids the need to worry about invalid values being passed in (default case below), as well as worrying about whether someone will persist capability constants and reuse them against different versions of the code (see below).
If you had planned to use these capability constants in other, more sophisticated ways later, I could see why they would be needed. For example, do you want to allow serialization and transmission of capabilities over the wire? Or even just dealing with lists of capabilities in-memory? If so, we should talk about what those future use cases are, and also considerations like ensuring stability of the constants across code changes. If not, it feels to me like the complexity of the enumeration+switch is unnecessary.
Oops I just submitted a review based on the code before this change. Before we drop MYSQL_FLAVOR, we need to be careful we don't break support for the use case in which Ideally, we can detect the version of a remote mysqld by connecting to it and asking it, in that case. The My hope is that we can prove that the code paths that require |
@morgo I think it will be good to create an issue that outlines the problem and the proposed solution. Once any comments on the design are addressed, it will be much easier to review the PR. |
That is a good idea. I am going to push some of the config changes prior (described in #4990 ), and then after this PR. It will reduce the size and scope. |
Signed-off-by: Morgan Tocker <tocker@gmail.com>
…ilities Signed-off-by: Morgan Tocker <tocker@gmail.com>
Reverted small changes to configs Signed-off-by: Morgan Tocker <tocker@gmail.com>
I didn't realize I had not finished the detectVersion refactoring when I pushed. Sorry, don't review for now.. I will update soon. |
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
I chatted with @sougou about this, and it shouldn't be a problem. |
@enisoc followup ping. Many changes, looking for your review :-) |
Responding to @enisoc's comment about hiding the capabilities using separate implementations: I looked at how these capabilities were used. I think moving to separate implementations will be too big of a leap from where we are today. The capabilities approach allows us to replace existing conditional logic to use these abstracted out functions. In other words, it feels like there will be a lot of shared code between different implementations, and will require us to refactor the common parts out. So, I think this is a good starting point for this. |
@morgo wrote:
Even though no one uses the With that said, I'm willing to trust the tests on this. And if remote mysqld isn't tested, then that feature doesn't actually exist IMO. @sougou wrote:
I wasn't suggesting separate implementations. There's only one, concrete implementation; no interfaces. I just suggested making separate functions instead of one big function with a |
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.
Sorry for the delay. I went on vacation and then got swamped by PS stuff when I got back.
Looking good overall! Mostly just style comments and some error-handling changes.
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.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.
I'm still worried about the error handling in NewMysqld
. Let me know if my reasoning isn't clear. We can set up a call to discuss it.
Added tests for version detection Signed-off-by: Morgan Tocker <tocker@gmail.com>
71162b7
to
e7f7474
Compare
Signed-off-by: Morgan Tocker <tocker@gmail.com>
I thought about this: it's a bad idea. It means that if there was a test that created 2 mysqld's, the usage would not be repeatable/idempotent. Signed-off-by: Morgan Tocker <tocker@gmail.com>
Signed-off-by: Morgan Tocker <tocker@gmail.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 overall. Just some final style nits. Thanks for being patient with the long review process.
Signed-off-by: Morgan Tocker <tocker@gmail.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.
LGTM
This is no longer required since vitessio/vitess#4987 merged Signed-off-by: Morgan Tocker <tocker@gmail.com>
Nice work! |
This eliminates the need to set
MYSQL_FLAVOR
. I added it togo/vt/
rather thango/mysql/
based on that it is verymysqld
(andmysqlctl
) centric.There is an existing flavor-specific system for connections in
go/mysql
, but it branches between mysqld and mariadb. I looked at opportunities to merge the two, but this system is more about capabilities and differences between versions for bootstrapping binaries inmysqlctl
. It also has a chicken and egg problem: the connection system requires a database installed, and this system uses capabilities to figure out how it should be installed (there is no database yet).Fixes #4998
Signed-off-by: Morgan Tocker tocker@gmail.com