MariaDB refuses to start... Clues inside!

I’ve installed the MariaDB addon from the hass.io addon store, but can’t get it to work for a hill of beans.

The addon config:

{
  "databases": [
    "homeassistant"
  ],
  "logins": [
    {
      "username": "hass",
      "host": "core-mariadb",
      "password": "password"
    }
  ],
  "rights": [
    {
      "username": "hass",
      "host": "core-mariadb",
      "database": "homeassistant",
      "grant": "ALL PRIVILEGES ON"
    }
  ]
}

I have tried variations of hosts, different users (hardcoded in config or as hass user), same issue.

When the addon is FIRST run, these are the docker logs generated:

[INFO] Create a new mariadb initial system
2019-09-14 22:46:49 0 [ERROR] InnoDB: preallocating 12582912 bytes for file ./ibdata1 failed with error 95
2019-09-14 22:46:49 0 [ERROR] InnoDB: Could not set the file size of './ibdata1'. Probably out of disk space
2019-09-14 22:46:49 0 [ERROR] InnoDB: Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2019-09-14 22:46:50 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-09-14 22:46:50 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-09-14 22:46:50 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2019-09-14 22:46:50 0 [ERROR] Aborting

When running a subsequent time, these are the logs:

[INFO] Use exists mariadb initial system
[INFO] Start MariaDB
190914 22:48:44 mysqld_safe Logging to '/data/databases/core-mariadb.err'.
190914 22:48:44 mysqld_safe Starting mysqld daemon with databases from /data/databases

BUT CHECK THIS OUT
If I go into the container, I can watch the PID of this sleep 1 command increment every second.


~/hass-shortcut(master*) » docker exec -i -t addon_core_mariadb bash                                                                                                                           
bash-4.4# ps au
PID   USER     TIME  COMMAND
    1 root      0:00 /sbin/docker-init -- /run.sh
    6 root      0:00 {run.sh} /bin/bash /run.sh
  392 root      0:00 bash
  400 root      0:00 sleep 1

The addon logs show this here, which aligns with the run.sh code below

[INFO] Use exists mariadb initial system
[INFO] Start MariaDB
190914 22:30:48 mysqld_safe Logging to '/data/databases/core-mariadb.err'.
190914 22:30:48 mysqld_safe Starting mysqld daemon with databases from /data/databases

The run.sh code, where we can see the above logs being generated, and also the sleep 1. So it looks like it’s making it to mysqld_safe --datadir="$MARIADB_DATA" --user=root --skip-log-bin < /dev/null & and failing.

# Init mariadb
if [ ! -d "$MARIADB_DATA" ]; then
    echo "[INFO] Create a new mariadb initial system"
    mysql_install_db --user=root --datadir="$MARIADB_DATA" > /dev/null
else
    echo "[INFO] Use exists mariadb initial system"
fi

# Start mariadb
echo "[INFO] Start MariaDB"
mysqld_safe --datadir="$MARIADB_DATA" --user=root --skip-log-bin < /dev/null &
MARIADB_PID=$!

# Wait until DB is running
while ! mysql -e "" 2> /dev/null; do
    sleep 1
done

If I check my /data/databases/core-maridb.err file, I see the errors just below, which may be preventing mariadb from running. Unfortunately, all of the info I could pull up on this is mostly based around Docker on Mac, or Docker on Windows… HASS in this case is running as hass.io on a bare metal Arch linux install. All other docker containers are working just fine, including HASS.io itself.

2019-09-14 22:48:45 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2019-09-14 22:48:45 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-09-14 22:48:45 0 [Note] InnoDB: Starting shutdown...
2019-09-14 22:48:45 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-09-14 22:48:45 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-09-14 22:48:45 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-09-14 22:48:45 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2019-09-14 22:48:45 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2019-09-14 22:48:45 0 [ERROR] Aborting

Thinking that disk space could be a culprit (I was desperate, and held little faith it would work) I ran /usr/share/hassio/addons/data/core_mariadb » docker rmi $(docker images -f "dangling=true" -q) to clear up the cruft. I was right; it didn’t work.

Hopefully that’s enough data to help someone recognize this issue. I imagine it’s something as simple as a my.cnf update, or perhaps it’s not.

Try setting host to % for logins and rights

Yes I have tried all sorts of variations of host names, including dns, ip, local, and %.

The issue isn’t with the connection, it’s with starting the server altogether. The process wont start properly.

Out of interest, are you using docker zfs storage?

Not as far as I know.
Default options all over for hassio, Maria, docker, etc.

Host is Arch linux and it’s ext4.

If the install script for hassio uses zfs then yes I am.

My work around was the following: https://github.com/home-assistant/hassio-addons/issues/653#issuecomment-521497894

(but use 1.3 as the ‘current’ addon version [as of writing] instead of 1.2 on the command line) Also delete the addons ‘database’ directory and restart