Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
02b6457
Add base SYSTEMD library to cmake
grooverdan Mar 11, 2015
63d2b93
extend psi adding mysql_socket_fd function
grooverdan Mar 11, 2015
ebb3153
MDEV-5536 add systemd socket activation
grooverdan Mar 11, 2015
3c9c925
systemd notification messages for innodb status
grooverdan Mar 11, 2015
04f52db
whitespace fix
grooverdan Mar 11, 2015
2f140dc
whitespace extra
grooverdan Mar 12, 2015
8c607c2
Extend ib_logf to use that for sd_notifyf
grooverdan Mar 12, 2015
d0619cd
buf_dump_status to use ib_logf
grooverdan Mar 12, 2015
db1910a
cast enum status_severity to ib_log_level_t
grooverdan Mar 12, 2015
44d739c
mariadb-socket-convert script improvements
grooverdan Mar 12, 2015
eab0481
debian/ubuntu packaging of socket activation helpers
grooverdan Mar 12, 2015
24c5344
Fix for running mysqld not under socket activation but with systemd
grooverdan Mar 15, 2015
f7aad0b
remove additional timestamp from buf_dump_status
grooverdan Mar 15, 2015
39549e8
merge 10.0 deps in deb/ubuntu control file
grooverdan Jun 20, 2015
bdb1870
consolidate cmake defs for systemd
grooverdan Jun 20, 2015
a73d3e2
added postinst for systemd service/socket for mysql
grooverdan Jun 20, 2015
58e4690
typo in mysql_socket_fd docstring
grooverdan Jun 20, 2015
b481e4f
WITH_SYSTEMD cmake option - correct tristate value
grooverdan Jun 20, 2015
9ab56fa
systemd-daemon linking in sql/CMakeLists.txt not required
grooverdan Jun 20, 2015
91b0bc8
add #define for sd_listen_fds. Support use of extra_port with socket …
grooverdan Jun 20, 2015
85b9e87
reduce #if{n,}def on HAVE_SYSTEMD
grooverdan Jun 20, 2015
246362e
add abstraction for sd_notify{f,}. Remove info/warn innodb messages f…
grooverdan Jun 20, 2015
615c804
simplification in mariadb-socket-convert
grooverdan Jun 20, 2015
b499e19
more md_sdnotify consistenty
grooverdan Jun 20, 2015
2bfe611
mariadb-socket-convert - warnings for DNS based conversion and defaults
grooverdan Jun 21, 2015
4e351f1
mariadb-socket-convert - grab default port/socket from mysqld --verbo…
grooverdan Jun 21, 2015
af012a5
correct/document mariadb.service
grooverdan Jun 21, 2015
e65f3d6
created mariadb-service-convert for systemd migration. added --simula…
grooverdan Jun 21, 2015
2a2c21b
remove accidely commited extra/comp_err.c CR/LF hack
grooverdan Jun 21, 2015
9b2a1a1
dont automaticly ExecStartPre=/usr/bin/mariadb-systemd-start (db inst…
grooverdan Jun 21, 2015
b7c1c8b
just use /usr/bin/mysql_install_db to create database.
grooverdan Jun 21, 2015
1466c20
remove WorkingDir from mariadb.service
grooverdan Jun 21, 2015
9fb0b91
doc mariadb@.service before i forget
grooverdan Jun 21, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
#cmakedefine HAVE_LIBCRYPT 1
#cmakedefine HAVE_LIBMTMALLOC 1
#cmakedefine HAVE_LIBWRAP 1
#cmakedefine HAVE_SYSTEMD 1
/* Does "struct timespec" have a "sec" and "nsec" field? */
#cmakedefine HAVE_TIMESPEC_TS_SEC 1

Expand Down
27 changes: 27 additions & 0 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,33 @@ IF(UNIX)
SET(LIBWRAP "wrap")
ENDIF()
ENDIF()

SET(WITH_SYSTEMD "auto" CACHE STRING "Compile with systemd notification on ready")
IF(NOT ${WITH_SYSTEMD} MATCHES "[Nn][Oo]")
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} systemd-daemon)
CHECK_C_SOURCE_COMPILES(
"
#include <systemd/sd-daemon.h>
int main()
{
sd_listen_fds(0);
}"
HAVE_SYSTEMD)
CHECK_INCLUDE_FILES (systemd/sd-daemon.h HAVE_SYSTEMD_SD_DAEMON_H)
CHECK_FUNCTION_EXISTS (sd_listen_fds HAVE_SYSTEMD_SD_LISTEN_FDS)
CHECK_FUNCTION_EXISTS (sd_notify HAVE_SYSTEMD_SD_NOTIFY)
CHECK_FUNCTION_EXISTS (sd_notifyf HAVE_SYSTEMD_SD_NOTIFYF)
IF(HAVE_SYSTEMD AND HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS
AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF)
SET(LIBSYSTEMD "systemd-daemon")
MESSAGE(STATUS "Systemd features enabled")
ELSE()
MESSAGE(STATUS "Systemd features not enabled")
IF(${WITH_SYSTEMD} MATCHES "[Yy][Ee][Ss]")
MESSAGE(FATAL_ERROR "Requested WITH_SYSTEMD=YES however no dependencies installed/found")
ENDIF()
ENDIF()
ENDIF()
ENDIF()

#
Expand Down
5 changes: 3 additions & 2 deletions debian/dist/Debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Build-Depends: procps | hurd, debhelper, libncurses5-dev (>= 5.0-6),
zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV},
libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath,
dpatch, gawk, bison, lsb-release, hardening-wrapper,
${CMAKE_DEP}libaio-dev, libjemalloc-dev (>= 3.0.0)
${CMAKE_DEP}libaio-dev, libjemalloc-dev (>= 3.0.0),
libsystemd-daemon-dev, dh-systemd
Standards-Version: 3.8.3
Homepage: http://mariadb.org/
Vcs-Browser: http://bazaar.launchpad.net/~maria-captains/maria/10.0/files
Expand Down Expand Up @@ -161,7 +162,7 @@ Description: MariaDB database client binaries

Package: mariadb-server-core-10.0
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libmariadbclient18 (>= ${binary:Version})
Depends: ${shlibs:Depends}, ${misc:Depends}, libmariadbclient18 (>= ${binary:Version}), libsystemd-daemon0
Provides: mysql-server-core, mysql-server-core-5.1, mysql-server-core-5.5
Conflicts: mysql-server-5.0, mysql-server-core-5.0,
mariadb-server-core-5.1, mysql-server-core-5.1,
Expand Down
3 changes: 3 additions & 0 deletions debian/dist/Debian/mariadb-server-10.0.files.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ usr/bin/perror
usr/bin/replace
usr/bin/resolve_stack_dump
usr/bin/resolveip
usr/bin/mariadb-socket-convert
usr/bin/mariadb-system-convert
usr/bin/mariadb-systemd-start
usr/share/doc/mariadb-server-10.0/mysqld.sym.gz
usr/share/doc/mariadb-server-10.0/INFO_SRC
usr/share/doc/mariadb-server-10.0/INFO_BIN
Expand Down
13 changes: 13 additions & 0 deletions debian/dist/Debian/mariadb-server-10.0.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ if [ "$1" = "configure" ]; then
db_go
fi

# create a systemd socket activation file based on current settings
systemd_sockconf=/etc/systemd/system/mariadb.socket.d/migrated-from-my.cnf-settings.conf
if [ -x /usr/bin/mariadb-socket-convert -a ! -f "${systemd_sockconf}" ]; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd think that rpm scriptlets would need the same

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added to support-files/mysql.spec.sh

mkdir -p /etc/systemd/system/mariadb.socket.d
/usr/bin/mariadb-socket-convert > "${systemd_sockconf}"
fi
# copy out any mysqld_safe settings
systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
if [ -x /usr/bin/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
mkdir -p /etc/systemd/system/mariadb.service.d
/usr/bin/mariadb-service-convert > "${systemd_conf}"
fi

fi

db_stop # in case invoke failes
Expand Down
5 changes: 5 additions & 0 deletions debian/dist/Debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ install: build
install -m 0644 $(builddir)/Docs/INFO_SRC $(TMP)/usr/share/doc/mariadb-server-10.0/INFO_SRC
install -m 0644 $(builddir)/Docs/INFO_BIN $(TMP)/usr/share/doc/mariadb-server-10.0/INFO_BIN

# systemd helpers
install -m 0755 support-files/mariadb-systemd-start $(TMP)/usr/bin/

# mariadb-test
mv $(TMP)/usr/mysql-test $(TMP)/usr/share/mysql

Expand Down Expand Up @@ -216,7 +219,9 @@ binary-indep: build install
dh_installexamples -i
dh_installmenu -i
dh_installlogrotate -i
dh_systemd_enable -i support-files/mariadb.service support-files/mariadb.socket
dh_installinit -i
dh_systemd_start -i --restart-after-upgrade mariadb.socket

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this require systemd? dh_systemd_enable does not, according to its man page.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not sure. I'm assuming the abstraction is on the debian end. Just following the rules: https://wiki.debian.org/systemd/Packaging

dh_installcron -i
dh_installman -i
dh_installinfo -i
Expand Down
4 changes: 3 additions & 1 deletion debian/dist/Ubuntu/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Build-Depends: procps | hurd, debhelper, libncurses5-dev (>= 5.0-6),
zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV},
libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath,
dpatch, gawk, bison, lsb-release, hardening-wrapper,
${CMAKE_DEP}libaio-dev, libjemalloc-dev (>= 3.0.0)
${CMAKE_DEP}libaio-dev, libjemalloc-dev (>= 3.0.0),
libsystemd-daemon-dev, dh-systemd
Standards-Version: 3.8.2
Homepage: http://mariadb.org/
Vcs-Browser: http://bazaar.launchpad.net/~maria-captains/maria/10.0/files
Expand Down Expand Up @@ -162,6 +163,7 @@ Description: MariaDB database client binaries
Package: mariadb-server-core-10.0
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libmariadbclient18 (>= ${binary:Version})
libsystemd-daemon0
Provides: mysql-server-core, mysql-server-core-5.1, mysql-server-core-5.5
Conflicts: mysql-server-5.0, mysql-server-core-5.0,
mariadb-server-core-5.1, mysql-server-core-5.1,
Expand Down
3 changes: 3 additions & 0 deletions debian/dist/Ubuntu/mariadb-server-10.0.files.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ usr/bin/perror
usr/bin/replace
usr/bin/resolve_stack_dump
usr/bin/resolveip
usr/bin/mariadb-socket-convert
usr/bin/mariadb-system-convert
usr/bin/mariadb-systemd-start
usr/share/doc/mariadb-server-10.0/mysqld.sym.gz
usr/share/doc/mariadb-server-10.0/INFO_SRC
usr/share/doc/mariadb-server-10.0/INFO_BIN
Expand Down
12 changes: 12 additions & 0 deletions debian/dist/Ubuntu/mariadb-server-10.0.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ if [ "$1" = "configure" ]; then
db_go
fi

# create a systemd socket activation file based on current settings
systemd_sockconf=/etc/systemd/system/mariadb.socket.d/migrated-from-my.cnf-settings.conf
if [ -x /usr/bin/mariadb-socket-convert -a ! -f "${systemd_sockconf}" ]; then
mkdir -p /etc/systemd/system/mariadb.socket.d
/usr/bin/mariadb-socket-convert > "${systemd_sockconf}"
fi
# copy out any mysqld_safe settings
systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
if [ -x /usr/bin/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
mkdir -p /etc/systemd/system/mariadb.service.d
/usr/bin/mariadb-service-convert > "${systemd_conf}"
fi
fi

db_stop # in case invoke failes
Expand Down
5 changes: 5 additions & 0 deletions debian/dist/Ubuntu/rules
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ install: build
install -m 0644 $(builddir)/Docs/INFO_SRC $(TMP)/usr/share/doc/mariadb-server-10.0/INFO_SRC
install -m 0644 $(builddir)/Docs/INFO_BIN $(TMP)/usr/share/doc/mariadb-server-10.0/INFO_BIN

# systemd helpers
install -m 0755 support-files/mariadb-systemd-start $(TMP)/usr/bin/

# mariadb-test
mv $(TMP)/usr/mysql-test $(TMP)/usr/share/mysql

Expand Down Expand Up @@ -221,7 +224,9 @@ binary-indep: build install
dh_installexamples -i
dh_installmenu -i
dh_installlogrotate -i
dh_systemd_enable -i support-files/mariadb.service support-files/mariadb.socket
dh_installinit -i
dh_systemd_start -i --restart-after-upgrade mariadb.socket
dh_installcron -i
dh_installman -i
dh_installinfo -i
Expand Down
17 changes: 17 additions & 0 deletions include/my_sdnotify.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#ifndef _my_sdnotify_h
#define _my_sdnotify_h

#ifdef HAVE_SYSTEMD
#include <systemd/sd-daemon.h>

#else

#define sd_listen_fds(X) 0

#define sd_notify(X, Y, Z)
static int sd_notifyf(int unset_environment, const char *format, ...) {}

#endif

#endif /* _my_sdnotify_h */
38 changes: 38 additions & 0 deletions include/mysql/psi/mysql_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
}
#endif /* HAVE_PSI_SOCKET_INTERFACE */

/**
@def mysql_socket_fd(K, F)
Create a socket.
@c mysql_socket_fd is a replacement for @c socket.
@param K PSI_socket_key for this instrumented socket
@param F File descriptor
*/

#ifdef HAVE_PSI_SOCKET_INTERFACE
#define mysql_socket_fd(K, F) \
inline_mysql_socket_fd(K, F)
#else
#define mysql_socket_fd(K, F) \
inline_mysql_socket_fd(F)
#endif

/**
@def mysql_socket_socket(K, D, T, P)
Create a socket.
Expand Down Expand Up @@ -542,6 +558,28 @@ static inline void inline_mysql_socket_register(
}
#endif

/** mysql_socket_fd */

static inline MYSQL_SOCKET
inline_mysql_socket_fd
(
#ifdef HAVE_PSI_SOCKET_INTERFACE
PSI_socket_key key,
#endif
int fd)
{
MYSQL_SOCKET mysql_socket= MYSQL_INVALID_SOCKET;
mysql_socket.fd= fd;
#ifdef HAVE_PSI_SOCKET_INTERFACE
if (likely(mysql_socket.fd != INVALID_SOCKET))
{
mysql_socket.m_psi= PSI_SOCKET_CALL(init_socket)
(key, (const my_socket*)&mysql_socket.fd, NULL, 0);
}
#endif
return mysql_socket;
}

/** mysql_socket_socket */

static inline MYSQL_SOCKET
Expand Down
2 changes: 2 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ ELSE()
mysqldumpslow
mysqld_multi
mysqld_safe
mariadb-service-convert
mariadb-socket-convert
)
FOREACH(file ${BIN_SCRIPTS})
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
Expand Down
63 changes: 63 additions & 0 deletions scripts/mariadb-service-convert
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
#
# Used to generate a mariadb.service file based on the curent mysql/maridb settings
#
# This is to assist distro maintainers in migrating to systemd service definations from
# a user mysqld_safe settings in the my.cnf files.
#
# Redirect output to user directory like /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf

tz_old=$TZ

. /usr/bin/mysqld_safe --simulate

echo "# converted using $0"
echo "#"
echo

echo '[Service]'

echo


if [[ ( "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then
echo User=$user
fi


[ -n "${open_files}" ] && echo LimitNOFILE=$open_files
[ -n "${core_file_size}" ] && echo LimitCore=$core_file_size
[ "${niceness}" -gt 0 ] && echo Nice=$niceness
[ "${TZ}" != "${tz_old}" ] && echo Environment=\"TZ=${TZ}\"

if [ -n "$mysqld_ld_preload" ]; then
new_text="$mysqld_ld_preload"
[ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD"
echo Environment=\"LD_PRELOAD=`shell_quote_string "$new_text"`\"
fi

if [ -n "$mysqld_ld_library_path" ]; then
new_text="$mysqld_ld_library_path"
[ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH"
echo Environment=\"LD_LIBRARY_PATH=`shell_quote_string "$new_text"`\"
fi

if [ $want_syslog -eq 1 ]; then
echo StandardError=syslog
echo SyslogFacility=daemon
echo SyslogLevel=error
echo SyslogLevelPrefix=${syslog_tag_mysqld}
fi

if [ "${flush_caches}" -gt 0 ]; then
echo ExecStartPre=sync
echo ExecStartPre=sysctl -q -w vm.drop_caches=3
fi

if [ "${numa_interleave}" -gt 0 ]; then
echo
echo ExecStart=numactl --interleave=all ${cmd} '${OPTIONS}'
echo
fi

[ -n "${CRASH_SCRIPT}" ] && echo FailureAction=${CRASH_SCRIPT}
Loading