[MDEV-28640] dpkg: warning: old mariadb-server-10.6 package pre-removal script subprocess returned error exit status 1 Created: 2022-05-21  Updated: 2024-01-29

Status: In Testing
Project: MariaDB Server
Component/s: Server, Upgrades
Affects Version/s: 10.6, 10.7
Fix Version/s: 10.6

Type: Bug Priority: Minor
Reporter: Eric X Assignee: Otto Kekäläinen
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Debian 11.3 with sysvinit


Issue Links:
Duplicate
is duplicated by MDEV-27458 MariaDB 10.6.4 Installation error Closed

 Description   

When I try to upgrade my mariadb packages as part of a routine apt-get dist-upgrade or apt full-upgrade, it fails with the following messages:

dpkg: mariadb-client-10.6: dependency problems, but removing anyway as you requested: 
mariadb-server-10.6 depends on mariadb-client-10.6 (>= 1:10.6.7+maria~bullseye). 
mariadb-client depends on mariadb-client-10.6 (>= 1:10.6.8+maria~bullseye).
 
Removing mariadb-client-10.6 (1:10.6.7+maria~bullseye) ...
Setting up mysql-common (1:10.6.8+maria~bullseye) ...
Setting up mariadb-common (1:10.6.8+maria~bullseye) ...
Preparing to unpack .../00-mariadb-server-10.6_1%3a10.6.8+maria~bullseye_amd64.deb ...
Stopping MariaDB database server: mariadbd failed!
invoke-rc.d: initscript mariadb, action "stop" failed.
dpkg: warning: old mariadb-server-10.6 package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Stopping MariaDB database server: mariadbd failed!
invoke-rc.d: initscript mariadb, action "stop" failed.
dpkg: error processing archive /tmp/apt-dpkg-install-tGWUd2/00-mariadb-server-10.6_1%3a10.6.8+maria~bullseye_amd64.deb (  --unpack): 
new mariadb-server-10.6 package pre-removal script subprocess returned error exit status 1
Starting MariaDB database server: mariadbd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!
invoke-rc.d: initscript mariadb, action "start" failed.
dpkg: error while cleaning up: installed mariadb-server-10.6 package post-installation script subprocess returned error exit status 1

This can then be fixed with apt --fix-broken install, but it's a nuisance and causes enough downtime to have to take the server out of production to upgrade.

# apt-get -y dist-upgrade
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies: 
mariadb-client-10.6 : Breaks: mariadb-server-10.6 (< 1:10.6.8+maria~bullseye) but 1:10.6.7+maria~bullseye is installed 
mariadb-server : Depends: mariadb-server-10.6 (>= 1:10.6.8+maria~bullseye) but 1:10.6.7+maria~bullseye is installed 
mariadb-server-core-10.6 : Breaks: mariadb-server-10.6 (< 1:10.6.8+maria~bullseye) but 1:10.6.7+maria~bullseye is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I am using mariadb's repository.

deb [arch=amd64] https://ftp.osuosl.org/pub/mariadb/repo/10.6/debian bullseye main



 Comments   
Comment by Elena Stepanova [ 2022-05-21 ]

Thanks for the report.

Reproducible on 10.6 and 10.7, I didn't try 10.8 but it's probably the same.
Not reproducible on 10.5.

The problem appears to be specific to sysvinit.
As far as I can tell, the problem might be in a wrong sequence of events: first mariadb-client-10.x package gets removed, and then stop action in the init script attempts to use the removed mysqladmin to perform the operation.

Comment by Eric X [ 2022-05-22 ]

Thank you for addressing this promptly. Sorry about all the extra edits to make it readable.

Comment by Tuukka Pasanen [ 2022-05-22 ]

SysV init it's not obvious init system on Debian now-a-days. I have to see how to enable it that I can test this.

Comment by Eric X [ 2022-05-22 ]

Devuan uses it by default. It's easy to switch to on debian:

apt-get install --purge -y sysvinit-core

should do the trick.

You may also want to pin systemd's init system while running with sysvinit:

echo -e 'Package: systemd-sysv\nPin: release *\nPin-Priority: -1\n' > /etc/apt/preferences.d/systemd

I hope that helps.

Comment by Tuukka Pasanen [ 2022-05-23 ]

Thanks for clarification. Is this tested on Debian where SysV init is in use or Devuan? Just asking which enviroment I should use to test this.

Comment by Eric X [ 2022-05-23 ]

I imagine it would be the same either way, but I'm using Debian with sysvinit.

Comment by Tuukka Pasanen [ 2022-05-23 ]

Actually this is reproachable with systemd also.

Comment by Elena Stepanova [ 2022-05-23 ]

illuusio,

Actually this is reproachable with systemd also.

Do you have a log of such an occurrence?

Comment by Tuukka Pasanen [ 2022-05-23 ]

For example this Salsa-CI task when installing 10.6 MariaDB official tree over git-pulled tree builded with autobake.sh. At least it seems to be the same. It does not happen any other combination. It's just my testing build with OpenSSL 3.x backporting.

Comment by Elena Stepanova [ 2022-05-24 ]

At least it seems to be the same

Exactly the same, which is the problem. I don't know whether it's because of the build or because of the test being run in docker or something else, but your installation doesn't seem to be using systemd (which you apparently expect it to). For example this:

Stopping MariaDB database server: mariadbd.
Starting MariaDB database server: mariadbd.

It is the init script logging, isn't it?

Comment by Tuukka Pasanen [ 2022-05-27 ]

Yes are correct it's executed under Docker (I think) and there is no systemd available in that test as it's not mentioned in YAML. It happens when new version is installed over MariaDB 10.6 official build.

Comment by Tuukka Pasanen [ 2022-05-30 ]

Strange I can't get same behaviour with Docker locally than it's making on Salsa-CI. I give up and install Devuan to make sure that my env is correct.

Comment by Tuukka Pasanen [ 2022-08-30 ]

herrnoel do you have capability to test current MariaDB 10.6 git? MDEV-29321 is fixed and I think it's related to this but it didn't get into latest release in time.

Comment by Otto Kekäläinen [ 2022-10-22 ]

I encountered this in Salsa-CI after removing allow_failure: true from the step mariadb.org-10.6 to mariadb-10.6 upgrade: which had been there since the inception of 10.6 series, as the way uring was used broke the 10.6 upgrades completely. Because this test was ignored, the commit that introduced this bug was not caught..

It is easily reproducible by copy-pasting the commands in salsa-ci.yml into a Debian Sid Docker session.

The error starts actually here:

Unpacking mysql-common (1:10.6.11+maria~debunstable) over (1:10.6.10+maria~debunstable) ...
Preparing to unpack .../mariadb-common_10.6.11+maria~debunstable_all.deb ...
Unpacking mariadb-common (1:10.6.11+maria~debunstable) over (1:10.6.10+maria~debunstable) ...
Preparing to unpack .../libmariadb3_10.6.11+maria~debunstable_amd64.deb ...
Unpacking libmariadb3:amd64 (1:10.6.11+maria~debunstable) over (1:10.6.10+maria~debunstable) ...
dpkg: mariadb-client-10.6: dependency problems, but removing anyway as you requested:
 mariadb-server-10.6 depends on mariadb-client-10.6 (>= 1:10.6.10+maria~debunstable).

This leads to the command mariadb-admin (and the symlink mysqladmin to be missing from the system at the time /etc/init.d/mariadb stop runs. When that script has set -x on the error is rather clear:

Preparing to unpack .../0-mariadb-server-10.6_10.6.11+maria~debunstable_amd64.deb ...
...
+ log_daemon_msg 'Stopping MariaDB database server' mariadbd
+ '[' -z 'Stopping MariaDB database server' ']'
+ log_daemon_msg_pre 'Stopping MariaDB database server' mariadbd
+ :
+ '[' -z mariadbd ']'
+ echo -n 'Stopping MariaDB database server: mariadbd'
Stopping MariaDB database server: mariadbd+ log_daemon_msg_post 'Stopping MariaDB database server' mariadbd
+ :
+ mariadbd_status check_dead nowarn
++ /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
+ ping_output='/etc/init.d/mariadb: line 87: /usr/bin/mysqladmin: No such file or directory'

I will fix this now and post a PR soon. Assigning to myself.

Comment by Otto Kekäläinen [ 2022-10-22 ]

After failed install apt shows the problem, but is not very verbose..

# apt-get install -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1 -o Debug::pkgProblemResolver=1 -y --allow-downgrades ./*.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mariadb-client-10.6 : Breaks: mariadb-server-10.6 (< 1:10.6.11+maria~debunstable) but 1:10.6.10+maria~debunstable is installed
 mariadb-server-core-10.6 : Breaks: mariadb-server-10.6 (< 1:10.6.11+maria~debunstable) but 1:10.6.10+maria~debunstable is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Comment by Otto Kekäläinen [ 2022-10-23 ]

I am trying to fix this for 10.6 in https://github.com/MariaDB/server/pull/2300

It is a hard one, none of these errors seem to be affected no matter what changes I do in debian/control (or directly in Packages file in repository while debugging):

cat /etc/apt/apt.conf.d/debug 
Debug::pkgProblemResolver 1;
Debug::pkgDepCache::AutoInstall 1;
Debug::pkgDepCache::Marker 1;
 
root@4e0d3a1610e8:/build/mariadb-sid# apt install ./mariadb-client-core-10.6_10.6.11+maria~debunstable_amd64.deb 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'mariadb-client-core-10.6' instead of './mariadb-client-core-10.6_10.6.11+maria~debunstable_amd64.deb'
   Removing: mariadb-client-10.6:amd64 as upgrade is not an option for mariadb-client-core-10.6:amd64 (1:10.6.11+maria~debunstable)
    MarkDelete mariadb-client-10.6:amd64 < 1:10.6.10+maria~debunstable @ii K > FU=0
   Removing: mariadb-server-core-10.6:amd64 as upgrade is not an option for mariadb-client-core-10.6:amd64 (1:10.6.11+maria~debunstable)
    MarkDelete mariadb-server-core-10.6:amd64 < 1:10.6.10+maria~debunstable @ii K > FU=0
  MarkInstall mariadb-client-core-10.6:amd64 < 1:10.6.10+maria~debunstable -> 1:10.6.11+maria~debunstable @ii puU > FU=1
    MarkInstall libmariadb3:amd64 < 1:10.6.10+maria~debunstable @ii pK > FU=0
      MarkInstall mariadb-common:amd64 < 1:10.6.11+maria~debunstable @ii pK > FU=0
        MarkInstall mysql-common:amd64 < 1:10.6.11+maria~debunstable @ii pK > FU=0
      MarkInstall libc6:amd64 < 2.35-3 @ii pK > FU=0
        MarkInstall libgcc-s1:amd64 < 12.2.0-7 @ii pK > FU=0
          MarkInstall gcc-12-base:amd64 < 12.2.0-7 @ii pK > FU=0
      MarkInstall libssl3:amd64 < 3.0.5-4 @ii pK > FU=0
      MarkInstall zlib1g:amd64 < 1:1.2.11.dfsg-4.1 @ii pK > FU=0
    MarkInstall libedit2:amd64 < 3.1-20221009-1 @ii pK > FU=0
      MarkInstall libbsd0:amd64 < 0.11.7-1 @ii pK > FU=0
        MarkInstall libmd0:amd64 < 1.0.4-2 @ii pK > FU=0
      MarkInstall libtinfo6:amd64 < 6.3+20220423-2 @ii pK > FU=0
    MarkInstall libncurses6:amd64 < 6.3+20220423-2 @ii pK > FU=0
    MarkInstall libstdc++6:amd64 < 12.2.0-7 @ii pK > FU=0
Starting pkgProblemResolver with broken count: 1
Starting 2 pkgProblemResolver with broken count: 1
Investigating (0) mariadb-server-10.6:amd64 < 1:10.6.10+maria~debunstable @ii K Ib >
Broken mariadb-server-10.6:amd64 Depends on mariadb-client-10.6:amd64 < 1:10.6.10+maria~debunstable @ii pR > (>= 1:10.6.10+maria~debunstable)
  Considering mariadb-client-10.6:amd64 0 as a solution to mariadb-server-10.6:amd64 0
  Removing mariadb-server-10.6:amd64 rather than change mariadb-client-10.6:amd64
  MarkDelete mariadb-server-10.6:amd64 < 1:10.6.10+maria~debunstable @ii K Ib > FU=0
Done
  Ignore MarkGarbage of libtinfo6:amd64 < 6.3+20220423-2 @ii pK > as its mode (Keep) is protected
  Ignore MarkGarbage of libbsd0:amd64 < 0.11.7-1 @ii pK > as its mode (Keep) is protected
  Ignore MarkGarbage of libmariadb3:amd64 < 1:10.6.10+maria~debunstable @ii pK > as its mode (Keep) is protected
  Ignore MarkGarbage of libtinfo6:amd64 < 6.3+20220423-2 @ii pK > as its mode (Keep) is protected
  Ignore MarkGarbage of libbsd0:amd64 < 0.11.7-1 @ii pK > as its mode (Keep) is protected
  Ignore MarkGarbage of libmariadb3:amd64 < 1:10.6.10+maria~debunstable @ii pK > as its mode (Keep) is protected
The following packages were automatically installed and are no longer required:
  galera-4 iproute2 libatm1 libbpf0 libcap2-bin libcgi-fast-perl libcgi-pm-perl libclone-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libelf1
  libencode-locale-perl libexpat1 libfcgi-bin libfcgi-perl libfcgi0ldbl libgdbm-compat4 libgdbm6 libhtml-parser-perl libhtml-tagset-perl
  libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl libkmod2 liblwp-mediatypes-perl libmnl0 libndctl6 libnsl2 libpam-cap
  libperl5.36 libpmem1 libpopt0 libprocps8 libpython3.10-minimal libregexp-ipv6-perl libssl1.1 libterm-readkey-perl libtimedate-perl libtirpc-common
  libtirpc3 liburi-perl liburing2 libwrap0 libxtables12 lsof netbase perl perl-modules-5.36 procps psmisc python3.10-minimal rsync socat
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  mariadb-client-10.6 mariadb-server-10.6 mariadb-server-core-10.6
The following packages will be upgraded:
  mariadb-client-core-10.6
1 upgraded, 0 newly installed, 3 to remove and 16 not upgraded.
Need to get 0 B/831 kB of archives.
After this operation, 139 MB disk space will be freed.
Do you want to continue? [Y/n] 
 
 
root@4e0d3a1610e8:/build/mariadb-sid# apt install ./mariadb-server-core-10.6_10.6.11+maria~debunstable_amd64.deb 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'mariadb-server-core-10.6' instead of './mariadb-server-core-10.6_10.6.11+maria~debunstable_amd64.deb'
   Removing: mariadb-client-10.6:amd64 as upgrade is not an option for mariadb-server-core-10.6:amd64 (1:10.6.11+maria~debunstable)
    MarkDelete mariadb-client-10.6:amd64 < 1:10.6.10+maria~debunstable @ii K > FU=0
   Removing: mariadb-server-10.6:amd64 as upgrade is not an option for mariadb-server-core-10.6:amd64 (1:10.6.11+maria~debunstable)
    MarkDelete mariadb-server-10.6:amd64 < 1:10.6.10+maria~debunstable @ii K Ib > FU=0
  MarkInstall mariadb-server-core-10.6:amd64 < 1:10.6.10+maria~debunstable -> 1:10.6.11+maria~debunstable @ii puU > FU=1
    MarkInstall mariadb-common:amd64 < 1:10.6.11+maria~debunstable @ii pK > FU=0
      MarkInstall mysql-common:amd64 < 1:10.6.11+maria~debunstable @ii pK > FU=0
    MarkInstall libc6:amd64 < 2.35-3 @ii pK > FU=0
      MarkInstall libgcc-s1:amd64 < 12.2.0-7 @ii pK > FU=0
        MarkInstall gcc-12-base:amd64 < 12.2.0-7 @ii pK > FU=0
    MarkInstall libcrypt1:amd64 < 1:4.4.28-2 @ii pK > FU=0
    MarkInstall liblz4-1:amd64 < 1.9.4-1 @ii pK > FU=0
    MarkInstall libpcre2-8-0:amd64 < 10.40-1 @ii pK > FU=0
    MarkInstall libpmem1:amd64 < 1.12.1-1 @ii pK > FU=0
      MarkInstall libdaxctl1:amd64 < 74-2 @ii pK > FU=0
        MarkInstall libkmod2:amd64 < 30+20220905-1 @ii pK > FU=0
          MarkInstall liblzma5:amd64 < 5.2.7-0.0 @ii pK > FU=0
          MarkInstall libssl3:amd64 < 3.0.5-4 @ii pK > FU=0
          MarkInstall libzstd1:amd64 < 1.5.2+dfsg-1 @ii pK > FU=0
      MarkInstall libndctl6:amd64 < 74-2 @ii pK > FU=0
    MarkInstall libstdc++6:amd64 < 12.2.0-7 @ii pK > FU=0
    MarkInstall liburing2:amd64 < 2.2-2 @ii pK > FU=0
    MarkInstall zlib1g:amd64 < 1:1.2.11.dfsg-4.1 @ii pK > FU=0
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
The following packages were automatically installed and are no longer required:
  galera-4 iproute2 libatm1 libbpf0 libbsd0 libcap2-bin libcgi-fast-perl libcgi-pm-perl libclone-perl libdbd-mariadb-perl libdbi-perl libedit2 libelf1
  libencode-locale-perl libexpat1 libfcgi-bin libfcgi-perl libfcgi0ldbl libgdbm-compat4 libgdbm6 libhtml-parser-perl libhtml-tagset-perl
  libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmd0 libmnl0 libncurses6 libnsl2
  libpam-cap libperl5.36 libpopt0 libprocps8 libpython3.10-minimal libregexp-ipv6-perl libssl1.1 libterm-readkey-perl libtimedate-perl libtirpc-common
  libtirpc3 liburi-perl libwrap0 libxtables12 lsof mariadb-client-core-10.6 netbase perl perl-modules-5.36 procps psmisc python3.10-minimal rsync socat
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  mariadb-client-10.6 mariadb-server-10.6
The following packages will be upgraded:
  mariadb-server-core-10.6
1 upgraded, 0 newly installed, 2 to remove and 16 not upgraded.
Need to get 0 B/7247 kB of archives.
After this operation, 97.2 MB disk space will be freed.
Do you want to continue? [Y/n] 

Comment by Eric X [ 2023-05-12 ]

Just went to update 10.6 to the latest and the results are still bad but with different errors:

Removing mariadb-client-10.6 (1:10.6.12+maria~deb11) ...
Setting up mysql-common (1:10.6.13+maria~deb11) ...
Setting up mariadb-common (1:10.6.13+maria~deb11) ...
(Reading database ... 56749 files and directories currently installed.)
Preparing to unpack .../mariadb-server-10.6_1%3a10.6.13+maria~deb11_amd64.deb ...
Command mariadb-admin/mysqladmin not found! This SysV init script depends on it. ... failed!
invoke-rc.d: initscript mariadb, action "stop" failed.
dpkg: warning: old mariadb-server-10.6 package pre-removal script subprocess returned error exit status 255
dpkg: trying script from the new package instead ...
Command mariadb-admin/mysqladmin not found! This SysV init script depends on it. ... failed!
invoke-rc.d: initscript mariadb, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/mariadb-server-10.6_1%3a10.6.13+maria~deb11_amd64.deb (--unpack):
new mariadb-server-10.6 package pre-removal script subprocess returned error exit status 255
Command mariadb-admin/mysqladmin not found! This SysV init script depends on it. ... failed!
invoke-rc.d: initscript mariadb, action "start" failed.
dpkg: error while cleaning up:
 installed mariadb-server-10.6 package post-installation script subprocess returned error exit status 255
Preparing to unpack .../mariadb-server-core-10.6_1%3a10.6.13+maria~deb11_amd64.deb ...
Unpacking mariadb-server-core-10.6 (1:10.6.13+maria~deb11) over (1:10.6.12+maria~deb11) ...
Preparing to unpack .../mariadb-client-core-10.6_1%3a10.6.13+maria~deb11_amd64.deb ...
Unpacking mariadb-client-core-10.6 (1:10.6.13+maria~deb11) over (1:10.6.12+maria~deb11) ...
Selecting previously unselected package mariadb-client-10.6.
Preparing to unpack .../mariadb-client-10.6_1%3a10.6.13+maria~deb11_amd64.deb ...
Unpacking mariadb-client-10.6 (1:10.6.13+maria~deb11) ...
Errors were encountered while processing:
 /var/cache/apt/archives/mariadb-server-10.6_1%3a10.6.13+maria~deb11_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Something is wrong with this jira platform. I had to manually type in all the line feeds just to make this readable.

Comment by Otto Kekäläinen [ 2023-05-14 ]

Related downstream Debian bug report with further discussion: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1035949

Comment by Eric X [ 2023-08-20 ]

seems resolved now but the init.d script has a small bug on line 98

  if [ ! -d "$datadir"]

change to

  if [ ! -d "$datadir" ]

and the bash error goes away

Generated at Thu Feb 08 10:02:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.