Skip to content

Conversation

@grooverdan
Copy link
Member

Adds system functionality to mariadb including socket activation and notification.

Add systemd detection (autoenabled) and configuration option.

Enable systemd for debian and ubuntu
mysql_socket_fd mirrors the functionality of mysql_socket_socket.

Needed for systemd socket activation.
This adds systemd socket activation functionality to MariaDB where the
system libraries exist for it.

When started from init scripts mysqld functions the same as it does
before this patch.

When systemd socket activation starts mysqld, systemd does the listening
and leaves these listening file descriptors open. Assisted by
sd_listen_fds, the sockets are populated into arrays.

Configuration options ignored by mysqld when instigated from systemd
socket activation include:
* bind-address
* port
* extra-port
* socket
* skip-networking
* max-connections

Systemd socket activation definations (e.g. support-files/mariadb.socket)
provide an arbitary number of sockets for MariaDB to listen on. 10 was
chosen as an arbitary number bigger than the currently supported 2 TCP
ports and one unix socket for the maximium number supported.

The support-files/mariadb-socket-convert script can be used to convert my.cnf
files and extract the needed config files to create a mariadb.socket file.

The functionalty provided by extra_port isn't supported on MariaDB under
socket activation as all sockets are treated equal.

support-files/mariadb.service provides a systemd service file. This
replaces mysqld_safe. Inside this file there are examples on how to
replace specific mysqld_safe variables.
Add systemd notification for long and intrustive innodb events to report
to systemd status monitoring'
To extend the number of status messages available to innodb moved the
sd_notifyf into ib_logf. Suggested by Jan Lindstrom.
@janlindstrom
Copy link
Contributor

Please note that buf_dump_status does not use ib_logf currently, instead fprintf directly.

@grooverdan
Copy link
Member Author

@janlindstrom d0619cd too invasive? could boost it with asserts that enum status_severity enumberations match ib_log_level_t

handing missing /usr/bin/host executable
Default to *:ports if can't resolve bindaddress
Comment why we put and empty ListenStream= line
Only give "STATUS=No listening sockets" when there are no systemd
sockets activated and systemd sockets where provided.
result of set global innodb_buffer_pool_dump_now=ON;

before:

2015-03-15 16:46:34 7fba7effd700150315 16:46:34 [Warning] InnoDB:
Dumping buffer pool(s) to .//ib_buffer_pool
150315 16:46:34 [Note] InnoDB: Dumping buffer pool 1/1, page 1/154
150315 16:46:34 [Note] InnoDB: Dumping buffer pool 1/1, page 129/154
2015-03-15 16:46:34 7fba7effd700150315 16:46:34 [Warning] InnoDB: Buffer
pool(s) dump completed at 150315 16:46:34

after:

150315 16:57:45 [Warning] InnoDB: Dumping buffer pool(s) to
.//ib_buffer_pool
150315 16:57:45 [Note] InnoDB: Dumping buffer pool 1/1, page 1/154
150315 16:57:45 [Note] InnoDB: Dumping buffer pool 1/1, page 129/154
150315 16:57:45 [Warning] InnoDB: Buffer pool(s) dump completed at
150315 16:57:45
@grooverdan
Copy link
Member Author

Hi, Did you test the output,

no

why you did not remove ut_print_timestamp(stderr); ?

hadn't tested it.

Have tested now - cleaned up as per f7aad0b.

@ghost
Copy link

ghost commented Apr 28, 2015

The support-files/mariadb-systemd-start file should be removed as it is a security hazard. The init system should not automatically create the database. This should be left up to the machine's administrator. As the mysql_install_db script opens a password-less root user, this is unsafe. https://bugs.gentoo.org/show_bug.cgi?id=483526 shows a discussion from Gentoo's change of manual systemd integration by our distro.

@grooverdan
Copy link
Member Author

@grknight , thanks so much for looking a this. I've looked at at the gentoo scripts/service files. I quite like the idea of the mysqld_at service and will probably incorporate its concepts into whatever is accepted as the single instance version.

Is a passwordless root the only concern? Its a good point. As an alternative I'm thinking about having unix_socket plugin installed by default and root@localhost via unix_socket as the default grant, passwordless yes, but can only be accessed via the unix root user. Its the way the current debian/ubuntu packages are (though it seems to have some packaging problems - might be my error there).

With socket activation (main benefit I see is more flexible network configuration, easy early runtime dependencies, and systemd restart on process dying), is mariadb-socket-convert sufficient? Should I be trying to script the migration of less used mysqld_safe options to their equivalent (as per mariadb.service)?

@ghost
Copy link

ghost commented May 21, 2015

On 4/29/2015 2:19 AM, Daniel Black wrote:

@grknight https://github.com/grknight , thanks so much for looking a
this. I've looked at at the gentoo scripts/service files. I quite like
the idea of the mysqld_at service and will probably incorporate its
concepts into whatever is accepted as the single instance version.

Is a passwordless root the only concern? Its a good point. As an
alternative I'm thinking about having unix_socket plugin installed by
default and root@localhost via unix_socket as the default grant,
passwordless yes, but can only be accessed via the unix root user. Its
the way the current debian/ubuntu packages are (though it seems to have
some packaging problems - might be my error there).

Yes that is a concern. unix_socket also can cause a confusion of users
who are used to 'mysql -u root -p' from another user as it will fail
when using unix_socket. This is because the auth plugin system does not
fall back to stored passwords.

With socket activation (main benefit I see is more flexible network
configuration, easy early runtime dependencies, and systemd restart on
process dying), is mariadb-socket-convert sufficient? Should I be trying
to script the migration of less used mysqld_safe options to their
equivalent (as per mariadb.service)?

Systemd's Socket activation is not right for MariaDB IMO.
Think about recovery from a crash, be it system (environment or other)
or segfault. Pending database calls would be waiting or even timeout
unnecessarily since we cannot guarantee near-instant start up and action.

I know that XtraDB/InnoDB can be faster in recent times to recover, but
may not always be on larger systems or if the recovery fails.

Also, socket activation + full SST with galera may not be pretty since
it depends on network transfers.

@grooverdan
Copy link
Member Author

On 22 May 2015 at 00:46, Brian Evans [email protected] wrote:

On 4/29/2015 2:19 AM, Daniel Black wrote:

@grknight https://github.com/grknight , thanks so much for looking a
this. I've looked at at the gentoo scripts/service files. I quite like
the idea of the mysqld_at service and will probably incorporate its
concepts into whatever is accepted as the single instance version.

Is a passwordless root the only concern?....

Yes that is a concern. unix_socket also can cause a confusion of users

This is getting off topic for this PR.

With socket activation (main benefit I see is more flexible network
configuration, easy early runtime dependencies, and systemd restart on
process dying), is mariadb-socket-convert sufficient? Should I be trying
to script the migration of less used mysqld_safe options to their
equivalent (as per mariadb.service)?

Systemd's Socket activation is not right for MariaDB IMO.
Think about recovery from a crash, be it system (environment or other)
or segfault. Pending database calls would be waiting or even timeout
unnecessarily since we cannot guarantee near-instant start up and action.

You may be misunderstand the role that systemd socket activation plays. I
passes the Listening socket FD only to the mysqld process and lets mysqld
to all the accepts.
Because happens, its the same impact with or without socket activation. A
slow start up may have a listening socket there slightly earlier however
there is acceptance until mysqld is ready. While smaller foot print
services use socket activation to trigger the start of a service on connect
I don't expect this to be used with MariaDB. Hence the mariadb.service
definition that contains After=network.target, After=syslog.target. If you
still don't like socket activation, use type=notify. Its here too.

I know that XtraDB/InnoDB can be faster in recent times to recover, but
may not always be on larger systems or if the recovery fails.

Believe me I know, I work on some fairly large systems.

Also, socket activation + full SST with galera may not be pretty since

it depends on network transfers.

As noted in the MDEVs there is more work to do with galera. Its not too
much, just need to map a socket to a config var. Given this patch has
waited over 5 months with only some mediocure review on small parts of the
patch I'm not going to rush to complete the galera component right now.

configure.cmake Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer three-value option, YES/NO/AUTO, with AUTO being the default.

@grooverdan
Copy link
Member Author

Did the clean ups.

10.0 work stalled at the thought of including systemd notify_* function into mariadb. Will need to purge out the socket activation and enhance mariadb-service-convert to port port/socket options too

attempted to create a 10.1 merge however it seemed to encompase everything from 10.0 that hasn't yet been merged to 10.1 https://github.com/MariaDB/server/compare/10.1...openquery:MDEV-5536-systemd-socket-activation-notification-10.1?expand=1

Where do you met to go from here?

@davidstrauss
Copy link

I'd like to leave the code there so distros can move to socket activation if they want and leave the systemd scripts as Type=Notify until 10.1(?) ?

I'm a bit confused at this comment. I don't see why you would stop running the service as Type=notify even if you do use socket activation.

@grooverdan
Copy link
Member Author

I'm a bit confused at this comment. I don't see why you would stop running the service as Type=notify even if you do use socket activation.

Quite right. I though from the comments in on of the MDEV it was ignored when socket activation was used but yes I will keep it the same.

I can't add a dependency on libsystemd-daemon0 in a stable branch, even if compile time configurable(?),

So at the moment I've got to rebase/merge this for 10.1 and/or remove socket activation and include the sd_notify calls from libsystemd-daemon0 in 10.0. And a bit more testing just to be sure - especially on packaging changes.

@vuvova
Copy link
Member

vuvova commented Jul 24, 2015

I'm sorry, but I don't quite understand the state of this PR. You've created #83 for 10.1, fine. Is this one still for 10.0? Or is it obsolete and should be closed?

@grooverdan
Copy link
Member Author

grooverdan commented Jul 24, 2015 via email

@grooverdan grooverdan closed this Jul 24, 2015
ankitkumar031 pushed a commit to ankitkumar031/server that referenced this pull request Apr 16, 2017
Issue 25: Different functions for Treeherder prod and stage
holyfoot pushed a commit that referenced this pull request May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants