Score:0

Postfix suddenly is not configured for MySQL

dz flag

I've had this server in use for something like a week. Fresh Ubuntu 20.04 install, packages all installed through apt. I could receive and send mail outside of my IP just fine. Suddenly, receiving e-mail was not longer possible.

I checked the logs and soon noticed the error: unsupported dictionary type: mysql message, which meant that postfix was unable to check the recipient against my database. I checked my apt list --installed output, but postfix-mysql was installed, so that wasn't the problem. I soon discovered I needed to add the line: mysql /usr/lib/postfix/postfix-mysql.so.1.0.1 dict_mysql_open to /etc/postfix/dynamicmaps.cf and do a postfix reload.

My question is: how could this happen? I do have an apt update && apt upgrade cron running that auto-updates the server.

Update

The last update I saw was this one:

2021-09-28 23:01:31 upgrade postfix:amd64 3.4.13-0ubuntu1.1 3.4.13-0ubuntu1.2 The problems started right after that. dynamicmaps.cf was empty except for the commented instruction-line at the top. I added the mysql-line, and now that is the only functional line in the file.

Update 2

After killing all the processes found with ps -Af | grep -E 'dpkg|debconf|apt|unatt' I ran:

sudo apt update
sudo apt-get install --fix-broken
sudo dpkg --configure -a -D223

Which gave me the following error when trying to configure postfix:

D000001: process queue pkg postfix-mysql:amd64 queue.len 54 progress 1, try 1
dpkg: dependency problems prevent configuration of postfix-mysql:
 postfix-mysql depends on postfix (= 3.4.13-0ubuntu1.2); however:
  Package postfix is not installed.

dpkg: error processing package postfix-mysql (--configure):
 dependency problems - leaving unconfigured

I don't know enough about dpkg to understand this. What's happening here?

Update 3

dpkg-query --show --showformat='${package} ${status}\n' 'postfix*' yields:

postfix install ok installed                                                                                            postfix-cdb unknown ok not-installed
postfix-doc unknown ok not-installed
postfix-ldap unknown ok not-installed
postfix-lmdb unknown ok not-installed
postfix-mysql install ok installed
postfix-pcre unknown ok not-installed
postfix-pgsql unknown ok not-installed
postfix-sqlite unknown ok not-installed

So both requested packages are in an OK and installed status. The apt command did not suggest a fix as far as I saw (and I read the output carefully). It seems your suggestions worked.

What I don't like is not knowing what I'm doing, but that is due to my own apt and dpkg lack of knowledge.

anx avatar
fr flag
anx
Well, open up your dpkg.log and check after which version you experienced the unexpected change. Also, what were the contents of the `dynamicmaps.cf` file before you edited it?
Guido Goluke avatar
dz flag
Updated the question with the information
anx avatar
fr flag
anx
You only added the error, but I was sort of expecting `apt-get install -f` to automatically suggest the solution to the dependency problem for you. What did apt-get say?
anx avatar
fr flag
anx
The dpkg-query command I suggested should list the current status of all involved packages.. but its probably less effort to just `apt install postfix postfix-mysql` and see what happens.
Guido Goluke avatar
dz flag
Thanks again, updated in Update 3
Score:0
fr flag
anx

Every time you upgrade a postfix map package, it will first remove its respective map type from /etc/postfix/dynamicmaps.cf and only in a later add it (back). You can manually see that this works by forcing a reconfiguration via dpkg-reconfigure postfix-mysql. If the file was left empty after the upgrade, that likely means the upgrade was interrupted - or is even still hanging, waiting for user input that never came.

If you are applying all SRU, then you will have upgraded Postfix to 3.4.13-0ubuntu1.2 for Ubuntu 20.04. I recommend you confirm that no upgrades are currently being applied:

ps -Af | grep -E 'dpkg|debconf|apt|unatt'
dpkg-query --show --showformat='${package} ${status}\n' 'postfix*'

Your cron job has is flawed in that it fails to tell apt that this is a non-interactive invocation, this may be the reason it is hanging.

If necessary, ensure all packages are properly installed. During this steps, you will likely see warnings or questions that help determine why your cron job failed.

sudo apt update
sudo apt-get install --fix-broken
sudo dpkg --configure -a -D223

Don't forget to remove the offending cron job as setup something reliable. The program unattended-upgrade is usually the preferred method of applying upgrades on Ubuntu systems when no admin is standing by. It will skip over or use defaults for things apt would otherwise ask for interactively.

Guido Goluke avatar
dz flag
Thanks so much. The ps output gave me a number of results. The one that struck me was: `root 979323 979322 0 Sep28 ? 00:00:00 /bin/sh -c (apt-get update && apt-get -y upgrade) > /dev/null`. Sep 28th was the date after which the error occured, I assume this tells me the update process is still hanging?
anx avatar
fr flag
anx
Oh that's your cron call, so it seems like its hanging. Look what other processes (specifically: child processes of the one you found) are running - I suspected the upgrade got stuck while calling dpkg/debconf somewhere. If you do not want to fix this, kill the child process, wait for apt to deal with that, then try my steps to ensure you get all packages back to normal.
Guido Goluke avatar
dz flag
Thanks again, updated my question with findings
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.