Commit 5aabf1a9 authored by unknown's avatar unknown
Browse files

Merge poseidon.ndb.mysql.com:/home/tomas/mysql-5.0

into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.0-main

parents f5afd233 808f77f6
Loading
Loading
Loading
Loading
+38 −25
Original line number Diff line number Diff line
@@ -3699,6 +3699,37 @@ os_aio_posix_handle(
}
#endif

/**************************************************************************
Do a 'last millisecond' check that the page end is sensible;
reported page checksum errors from Linux seem to wipe over the page end. */
static
void
os_file_check_page_trailers(
/*========================*/
	byte*	combined_buf,	/* in: combined write buffer */
	ulint	total_len)	/* in: size of combined_buf, in bytes
				(a multiple of UNIV_PAGE_SIZE) */
{
	ulint	len;

	for (len = 0; len + UNIV_PAGE_SIZE <= total_len;
			len += UNIV_PAGE_SIZE) {
		byte*	buf = combined_buf + len;

		if (memcmp(buf + (FIL_PAGE_LSN + 4), buf + (UNIV_PAGE_SIZE
				- FIL_PAGE_END_LSN_OLD_CHKSUM + 4), 4)) {
		    	ut_print_timestamp(stderr);
		    	fprintf(stderr,
"  InnoDB: ERROR: The page to be written seems corrupt!\n"
"InnoDB: Writing a block of %lu bytes, currently at offset %lu\n",
			(ulong)total_len, (ulong)len);
			buf_page_print(buf);
		    	fprintf(stderr,
"InnoDB: ERROR: The page to be written seems corrupt!\n");
		}
	}
}

/**************************************************************************
Does simulated aio. This function should be called by an i/o-handler
thread. */
@@ -3736,7 +3767,6 @@ os_aio_simulated_handle(
	ibool		ret;
	ulint		n;
	ulint		i;
	ulint		len2;
	
	segment = os_aio_get_array_and_local_segment(&array, global_segment);
	
@@ -3944,32 +3974,15 @@ os_aio_simulated_handle(
				ut_error;
			}

			/* Do a 'last millisecond' check that the page end
			is sensible; reported page checksum errors from
			Linux seem to wipe over the page end */

			for (len2 = 0; len2 + UNIV_PAGE_SIZE <= total_len;
						len2 += UNIV_PAGE_SIZE) {
				if (mach_read_from_4(combined_buf + len2
						+ FIL_PAGE_LSN + 4)
				    != mach_read_from_4(combined_buf + len2
				    		+ UNIV_PAGE_SIZE
				    	- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
				    	ut_print_timestamp(stderr);
				    	fprintf(stderr,
"  InnoDB: ERROR: The page to be written seems corrupt!\n");
				    	fprintf(stderr,
"InnoDB: Writing a block of %lu bytes, currently writing at offset %lu\n",
					(ulong)total_len, (ulong)len2);
					buf_page_print(combined_buf + len2);
				    	fprintf(stderr,
"InnoDB: ERROR: The page to be written seems corrupt!\n");
				}
			}
			os_file_check_page_trailers(combined_buf, total_len);
		}

		ret = os_file_write(slot->name, slot->file, combined_buf,
				slot->offset, slot->offset_high, total_len);

		if (array == os_aio_write_array) {
			os_file_check_page_trailers(combined_buf, total_len);
		}
	} else {
		ret = os_file_read(slot->file, combined_buf,
				slot->offset, slot->offset_high, total_len);
+20 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ sub mtr_record_dead_children ();
sub mtr_exit ($);
sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
sub mtr_kill_process ($$$$);

# static in C
sub spawn_impl ($$$$$$$$);
@@ -885,6 +886,25 @@ sub mtr_kill_processes ($) {
  }
}


sub mtr_kill_process ($$$$) {
  my $pid= shift;
  my $signal= shift;
  my $retries= shift;
  my $timeout= shift;

  while (1)
  {
    kill($signal, $pid);

    last unless kill (0, $pid) and $retries--;

    mtr_debug("Sleep $timeout second waiting for processes to die");

    sleep($timeout);
  }
}

##############################################################################
#
#  When we exit, we kill off all children
+73 −13
Original line number Diff line number Diff line
@@ -918,6 +918,7 @@ sub command_line_setup () {
   path_err =>        "$opt_vardir/log/im.err",
   path_log =>        "$opt_vardir/log/im.log",
   path_pid =>        "$opt_vardir/run/im.pid",
   path_angel_pid =>  "$opt_vardir/run/im.angel.pid",
   path_sock =>       "$sockdir/im.sock",
   port =>            $im_port,
   start_timeout =>   $master->[0]->{'start_timeout'},
@@ -1188,6 +1189,7 @@ sub environment_setup () {
  $ENV{'NDB_STATUS_OK'}=      "YES";

  $ENV{'IM_PATH_PID'}=        $instance_manager->{path_pid};
  $ENV{'IM_PATH_ANGEL_PID'}=  $instance_manager->{path_angel_pid};
  $ENV{'IM_PORT'}=            $instance_manager->{port};

  $ENV{'IM_MYSQLD1_SOCK'}=    $instance_manager->{instances}->[0]->{path_sock};
@@ -1813,6 +1815,7 @@ sub im_create_defaults_file($) {

[manager]
pid-file            = $instance_manager->{path_pid}
angel-pid-file      = $instance_manager->{path_angel_pid}
socket              = $instance_manager->{path_sock}
port                = $instance_manager->{port}
password-file       = $instance_manager->{password_file}
@@ -2805,6 +2808,18 @@ sub im_start($$) {
sub im_stop($) {
  my $instance_manager = shift;

  # Obtain mysqld-process pids before we start stopping IM (it can delete pid
  # files).

  my @mysqld_pids = ();
  my $instances = $instance_manager->{'instances'};

  push(@mysqld_pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'}))
    if -r $instances->[0]->{'path_pid'};

  push(@mysqld_pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'}))
    if -r $instances->[1]->{'path_pid'};

  # Re-read pid from the file, since during tests Instance Manager could have
  # been restarted, so its pid could have been changed.

@@ -2812,34 +2827,79 @@ sub im_stop($) {
    mtr_get_pid_from_file($instance_manager->{'path_pid'})
      if -f $instance_manager->{'path_pid'};

  if (-f $instance_manager->{'path_angel_pid'})
  {
    $instance_manager->{'angel_pid'} =
      mtr_get_pid_from_file($instance_manager->{'path_angel_pid'})
  }
  else
  {
    $instance_manager->{'angel_pid'} = undef;
  }

  # Inspired from mtr_stop_mysqld_servers().

  start_reap_all();

  # Create list of pids. We should stop Instance Manager and all started
  # mysqld-instances. Some of them may be nonguarded, so IM will not stop them
  # on shutdown.
  # Try graceful shutdown.

  my @pids = ( $instance_manager->{'pid'} );
  my $instances = $instance_manager->{'instances'};
  mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);

  if ( -r $instances->[0]->{'path_pid'} )
  # Check that all processes died.

  my $clean_shutdown= 0;

  while (1)
  {
    push(@pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'}));
  }
    last if kill (0, $instance_manager->{'pid'});

  if ( -r $instances->[1]->{'path_pid'} )
    last if (defined $instance_manager->{'angel_pid'}) &&
            kill (0, $instance_manager->{'angel_pid'});

    foreach my $pid (@mysqld_pids)
    {
    push(@pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'}));
      last if kill (0, $pid);
    }

    $clean_shutdown= 1;
    last;
  }

  # Kill processes.
  # Kill leftovers (the order is important).

  unless ($clean_shutdown)
  {
    mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
      if defined $instance_manager->{'angel_pid'};
    
    mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1);

    # Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM
    # will not stop them on shutdown. So, we should firstly try to end them
    # legally.

    mtr_kill_processes(\@mysqld_pids);

    # Complain in error log so that a warning will be shown.

    my $errlog= "$opt_vardir/log/mysql-test-run.pl.err";

    open (ERRLOG, ">>$errlog") ||
      mtr_error("Can not open error log ($errlog)");

    my $ts= localtime();
    print ERRLOG
      "Warning: [$ts] Instance Manager did not shutdown gracefully.\n";

    close ERRLOG;
  }

  mtr_kill_processes(\@pids);
  # That's all.

  stop_reap_all();

  $instance_manager->{'pid'} = undef;
  $instance_manager->{'angel_pid'} = undef;
}


+4 −4
Original line number Diff line number Diff line
@@ -103,8 +103,8 @@ t1 CREATE TABLE `t1` (
  `c2` varchar(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
  `c3` varbinary(1) NOT NULL default '',
  `c4` varbinary(1) NOT NULL default '',
  `c5` varbinary(3) NOT NULL default '',
  `c6` varbinary(3) NOT NULL default '',
  `c5` varbinary(4) NOT NULL default '',
  `c6` varbinary(4) NOT NULL default '',
  `c7` decimal(2,1) NOT NULL default '0.0',
  `c8` decimal(2,1) NOT NULL default '0.0',
  `c9` decimal(2,1) default NULL,
@@ -152,11 +152,11 @@ SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `COALESCE(1)` int(1) NOT NULL default '0',
  `COALESCE(1.0)` decimal(2,1) unsigned NOT NULL default '0.0',
  `COALESCE(1.0)` decimal(2,1) NOT NULL default '0.0',
  `COALESCE('a')` varchar(1) NOT NULL default '',
  `COALESCE(1,1.0)` decimal(2,1) NOT NULL default '0.0',
  `COALESCE(1,'1')` varbinary(1) NOT NULL default '',
  `COALESCE(1.1,'1')` varbinary(3) NOT NULL default '',
  `COALESCE(1.1,'1')` varbinary(4) NOT NULL default '',
  `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+4 −0
Original line number Diff line number Diff line
@@ -53,3 +53,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1	SIMPLE		ref	0,01	0	5	const	1	Using where; Using index
drop table ;
set names latin1;
select 3 into @v1;
explain select 3 into @v1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
Loading