Merge ~kstenerud/ubuntu/+source/mysql-5.7:cosmic-mysql-frozen-1799763 into ubuntu/+source/mysql-5.7:ubuntu/cosmic-devel

Proposed by Karl Stenerud
Status: Merged
Merge reported by: Robie Basak
Merged at revision: c6a8d94e1bd2334eef88faa32d28de4992a6e918
Proposed branch: ~kstenerud/ubuntu/+source/mysql-5.7:cosmic-mysql-frozen-1799763
Merge into: ubuntu/+source/mysql-5.7:ubuntu/cosmic-devel
Diff against target: 82 lines (+25/-5)
4 files modified
debian/additions/mysql-systemd-start (+4/-0)
debian/changelog (+11/-0)
debian/mysql-server-5.7.postinst (+3/-2)
debian/mysql-server-5.7.preinst (+7/-3)
Reviewer Review Type Date Requested Status
Robie Basak Approve
Canonical Server Pending
Review via email: mp+358234@code.launchpad.net

Description of the change

This patch fixes frozen state handling in MySQL:

- Do not proceed in preinst if already in frozen state to prevent daemon
  stop if it had been started manually.
- Log to syslog via logger to increase visibility of the problem.
- Prevent systemd service start when in frozen state.

PPA: ppa:kstenerud/cosmic-mysql-frozen-1799763

Steps to test:

# lxc launch ubuntu:cosmic tester
# lxc exec tester bash
# apt update
# apt dist-upgrade -y
# apt install -y mysql-server
# apt remove -y mysql-server
# apt install -y mariadb-server
# apt remove -y mariadb-server
# apt install -y mysql-server

Pop up window:
 Automatic maintenance of MySQL server daemon disabled

 Packaging maintainer scripts detected a case that it does not know how to handle and cannot continue configuring MySQL. Automatic management of your MySQL installation has been disabled to allow other packaging tasks to complete. For more details, see /etc/mysql/FROZEN.

Console:

 Packaging maintenance of MySQL will stop and the daemon disabled to prevent damage to your system.
 For help, see /etc/mysql/FROZEN

# journalctl -xe
(nothing in the journal)
#service mysql start
(starts successfully when it should error out)

---------------------------------

# lxc launch ubuntu:cosmic tester-fix
# lxc exec tester-fix bash
# add-apt-repository -y ppa:kstenerud/cosmic-mysql-frozen-1799763
# apt update
# apt dist-upgrade -y
# apt install -y mysql-server
# apt remove -y mysql-server
# apt install -y mariadb-server
# apt remove -y mariadb-server
# apt install -y mysql-server

Pop up window:
 Automatic maintenance of MySQL server daemon disabled

 Packaging maintainer scripts detected a case that it does not know how to handle and cannot continue configuring MySQL. Automatic management of your MySQL installation has been disabled to allow other packaging tasks to complete. For more details, see /etc/mysql/FROZEN.

Console:
 MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help.

# journalctl -xe
Nov 02 10:36:28 tester /etc/init.d/mysql[3598]: MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help.
# service mysql start
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
# journalctl -xe
Nov 02 10:37:31 tester mysql-systemd-start[3694]: MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help.
Nov 02 10:37:31 tester systemd[1]: mysql.service: Control process exited, code=exited status=1
Nov 02 10:37:31 tester systemd[1]: mysql.service: Failed with result 'exit-code'.
Nov 02 10:37:31 tester systemd[1]: Failed to start MySQL Community Server.

Package Tests:

autopkgtest [14:42:05]: test upstream: -----------------------]
autopkgtest [14:42:05]: test upstream: - - - - - - - - - - results - - - - - - - - - -
upstream PASS
autopkgtest [14:42:06]: @@@@@@@@@@@@@@@@@@@@ summary
smoke PASS
upstream PASS

To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote :

Looks good, thanks!

This is fine to upload to Ubuntu, but it will save future work if we could land it in VCS on Salsa directly. Did you get anywhere with getting a merge request filed there please?

review: Approve
db7d7f5... by Karl Stenerud

  * d/mysql-server-5.7.{pre,post}inst, d/additions/mysql-systemd-start: improve
    frozen state handling (LP: #1799763):
    - Do not proceed in preinst if already in frozen state to prevent daemon
      stop if it had been started manually.
    - Log to syslog via logger to increase visibility of the problem.
    - Prevent systemd service start when in frozen state.

c6a8d94... by Karl Stenerud

changelog

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

What are we waiting for here, an upload to cosmic?

Revision history for this message
Robie Basak (racb) wrote :

I need to merge in Salsa, upload to unstable, and then sync to Ubuntu.

Revision history for this message
Robie Basak (racb) wrote :

This is now in disco-proposed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/additions/mysql-systemd-start b/debian/additions/mysql-systemd-start
2index 946efb5..7178f1a 100755
3--- a/debian/additions/mysql-systemd-start
4+++ b/debian/additions/mysql-systemd-start
5@@ -20,6 +20,10 @@ get_mysql_option() {
6 echo "$result"
7 }
8 sanity () {
9+ if [ -e /etc/mysql/FROZEN -o -h /etc/mysql/FROZEN ]; then
10+ echo "MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help."
11+ exit 1
12+ fi
13 if [ ! -r /etc/mysql/my.cnf ]; then
14 echo "MySQL configuration not found at /etc/mysql/my.cnf. Please create one."
15 exit 1
16diff --git a/debian/changelog b/debian/changelog
17index 90df71f..9618212 100644
18--- a/debian/changelog
19+++ b/debian/changelog
20@@ -1,3 +1,14 @@
21+mysql-5.7 (5.7.24-0ubuntu0.18.10.2) cosmic; urgency=medium
22+
23+ * d/mysql-server-5.7.{pre,post}inst, d/additions/mysql-systemd-start: improve
24+ frozen state handling (LP: #1799763):
25+ - Do not proceed in preinst if already in frozen state to prevent daemon
26+ stop if it had been started manually.
27+ - Log to syslog via logger to increase visibility of the problem.
28+ - Prevent systemd service start when in frozen state.
29+
30+ -- Karl Stenerud <karl.stenerud@canonical.com> Thu, 01 Nov 2018 17:20:06 +0100
31+
32 mysql-5.7 (5.7.24-0ubuntu0.18.10.1) cosmic-security; urgency=medium
33
34 * SECURITY UPDATE: Update to 5.7.24 to fix security issues
35diff --git a/debian/mysql-server-5.7.postinst b/debian/mysql-server-5.7.postinst
36index d4be88d..a3323db 100755
37--- a/debian/mysql-server-5.7.postinst
38+++ b/debian/mysql-server-5.7.postinst
39@@ -150,11 +150,12 @@ case "$1" in
40 # remains active for a long period.
41
42 if [ -e /etc/mysql/FROZEN -o -h /etc/mysql/FROZEN ]; then
43+ error_message="MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help."
44+ logger -p daemon.err -t /etc/init.d/mysql -i "$error_message"
45 db_input critical mysql-server-$this_version/installation_freeze_mode_active || true
46 db_go
47 db_stop
48- echo "Packaging maintenance of MySQL will stop and the daemon disabled to prevent damage to your system." 1>&2
49- echo "For help, see /etc/mysql/FROZEN" 1>&2
50+ echo "$error_message" 1>&2
51 exit 0
52 fi
53
54diff --git a/debian/mysql-server-5.7.preinst b/debian/mysql-server-5.7.preinst
55index e3891e4..6793167 100755
56--- a/debian/mysql-server-5.7.preinst
57+++ b/debian/mysql-server-5.7.preinst
58@@ -87,18 +87,22 @@ for i in `ls $DATADIR/debian-*.flag 2>/dev/null`; do
59 fi
60 done
61 if [ "$is_downgrade_attempt" = 1 ]; then
62+ echo "Downgrade from (at least) $found_version to $this_version is not possible." 1>&2
63 if [ -e /etc/mysql/FROZEN -o -h /etc/mysql/FROZEN ]; then
64 echo "Warning: /etc/mysql/FROZEN already exists" >&2
65 else
66 ln -s ../../usr/share/doc/mysql-common/frozen-mode/downgrade /etc/mysql/FROZEN
67 fi
68+fi
69+
70+if [ -e /etc/mysql/FROZEN -o -h /etc/mysql/FROZEN ]; then
71+ error_message="MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help."
72+ logger -p daemon.err -t /etc/init.d/mysql -i "$error_message"
73 db_fset mysql-server-$this_version/installation_freeze_mode_active seen false || true
74 db_input critical mysql-server-$this_version/installation_freeze_mode_active || true
75 db_go
76 db_stop
77- echo "Downgrade from (at least) $found_version to $this_version is not possible." 1>&2
78- echo "Packaging maintenance of MySQL will stop and the daemon disabled to prevent damage to your system." 1>&2
79- echo "For help, see /etc/mysql/FROZEN" 1>&2
80+ echo "$error_message" 1>&2
81 exit 0
82 fi
83

Subscribers

People subscribed via source and target branches