Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

systemctl start mariadb hangs, then fails with a timeout

ErrorJob for mariadb.service failed because a timeout was exceeded.

Short answer

When mariadb.service fails or hangs, the journal and the server's own start-up messages say why. The default start timeout is about 90 seconds, so long crash recovery gets killed by systemd. Raise TimeoutStartSec with a drop-in file, or fix the real fault in the log: corrupt InnoDB pages or a damaged Aria control file.

  • Applies to MariaDB 11.4 LTS, Ubuntu 24.04 with its packaged systemd
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the service status and the last journal lines before changing anything. The wording tells a timeout apart from a crash at start-up.

    sudo systemctl status mariadb.service
    sudo journalctl -n 50 -u mariadb.service
  2. 2Match what you see, then jump to its fix

    1. 1mariadb.service start-pre operation timed out. Terminating.Crash recovery takes longer than the systemd start timeoutFix
    2. 2The log shows InnoDB page corruption or a failed recovery, and the server exits instead of just taking longInnoDB cannot recover because pages or the redo log are corruptFix
    3. 3Missing valid id in the aria control file, in the journalAria control file or log files are corruptFix

What does the error look like?

  • Job for mariadb.service failed because a timeout was exceeded.
  • mariadb.service start-pre operation timed out. Terminating.
  • Failed to start MariaDB 11.4 database server.

Cause 1 of 3

Crash recovery takes longer than the systemd start timeout

1Check

The unit has a start timeout of about 90 seconds. After a crash or a kill, InnoDB recovery of a large redo log can take longer. The journal shows recovery messages right before the timeout.

sudo journalctl -u mariadb.service | grep -i -E 'recover|timed out'

2Fix

Give the unit an unlimited start timeout in a drop-in file, then reload systemd and start again. With systemd 236 or later, MariaDB can extend the timeout itself, so check the version first.

sudo systemctl edit mariadb.service
# in the editor add:
[Service]
TimeoutStartSec=infinity
TimeoutStopSec=infinity

sudo systemctl daemon-reload
sudo systemctl start mariadb.service

3Verify

The unit becomes active (running).

systemctl --version | head -1 && systemctl is-active mariadb.service

Confirmed by mariadb.com

Did this fix it?

Cause 2 of 3

InnoDB cannot recover because pages or the redo log are corrupt

1Check

Read the error log for lines mentioning InnoDB corruption. Copy the data directory before any recovery step.

sudo journalctl -u mariadb.service | grep -i innodb | tail -n 30

2Fix

Start with innodb_force_recovery=1 and go up one level at a time only if needed. This mode is read-only emergency access, not a repair: dump the data, then rebuild the instance from the dump.

# /etc/mysql/mariadb.conf.d/99-recovery.cnf
[mysqld]
innodb_force_recovery = 1

sudo systemctl start mariadb
sudo mariadb-dump --all-databases > rescue.sql

3Verify

The server stays up and the dump completes. Remove the setting once the data is restored.

ls -lh rescue.sql

Confirmed by mariadb.com

Did this fix it?

Cause 3 of 3

Aria control file or log files are corrupt

1Check

This message means something overwrote at least the first bytes of the Aria control file.

sudo journalctl -u mariadb.service | grep -i aria

2Fix

With the server stopped, move the aria_log_control file and the aria_log files away. Aria then checks and repairs its tables when they are next opened.

sudo mkdir /root/aria-backup
sudo mv /var/lib/mysql/aria_log_control /var/lib/mysql/aria_log.* /root/aria-backup/
sudo systemctl start mariadb.service

3Verify

The service starts and the journal has no Aria errors.

systemctl is-active mariadb.service

Confirmed by mariadb.com

Did this fix it?

How do I stop it coming back?

  • Shut the server down with systemctl stop, never by killing the process, so the next start needs little recovery.
  • Keep the data disk from filling up; a full disk is a common reason for corruption.
  • Back up with mariadb-backup or a dump on a schedule and test the restore.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.