What our databases have taught us

We run MySQL, MariaDB and PostgreSQL on our own servers and in our own products. These are the failures that cost us most – and what we do now. None of them are in an installation guide.

Last checked:

ChecklistWhat we take away
  • Check every new install from a panel: authentication, character set and backup target
  • A backup only counts once it has been restored from the offsite copy
  • Test on the same engine and version as production
  • Apply minor versions every quarter, and plan major versions before support ends

Where we start from

MySQL 8 and MariaDB run almost everywhere for us, because the control panel uses them by default. New projects start on PostgreSQL – our convention says 17, JaKonto runs its Alembic migrations on PostgreSQL 18, and jajob runs Postgres 16 with pgvector. SQLite is for development only. Test databases and build jobs run in Docker on our own hub, a Mac mini with 32 GB.

1. Backups that only existed on paper

The control panel sent backups to Google Drive. When the upload failed it kept a local copy, and its retention setting applied only to Drive. So when uploads failed there was no offsite copy, and the disk slowly filled. On one server the clean-up freed 208 GB – from 251 to 43 GB. When we went through every server on 25.10.2026, we found about 300 GB of leftover local copies on 12 servers.

What we do now: every backup leaves the server, project dumps stay at most 2 days, and a job only reports “OK” once the upload is verified. See the script on the backup page.

2. PostgreSQL was running – but no query worked

A cron job used su - postgres. When that login session ended, systemd-logind deleted PostgreSQL’s shared memory, because RemoveIPC=yes is the default on Debian and Ubuntu. The cluster showed “active”, but every query failed. Odoo showed “Create Database” as if the database were gone – the data was intact. The PostgreSQL documentation describes exactly this and notes that it mainly hits installs where postgres is not a system user.

# Is postgres a regular user (UID >= 1000)? Then RemoveIPC applies to it
id -u postgres
# Turn RemoveIPC off
sudo sed -i 's/^#\?RemoveIPC=.*/RemoveIPC=no/' /etc/systemd/logind.conf
grep -q '^RemoveIPC=no' /etc/systemd/logind.conf || echo 'RemoveIPC=no' | sudo tee -a /etc/systemd/logind.conf
sudo systemctl restart systemd-logind
# In scripts: su postgres -c '…' (no dash) or sudo -u postgres

3. Trust in pg_hba.conf after installation

Our control panel installed PostgreSQL with trust in pg_hba.conf. That means anyone who can run code on the server – including a web shell through a plugin hole – can log in as superuser without a password. We now check the file after every install from the panel:

HBA=$(sudo -u postgres psql -AtX -c 'SHOW hba_file')
sudo grep -nE '^[[:space:]]*(local|host)' "$HBA" | grep -w trust \
  && echo "FIX: change trust to scram-sha-256 and run SELECT pg_reload_conf();"

4. The first emoji caused error 1366

Databases the panel created in MariaDB and MySQL were in utf8mb3. The first user who typed an emoji got error 1366, and the message was never saved. Setting charset=utf8mb4 in the connection string did not help, because the columns themselves were utf8mb3. One query found them, and we converted 58 tables and 245 columns in one product.

-- Columns still in utf8mb3
SELECT table_schema, table_name, column_name, character_set_name
FROM information_schema.COLUMNS
WHERE character_set_name IN ('utf8mb3', 'utf8')
  AND table_schema NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys');

-- Convert one table at a time – backup first, the table is locked meanwhile
ALTER TABLE messages CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER DATABASE app CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

5. 320 green tests and four dead tables

The test suite ran on SQLite because it was fast. Meanwhile four tables were dead in production on MySQL, because the schema had changed in a way SQLite did not catch. A related trap: MySQL DATETIME rounds fractional seconds, so times can differ from what the code wrote. Today we test against the same engine as production, and bkg.dk runs performance tests on MySQL 9.7.

6. The migration tool dropped someone else’s tables

Alembic’s --autogenerate quietly proposed dropping tables that belonged to another service in the same database. An include_object filter solved it. In the same place, two parallel development sessions once wrote the same hand-made revision id. Now only additive migrations go out on bkg.dk – data migrations are refused at deploy. The code is on the migration page.

7. The panel’s update button

On 22.10.2026 we updated the engines on 11 servers. Along the way we learnt that the panel’s MariaDB button does not update – it reinstalls and moves the data directory aside – and that its PostgreSQL update copies only bin/. We now use the packages directly and take a dump first.

PostgreSQL 14 had its final release on 12.11.2026. If you still run 14, it is time to plan a new major version. And minor versions arrive every month, so a fixed update rhythm beats one big clean-up a year.

8. A MySQL hint that MariaDB ignores

In soge we limited a heavy browse query with the MySQL hint MAX_EXECUTION_TIME. On MariaDB it did nothing, and the query over 12.6 million vehicles still took 16–20 seconds or hung. SET STATEMENT max_statement_time=N FOR … worked.

What we take away

  • Check every new install from a panel: authentication, character set and backup target.
  • A backup only counts once it has been restored from the offsite copy.
  • Test on the same engine and version as production.
  • Apply minor versions every quarter, and plan major versions before support ends.

Sources

Last reviewed: 2026-12-03

Questions about our lessons

Why use a control panel when it causes so many problems?

Because it saves time on everything else: web servers, certificates and firewall. We now know its weak spots and check them after every install.

How can you tell RemoveIPC has hit PostgreSQL?

The service shows as running, but queries fail with shared-memory errors, typically right after a cron job or a login session of the postgres user has ended.

Can you check our database for the same problems?

Yes. Tell us which engine and version you run and where it is hosted, and you will get a fixed price.

Fixed price, no commitment

Get a fixed price for your database task

Tell us briefly what you use today and what you want to achieve. A person answers by e-mail with a proposal and a fixed price before any work starts.

  • A fixed price before we start
  • An answer by e-mail, no calls
  • Your details are used only to answer you

Fields marked with * are required.

What is it about?