Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

galera_bootstrap: Wait for initial bootstrap start prior creating users #1995

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions chef/cookbooks/mysql/recipes/ha_galera.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
unless node[:database][:galera_bootstrapped]
if CrowbarPacemakerHelper.is_cluster_founder?(node)

# mysql_install_db is blocking when mysql is running as
# it wants an exclusive lock. This can happen if a
# previous bootstrap ran into an error before stopping again

service "mysql-stop for install " do
service_name mysql_service_name
supports status: true, restart: true, reload: true
action :stop
end

execute "mysql_install_db" do
command "mysql_install_db"
action :run
Expand Down Expand Up @@ -90,6 +100,29 @@
action :start
end

ruby_block "wait mysql initialisation" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS this is basically a copy of the code from line 280. Apart from the different user name, static timeout and the not_if condition (which wouldn't hurt here). Could you please turn this into a chef definition with username and timeout as paramters?

block do
require "timeout"
begin
cmd = "mysql -u 'root' -N -B " \
"-e \"SHOW STATUS WHERE Variable_name='wsrep_local_state_comment';\" | cut -f 2"
sync_state = ""
Timeout.timeout(30) do
while sync_state != "Synced"
sleep(1)
get_state = Mixlib::ShellOut.new(cmd).run_command
sync_state = get_state.stdout.chop
end
end
rescue Timeout::Error
message = "Galera cluster did not start after 30 seconds. " \
"Check pacemaker and mysql log files manually for possible errors."
Chef::Log.fatal(message)
raise message
end
end
end

database_user "create state snapshot transfer user" do
connection db_connection
username "sstuser"
Expand Down