ERP5: fix mariadb init
Previously the mariadb service worked on this assumption:
- if
~/srv/mariadb
exists then its contents are in a valid state - if it doesn't exist then it must be created and initialized
The initialization was first made in a temporary directory, and then /bin/mv
was used to atomically move it to ~/srv/mariadb
. This way if the initialization fails in the middle we don't end up with a miss-initialized ~/srv/mariadb
directory.
However this approach had some issues: mv
only works if ~/srv/mariadb
is a simple directory: it fails if it's a symlink, a mount point, or a subvolume (btrfs).
Now the mariadb service works on these assumptions instead:
- if
~/srv/mariadb/mysql
exists and~/srv/mariadb/.slapos_initializing
does not exists then its in a valid state - else
~/srv/mariadb
must be emptied (or created) and reinitialized
The initialization now starts by emptying (or creating) ~/srv/mariadb
and then creating the marker file ~/srv/mariadb/.slapos_initializing
. The marker file is atomically removed at the end of a successful initialization using /bin/rm
.