Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 625918 - dev-db/mysql-init-scripts does not support MariaDB+Galera 'bootstrap' action
Summary: dev-db/mysql-init-scripts does not support MariaDB+Galera 'bootstrap' action
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-22 00:46 UTC by Phil Stracchino (Unix Ronin)
Modified: 2017-07-23 23:37 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to implement bootstrap() and properly mark the service as started on success (mysql-init.patch,853 bytes, patch)
2017-07-22 03:01 UTC, Phil Stracchino (Unix Ronin)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Stracchino (Unix Ronin) 2017-07-22 00:46:48 UTC
A galera-based MySQL cluster, whether MariaDB or Percona, requires a separate action to bootstrap a cluster from all nodes down.  This is achieved by starting the first node with the --wsrep-new-cluster argument.  dev-db/mysql-init-scripts does not have an action to do this, so when restarting a cold cluster, the first node must be started manually.  The other nodes can then be started and joined to the cluster, but now OpenRC does not know that the mysql service is running on the first node, so mysqld must be stopped again (manually, you can't use rc-service because openRC thinks it's already stopped), then started a second time using rc-service start.

I modified /etc/init/mysql extremely simply to add a bootstrap( ) service that simply adds --wsrep-new-cluster to MY_ARGS and then calls start( ), and this modification successfully starts the cluster.  However, openrc STILL does not believe that the service is actually running until mysqld is stopped using mysqladmin shutdown and restarted again using rc-service start.

Percona XtraDB Cluster's startup scripts have a bootstrap-pxc startup option that handles this case perfectly well.  dev-db/mysql-init-scripts has no provision for it at all, meaning that the cluster must always be started manually.  wsrep-new-cluster cannot simply be added to the start( ) action, because if that is done, every node will start its own new cluster instead of joining the valid existing cluster.

Also see https://bugs.gentoo.org/show_bug.cgi?id=575360 - dev-db/mysql-init-scripts' check that the data directory is not empty before starting mysqld is counter-productive in a Galera cluster, in which it is perfectly permissable to add nodes with empty data directories to a cluster and the cluster will automatically provision them.  If a problem is encountered during a SST and the SST must be retried, this "helpful" check WILL cause the node restart to fail and force manual recovery.
Comment 1 Brian Evans (RETIRED) gentoo-dev 2017-07-22 01:02:35 UTC
bootstrap has never been a part of Gentoo, but has been in other distros.

You can easily change /etc/conf.d/mysql for the first invocation of a Galera cluster and then revert the change.

But I'm willing to discuss the value of adding this option.
Please remember that the script must work for all versions and not just for a Galera enabled setup.

I'll have another look at bug 575360 as well.
Comment 2 Phil Stracchino (Unix Ronin) 2017-07-22 03:01:35 UTC
Created attachment 486416 [details, diff]
Patch to implement bootstrap() and properly mark the service as started on success

Note:  This patch does NOT detect failed bootstraps and will hang if bootstrap does not succeed.  This is not the worst of all possible outcomes.
Comment 3 Phil Stracchino (Unix Ronin) 2017-07-22 03:04:51 UTC
(In reply to Brian Evans from comment #1)
> bootstrap has never been a part of Gentoo, but has been in other distros.
> 
> You can easily change /etc/conf.d/mysql for the first invocation of a Galera
> cluster and then revert the change.
> 
> But I'm willing to discuss the value of adding this option.
> Please remember that the script must work for all versions and not just for
> a Galera enabled setup.


This proposed patch adds a simplistic-but-workable bootstrap action but has no effect upon the default start/stop actions.  If someone should for some reason call rc-service mysql bootstrap on a non-cluster installation, the bootstrap action should either just act like start, or possibly fail with an error, but start and stop will work regardless.
Comment 4 Phil Stracchino (Unix Ronin) 2017-07-22 18:46:11 UTC
Please see #575360 for a combined patch for this bug and #575360.
Comment 5 Brian Evans (RETIRED) gentoo-dev 2017-07-23 23:37:58 UTC
Fixed with mysql-init-scripts-2.2

Thanks for the help