31
31
sub mtr_wait_blocking ($);
32
32
sub mtr_record_dead_children ();
33
33
sub mtr_ndbmgm_start($$);
34
sub mtr_mysqladmin_start($$$);
35
36
sub sleep_until_file_created ($$$);
36
37
sub mtr_kill_processes ($);
359
360
"socket: '$srv->{path_sock}'; ".
360
361
"port: $srv->{port})");
362
my $pid= mtr_server_shutdown($srv);
363
my $pid= mtr_mysqladmin_start($srv, "shutdown", 20);
364
# Save the pid of the drizzle client process
365
# Save the pid of the mysqladmin process
365
366
$admin_pids{$pid}= 1;
367
368
push(@kill_pids,{
373
374
$srv->{'pid'}= 0; # Assume we are done with it
377
if ( ! $::opt_skip_ndbcluster )
380
foreach my $cluster (@{$::clusters})
383
# Don't shut down a "running" cluster
384
next if $cluster->{'use_running'};
386
mtr_debug(" - cluster " .
387
"(pid: $cluster->{pid}; " .
388
"pid file: '$cluster->{path_pid})");
390
my $pid= mtr_ndbmgm_start($cluster, "shutdown");
392
# Save the pid of the ndb_mgm process
393
$admin_pids{$pid}= 1;
396
pid => $cluster->{'pid'},
397
pidfile => $cluster->{'path_pid'}
400
$cluster->{'pid'}= 0; # Assume we are done with it
402
foreach my $ndbd (@{$cluster->{'ndbds'}})
404
mtr_debug(" - ndbd " .
405
"(pid: $ndbd->{pid}; " .
406
"pid file: '$ndbd->{path_pid})");
409
pid => $ndbd->{'pid'},
410
pidfile => $ndbd->{'path_pid'},
412
$ndbd->{'pid'}= 0; # Assume we are done with it
376
417
# Wait for all the admin processes to complete
377
418
mtr_wait_blocking(\%admin_pids);
522
563
# many process's will exit sucessfully.
523
564
# This is the normal case.
524
565
# ----------------------------------------------------------------------
525
my $wait_counter= 10; # Max number of times to redo the loop
566
my $wait_counter= 50; # Max number of times to redo the loop
526
567
foreach my $srv ( @$spec )
528
569
my $pid= $srv->{'pid'};
541
582
if ($wait_counter-- > 0)
543
584
# Give the processes more time to exit
544
select(undef, undef, undef, (1));
585
select(undef, undef, undef, (0.1));
675
sub mtr_server_shutdown($) {
716
# Start "mysqladmin <command>" for a specific mysqld
717
sub mtr_mysqladmin_start($$$) {
720
my $adm_shutdown_tmo= shift;
679
723
mtr_init_args(\$args);
680
mtr_add_arg($args, "--shutdown");
725
mtr_add_arg($args, "--no-defaults");
681
726
mtr_add_arg($args, "--user=%s", $::opt_user);
682
727
mtr_add_arg($args, "--password=");
683
728
mtr_add_arg($args, "--silent");
685
729
if ( -e $srv->{'path_sock'} )
687
731
mtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
690
733
if ( $srv->{'port'} )
692
735
mtr_add_arg($args, "--port=%s", $srv->{'port'});
695
737
mtr_add_arg($args, "--connect_timeout=5");
697
my $pid= mtr_spawn($::exe_drizzle, $args,
698
"", "", "", "", { append_log_file => 1 });
699
mtr_verbose("mtr_server_shutdown, pid: $pid");
739
# Shutdown time must be high as slave may be in reconnect
740
mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
741
mtr_add_arg($args, "$command");
742
my $pid= mtr_spawn($::exe_drizzleadmin, $args,
744
{ append_log_file => 1 });
745
mtr_verbose("mtr_mysqladmin_start, pid: $pid");
703
750
# Start "ndb_mgm shutdown" for a specific cluster, it will