logrotate returns an error if mysql service is disabled

Bug #2120936 reported by Ghadi Rahme
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mysql-8.0 (Ubuntu)
New
Undecided
Unassigned
Jammy
Fix Released
Undecided
Ghadi Rahme
Noble
Fix Released
Undecided
Ghadi Rahme
mysql-8.4 (Ubuntu)
Fix Released
Undecided
Ghadi Rahme
Plucky
Fix Released
Undecided
Ghadi Rahme
Questing
Fix Released
Undecided
Ghadi Rahme

Bug Description

[Description]

After the MR part of this bug report: https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1850980

logrotate returns an error when running the mysql log rotation script if the mysql service is disabled.

It is expected of logrotate not to return an error if the service is disabled since a disabled service will not generate logs to rotate anyways.
I have written a fix that checks first the status of the mysql service before running the rest of the log rotate script.

[Test Plan]

Run the following commands, and verify the output of logrotate:

$ sudo apt install mysql-server

$ sudo systemctl stop mysql.service

$ sudo logrotate -f /etc/logrotate.conf

If no error is returned by logrotate it means the fix was successful, else the following error is shown:

error: error running shared postrotate script for '/var/log/mysql.log /var/log/mysql/*log '

[Where problems could occur]

Since the changes is related to logs, possible issues may be that the script falsely detects that the mysql service is disabled and not rotate the logs.
Any problems resulting from this patch are expected to only be limited to log rotation.

no longer affects: mysql-8.4 (Ubuntu Jammy)
no longer affects: mysql-8.4 (Ubuntu Noble)
no longer affects: mysql-8.0 (Ubuntu Plucky)
no longer affects: mysql-8.0 (Ubuntu Questing)
Changed in mysql-8.0 (Ubuntu Jammy):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Changed in mysql-8.0 (Ubuntu Noble):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Changed in mysql-8.4 (Ubuntu Plucky):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Changed in mysql-8.4 (Ubuntu Questing):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

questing debdiff

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

plucky debdiff

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

noble debdiff

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

jammy debdiff

Revision history for this message
Lena Voytek (lvoytek) wrote :

Thanks for the debdiffs! Sponsoring for all releases

Revision history for this message
Lena Voytek (lvoytek) wrote :

Done, as a note plucky needed to be rebased onto my latest update and jammy debdiff had the wrong series. Fixed both of those and sponsored

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mysql-8.4 - 8.4.6-0ubuntu3

---------------
mysql-8.4 (8.4.6-0ubuntu3) questing; urgency=medium

  * Modify logrotate script to silently exit if mysql service is not active
    (LP: #2120936).

 -- Ghadi Elie Rahme <email address hidden> Tue, 19 Aug 2025 16:39:09 +0000

Changed in mysql-8.4 (Ubuntu Questing):
status: New → Fix Released
Revision history for this message
Andreas Hasenack (ahasenack) wrote : Please test proposed package

Hello Ghadi, or anyone else affected,

Accepted mysql-8.4 into plucky-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/mysql-8.4/8.4.6-0ubuntu0.25.04.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-plucky to verification-done-plucky. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-plucky. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in mysql-8.4 (Ubuntu Plucky):
status: New → Fix Committed
tags: added: verification-needed verification-needed-plucky
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (mysql-8.4/8.4.6-0ubuntu0.25.04.3)

All autopkgtests for the newly accepted mysql-8.4 (8.4.6-0ubuntu0.25.04.3) for plucky have finished running.
The following regressions have been reported in tests triggered by the package:

isc-kea/2.6.1-1 (amd64, ppc64el)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/plucky/update_excuses.html#mysql-8.4

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

Error is related to the kea-ctrl-agent which is unrelated to the changes this SRU did. The issue comes from the fact that the kea-ctrl-agent service was still running when it should have stopped.

```
114s ## With no /etc/kea/kea-api-password, the service must not be running
114s ● kea-ctrl-agent.service - Kea Control Agent
114s Loaded: loaded (/usr/lib/systemd/system/kea-ctrl-agent.service; enabled; preset: enabled)
114s Drop-In: /run/systemd/system/kea-ctrl-agent.service.d
114s └─override.conf
114s Active: activating (auto-restart) (Result: exit-code) since Fri 2025-08-29 07:05:18 UTC; 18ms ago
114s Invocation: 24bf873094854112b9d13de43d9f4a59
114s Docs: man:kea-ctrl-agent(8)
114s Process: 2368 ExecStart=/usr/sbin/kea-ctrl-agent -c /etc/kea/kea-ctrl-agent.conf (code=exited, status=1/FAILURE)
114s Main PID: 2368 (code=exited, status=1/FAILURE)
114s Mem peak: 2M
114s CPU: 11ms
114s ## ERROR, service is activating
115s autopkgtest [07:05:19]: test kea-ctrl-agent-debconf: -----------------------]
115s kea-ctrl-agent-debconf FAIL non-zero exit status 1
```

Is it possible to restart the test to make sure this is not a one off error?

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

Plucky verification:

root@build-plucky:~# apt list mysql-server --installed
mysql-server/plucky-proposed,now 8.4.6-0ubuntu0.25.04.3 amd64 [installed]
Notice: There are 3 additional versions. Please use the '-a' switch to see them.

root@build-plucky:~# systemctl stop mysql.service

root@build-plucky:~# systemctl status mysql.service
○ mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: inactive (dead) since Fri 2025-08-29 14:52:10 UTC; 9s ago
   Duration: 1min 15.221s
 Invocation: 69a539abf7d14241af7b5beccede5f23
    Process: 26881 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 26891 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
   Main PID: 26891 (code=exited, status=0/SUCCESS)
     Status: "Server shutdown complete (with return value = 0)"
   Mem peak: 437.5M
        CPU: 1.091s

Aug 29 14:50:52 build-plucky systemd[1]: Starting mysql.service - MySQL Community Server...
Aug 29 14:50:54 build-plucky systemd[1]: Started mysql.service - MySQL Community Server.
Aug 29 14:52:09 build-plucky systemd[1]: Stopping mysql.service - MySQL Community Server...
Aug 29 14:52:10 build-plucky systemd[1]: mysql.service: Deactivated successfully.
Aug 29 14:52:10 build-plucky systemd[1]: Stopped mysql.service - MySQL Community Server.
Aug 29 14:52:10 build-plucky systemd[1]: mysql.service: Consumed 1.091s CPU time, 437.5M memory peak.

root@build-plucky:~# sudo logrotate -f /etc/logrotate.conf

root@build-plucky:~# echo $?
0

This confirms that plucky is working as expected after this patch!

tags: added: verification-done-plucky
removed: verification-needed-plucky
Revision history for this message
Julian Andres Klode (juliank) wrote : Please test proposed package

Hello Ghadi, or anyone else affected,

Accepted mysql-8.0 into noble-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/mysql-8.0/8.0.43-0ubuntu0.24.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-noble to verification-done-noble. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-noble. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in mysql-8.0 (Ubuntu Noble):
status: New → Fix Committed
tags: added: verification-needed-noble
Changed in mysql-8.0 (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed-jammy
Revision history for this message
Julian Andres Klode (juliank) wrote :

Hello Ghadi, or anyone else affected,

Accepted mysql-8.0 into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/mysql-8.0/8.0.43-0ubuntu0.22.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (mysql-8.0/8.0.43-0ubuntu0.22.04.2)

All autopkgtests for the newly accepted mysql-8.0 (8.0.43-0ubuntu0.22.04.2) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

libreoffice/1:7.3.7-0ubuntu0.22.04.10 (ppc64el)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#mysql-8.0

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (mysql-8.0/8.0.43-0ubuntu0.24.04.2)

All autopkgtests for the newly accepted mysql-8.0 (8.0.43-0ubuntu0.24.04.2) for noble have finished running.
The following regressions have been reported in tests triggered by the package:

exim4/4.97-4ubuntu4.3 (ppc64el)
watcher/2:12.0.0-0ubuntu1 (armhf)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/noble/update_excuses.html#mysql-8.0

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

Autopkgtests failure for libreoffice on jammy are unrelated to mysql and are an issue with the builder:

```
2940s Processing triggers for libc-bin (2.35-0ubuntu3.10) ...
4282s autopkgtest-virt-ssh [21:22:08]: copydown destination failed, status 255
4286s autopkgtest-virt-ssh [21:22:12]: ------- nova console-log 41dfa0ec-7aa0-4dfe-8654-add7143763fd (adt-jammy-ppc64el-libreoffice-20250902-163202-juju-7f2275-prod-proposed-migration-environment-20-2e8f6896-4f18-40da-bbe8-2dda8a08f0d6) ------
4286s ERROR (CommandError): No server with a name or ID of '41dfa0ec-7aa0-4dfe-8654-add7143763fd' exists.
4286s ---------------------------------------------------
4286s ------- nova show 41dfa0ec-7aa0-4dfe-8654-add7143763fd (adt-jammy-ppc64el-libreoffice-20250902-163202-juju-7f2275-prod-proposed-migration-environment-20-2e8f6896-4f18-40da-bbe8-2dda8a08f0d6) ------
4286s ERROR (CommandError): No server with a name or ID of '41dfa0ec-7aa0-4dfe-8654-add7143763fd' exists.
4286s ---------------------------------------------------
4286s
6911s autopkgtest [22:05:57]: ERROR: testbed failure: sent `auxverb_debug_fail', got `copy-failed', expected `ok...'
```

Failures on noble are also unrelated to the patch.

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote (last edit ):

noble verification:

root@noble-logrotate:~# apt list mysql-server --installed
Listing... Done
mysql-server/noble-proposed,now 8.0.43-0ubuntu0.24.04.2 all [installed]
N: There are 2 additional versions. Please use the '-a' switch to see them.

root@noble-logrotate:~# systemctl stop mysql.service

root@noble-logrotate:~# systemctl status mysql.service
○ mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: inactive (dead) since Tue 2025-09-09 07:38:33 UTC; 7s ago
   Duration: 2d 7h 7min 8.709s
    Process: 226363 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 226386 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
   Main PID: 226386 (code=exited, status=0/SUCCESS)
     Status: "Server shutdown complete"
        CPU: 3min 50.252s

Sep 07 00:31:21 noble-logrotate systemd[1]: Starting mysql.service - MySQL Community Server...
Sep 07 00:31:22 noble-logrotate systemd[1]: Started mysql.service - MySQL Community Server.
Sep 09 07:38:31 noble-logrotate systemd[1]: Stopping mysql.service - MySQL Community Server...
Sep 09 07:38:33 noble-logrotate systemd[1]: mysql.service: Deactivated successfully.
Sep 09 07:38:33 noble-logrotate systemd[1]: Stopped mysql.service - MySQL Community Server.
Sep 09 07:38:33 noble-logrotate systemd[1]: mysql.service: Consumed 3min 50.252s CPU time.

root@noble-logrotate:~# sudo logrotate -f /etc/logrotate.conf

root@noble-logrotate:~# echo $?
0

This confirms that noble is working as expected after this patch!

tags: added: verification-done-noble
removed: verification-needed-noble
Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

jammy verification:

root@build-jammy:~# apt list --installed mysql-server
Listing... Done
mysql-server/jammy-proposed,now 8.0.43-0ubuntu0.22.04.2 all [installed]
N: There are 2 additional versions. Please use the '-a' switch to see them.

root@build-jammy:~# systemctl stop mysql.service

root@build-jammy:~# systemctl status mysql.service
○ mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Tue 2025-09-09 07:43:27 UTC; 4s ago
    Process: 39781 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 39789 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
   Main PID: 39789 (code=exited, status=0/SUCCESS)
     Status: "Server shutdown complete"
        CPU: 1.343s

Sep 09 07:42:14 build-jammy systemd[1]: Starting MySQL Community Server...
Sep 09 07:42:16 build-jammy systemd[1]: Started MySQL Community Server.
Sep 09 07:43:26 build-jammy systemd[1]: Stopping MySQL Community Server...
Sep 09 07:43:27 build-jammy systemd[1]: mysql.service: Deactivated successfully.
Sep 09 07:43:27 build-jammy systemd[1]: Stopped MySQL Community Server.
Sep 09 07:43:27 build-jammy systemd[1]: mysql.service: Consumed 1.343s CPU time.

root@build-jammy:~# sudo logrotate -f /etc/logrotate.conf

root@build-jammy:~# echo $?
0

This confirms that jammy is working as expected after this patch!

tags: added: verification-done-jammy
removed: verification-needed-jammy
Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

autopkgtests on Noble are not related to the patch:

For exim4 the issue is TLS related:

 96s *** TLS startup failed (connect(): error:0A000438:SSL routines::tlsv1 alert internal error)
 96s *** STARTTLS attempted but failed
 97s *** Remote host closed connection unexpectedly.

For watcher it seems it timed out:

10433s autopkgtest [15:15:02]: test autodep8-python3: [-----------------------
10435s Testing with python3.12:
10435s <module 'watcher' from '/usr/lib/python3/dist-packages/watcher/__init__.py'>
10435s autopkgtest [15:15:04]: test autodep8-python3: -----------------------]
10439s autodep8-python3 PASS (superficial)
10439s autopkgtest [15:15:08]: test autodep8-python3: - - - - - - - - - - results - - - - - - - - - -
10442s autopkgtest [15:15:11]: @@@@@@@@@@@@@@@@@@@@ summary
10442s watcher-daemons FAIL timed out
10442s autodep8-python3 PASS (superficial)

Would it be possible to restart these tests?

Revision history for this message
Lukas Märdian (slyon) wrote :

I re-triggered the failed autopkgtests on Noble and Jammy:

exim4/4.97-4ubuntu4.3 (ppc64el)
watcher/2:12.0.0-0ubuntu1 (armhf)

libreoffice/1:7.3.7-0ubuntu0.22.04.10 (ppc64el)

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mysql-8.4 - 8.4.6-0ubuntu0.25.04.3

---------------
mysql-8.4 (8.4.6-0ubuntu0.25.04.3) plucky; urgency=medium

  * Modify logrotate script to silently exit if mysql service is not active
    (LP: #2120936).

 -- Ghadi Elie Rahme <email address hidden> Tue, 19 Aug 2025 16:39:09 +0000

Changed in mysql-8.4 (Ubuntu Plucky):
status: Fix Committed → Fix Released
Revision history for this message
Nick Rosbrook (enr0n) wrote : Update Released

The verification of the Stable Release Update for mysql-8.4 has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Julian Andres Klode (juliank) wrote (last edit ):

I have retried the build failures for mysql-8.0 on jammy and focal. They failed with no logs after the upload was processed, probably due to infrastructure issues.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mysql-8.0 - 8.0.43-0ubuntu0.24.04.2

---------------
mysql-8.0 (8.0.43-0ubuntu0.24.04.2) noble; urgency=medium

  * Modify logrotate script to silently exit if mysql service is not active
    (LP: #2120936).

 -- Ghadi Elie Rahme <email address hidden> Tue, 19 Aug 2025 14:30:45 +0000

Changed in mysql-8.0 (Ubuntu Noble):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mysql-8.0 - 8.0.43-0ubuntu0.22.04.2

---------------
mysql-8.0 (8.0.43-0ubuntu0.22.04.2) jammy; urgency=medium

  * Modify logrotate script to silently exit if mysql service is not active
    (LP: #2120936).

 -- Ghadi Elie Rahme <email address hidden> Tue, 19 Aug 2025 15:25:22 +0000

Changed in mysql-8.0 (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Simon Chopin (schopin) wrote :

AIUI there is no need for sponsorship anymore here, unsubscribing.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.