-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 support for MySQL Port / Unix Socket #1498
Conversation
@knnniggett @connortechnology This fixes the incomplete logic linked that does not work because it is not implemented in all the places it needs to be. |
👍 Would be awesome for this to get some traction. I was in the IRC channel a while back asking about it. |
It looks like none of the files this commit touches have changed in a way that will affect this PR. Thanks! |
@josh4trunks this was literally 19mins after 1.30.0 release, so I take it you are keen to get it merged 😄. I did promise it would go in next so if @connortechnology or @knnniggett have no objections I will merge this weekend. |
Well, I was hoping to give the new release a few days out in the wild before we start merging the open pull requests. If something crops up, we won't have a bunch of recent merges in the way if we have to troubleshoot. |
Yeah, I'd love to get this in so I don't need to keep mergeing in my changes for my production system =] But, no need to rush this in before making sure we are good with 1.30.0 |
Wouldn't fixes to 1.30 go on the 1.30 branch? I've been running with this code merged for a while. It's pretty solid. |
Ditto. Been running this since 1.30.0-RC1 and haven't seen any issues. |
I did a quick built and test on Fedora 24 using a single camera and the normal database configuration. Everything worked. Since @connortechnology mentioned this was working for him, I will trust this does not (somehow) negatively affect multiserver. Not sure how it could. In any case, merging.... |
@@ -37,23 +37,35 @@ void zmDbConnect() | |||
my_bool reconnect = 1; | |||
if ( mysql_options( &dbconn, MYSQL_OPT_RECONNECT, &reconnect ) ) | |||
Fatal( "Can't set database auto reconnect option: %s", mysql_error( &dbconn ) ); | |||
std::string::size_type colonIndex = staticConfig.DB_HOST.find( ":/" ); | |||
if ( colonIndex != std::string::npos ) | |||
std::string::size_type colonIndex = staticConfig.DB_HOST.find( ":" ); |
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 think there is a problem in here. So, the new logic is, if we found a colon, then we look for a socket path? That will never happen. The old code looked for either a colon or a slash, and then looked for a /. (By old code I mean some other patch that I merged into storageareas).
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.
See my reply here #1498 (comment).
I put it in the wrong spot =/
Does this have any practical benefit? Does it have a noticeable performance impact? |
@connortechnology the line you are looking at finds the length of the hostname/IP part of the DB_HOST config value. The part which decides if it is a TCP or file(unix) connection is at line 53. |
The practical benefit are you can now specify a socket path to connect to a mysql server. For example if your mysql server has a file socket at /non/default/path/mysql.sock you could enter This makes the logic consistent amounts each file for a given language (1 PHP, 2 C++, and 3 perl). Though the way I implemented it is different for each language because I tried to use the most efficient method given the available functions for that language. |
I assume there might be some small unnoticeable performance impacts because more checking/matching is done before connecting to mysql. But I did my best to use keep things efficient by using character matching like |
Yes but it will only run line 53 if there was a colon. the socket path doesn't have a colon so that code won't get run. I think the real line we are talking about is 383. Where it looks for the /. That only gets run if a colon was found. |
yeah, I assume values are in the format mentioned here. |
I've implemented this in a few different programs, and usually this is the format assumed. But if we want to also support '/path/to/socket' we could change the logic more. We'd need to also implement this in "web/api/app/Config/database.php.default" before passing to Cake. Not sure if that would be difficult but that logic also relieson the ":" |
Oh, I missed that.. I don't understand why we would specify a host if it is a local socket. Huh. I guess I've just never seen that before. Anyone else care to weigh in? |
You really don't need to, but that's how alot of programs I've worked with do it. owncloud/nextcloud, pydio, I think even wordpress. |
Logic is added to handle specified port / unix file socket for database connections.
For example, the following now all work as expected.
Fixes #901