[MDEV-5479] mysqld daemon should check if any process uses the socket file before removing Created: 2013-12-20 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.34 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Honza Horak | Assignee: | Daniel Black |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | contribution, foundation, patch, upstream | ||
| Environment: |
Linux |
||
| Description |
|
Already reported to http://bugs.mysql.com/71194 When running some MySQL daemon A and we are trying to run another instance B, while these conditions are met:
Then the new daemon B removes the unix socket file that is actually necessary for daemon A. How to repeat: Actual results: Expected results: Suggested fix: |
| Comments |
| Comment by Daniel Black [ 2017-12-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
I tested by removing the unlink of the unix socket before the bind and indeed the second instance fails to start reporting the error:
So removing the unlink is the minimal fix. A more comprehensive check could test if the existing socket is responsive and only in the non-responsive case remove it like https://github.com/grooverdan/mariadb-server/commit/f4191b0628531b3e0ebe1d2ce53eb8312433fde6 (breaks the way some of mtr works). This totally ignores your suggested fix mainly because I see it as too susceptible to race conditions and the behaviour of the other instance (which might be a different server version). The existing implementation and my variant are still susceptible to race conditions (in which the second server will abort) however as there isn't a truncate option with bind there isn't a race free implementation. Do you think this is on the right track? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2020-02-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
hhorak, we support bright and shiny abstract sockets since 10.4. Is it viable alternative? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Honza Horak [ 2022-03-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry for the long delay. I think abstract sockets help with the proper removing when the daemon ends. It's not clear to me whether it should help with not removing the socket of another daemon, at least based on the source, the second daemon can still remove (unlink) the socket from a different daemon. I think the abstract sockets would work well together with the Daniel's commit above, which seems to be not applied. So, while this issue does not seem to be very high priority for us, it doesn't seem to be solved by abstract sockets. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Honza Horak [ 2022-03-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
To share more about priority – we used to use Software Collections (a packaging concept, that allowed to install more versions of mariadb/mysql database servers in a single OS instance). With using a different concept (modules) that only allows to install one version at the same time (pick one from more variants available), it is not anymore that common that a user would run two daemons with a single unix socket by accident. Thus, not having this issue fixed does not seem to cause too much troubles in reality. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2022-03-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Abstract sockets (10.4+) aren't unlinked. But still after all these years, its not common use, so same problem. I tried and it seems that you can advisory lock a unix socket. I think those disappear when the process goes, so something like the following with acquiring the lock before an unlink.
|