-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
mysql: improve warnings when data directory is present. #60190
Conversation
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.
Thanks for the PR! I think the [WARNING]
is a bit out of place and a few questions/tweaks but otherwise: nice work!
Can you prefix the commit message with |
I've removed the warning, but this won't detect the presence of that data directory unless it can add something to the caveats from the Update: I don't think that is possible, but at least users will get a note to remind them that this data directory could cause issues. |
Thanks!
I'm not sure I understand this, can you explain why this would be useful?
Yes, I was thinking this alone would be useful. |
We could detect the presence of the data directory before the post_install runs and alter the caveats depending on the result, so the user could be reminded that they had already installed mysql there. I believe that when the user invokes the formula the install method runs, then the post_install method, and then the caveats method. When the program enters the post_install method, there isn't any way of modifying the caveats, but it's at this point when we could check to see if that data directory already exists and add a warning about it for the user to see. Once the program is in the caveats method, it's already too late to check if there was a pre-existing data directory as brew has already run the mysql initialize on it via the post_install method. |
I see. In that case the change as-is seems rather pointless, unfortunately. Can you point to the specific issues that are being caused by this being already present and how failures occur? |
Yes, I added some details to before I opened this issue on https://discourse.brew.sh/t/for-homebrew-mysql-installs-how-to-fix-mysql-sock-path/660/8 |
I see, thanks.
I think in this case it needs to check specifically if the data directory exists and is for a newer version of MySQL than the one you're installing. I'm not sure how to do this but it feels like the right direction (and would need to be made to |
@peterb You may want to look at how the |
@gromgit This isn't necessary/comparable with MySQL because:
We could consider using separate data directories for the older versions of MySQL we have (but we'd need to have it only take effect if the datadir doesn't exist so we don't break existing installs). |
@MikeMcQuaid I'm happy to look at the |
Yeh, there should be. I have no idea what it is, though 😭
Yes, that's a safe assumption 👍🏻 |
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.
Just so my review is here (as @SMillerDev requested this): as-is this unfortunately won't do anything but we could consider moving the datadir
for new installs.
@MikeMcQuaid I'm looking into this already, have just pushed some of the changes. |
Thanks @peterb, no rush! |
Users are already warned about config files, warn users about conflicting data directory too.
Refine logic for detecting which version of MySQL the datadir corresponds to by refactoring and adding heuristic for detection of MySQL 5.6.
Use special installation directory in MySQL 5.6 formula as well, unless the default is already being used.
Formula/mysql@5.6.rb
Outdated
# type MYISAM, MySQL version 50647 | ||
# | ||
def default_datadir_already_in_use_by_this_version? | ||
(var/"mysql").exist? && var.glob("mysql/*.dblwr").empty? && (var/"mysql/test").exist? |
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.
Think it's enough to just check for (var/"mysql").exist?
?
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.
Could also output something in the caveats
based on this?
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.
Sounds good, I think that a simpler check and a caveat explaining the location of the datadir to the user would be preferable to trying to work it out automatically for them. I'll modify as you suggest.
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.
Update: It turns out this is harder to do than I expected, as putting a conditional in the datadir
method means it gets evaluated differently during various stages in the formula.
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
for each version.
@MikeMcQuaid I've updated this to something along the lines of what you were suggesting, I think that detecting if another version of MySQL is installed and using a different datadir is a nice idea in theory, but based on how the formula works it could make it more confusing for the user, and detecting the version of MySQL isn't going to be reliable because there are so many different heuristics but no definitive way of doing it. With separate datadirs for each version ( Summary: assuming a fresh OSX install, this would get rid of the gotcha that 5.7 will break and requires manually fixing the datadir if MySQL 8 is already installed. If they already have a legacy MySQL installed and decide to run reinstall, then the caveats will tell them that the datadir location has moved. |
Not sure what the consensus is on this one, so closing it for the moment. |
Reopening because it's on my list, sorry for the delay here. |
@MikeMcQuaid thanks! At a first glance #65102 looks like a good example, I'll take a more detailed look at it. |
@MikeMcQuaid MySQL 5.6 has reached end-of-life, so it's probably only worth updating the formula for MySQL 5.7. EDIT: 5.6 will reach EOL in three months time. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
@MikeMcQuaid @SMillerDev @gromgit sorry for the delay in picking his up. I could look at MySQL 5.7? How valuable would be for Homebrew? |
Go for it, every improvement is valuable |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Users are already warned about config files, warn users about conflicting data directory too.