Commit 2c4fa340 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi
Browse files

Lots of code fixes to the replication code (especially the binary logging and...

Lots of code fixes to the replication code (especially the binary logging and index log file handling)
Fixed bugs in my last changeset that made MySQL hard to compile.
Added mutex around some data that could cause table cache corruptions when using OPTIMIZE TABLE / REPAIR TABLE or automatic repair of MyISAM tables.
Added mutex around some data in the slave start/stop code that could cause THD linked list corruptions
Extended my_chsize() to allow one to specify a filler character.
Extend vio_blocking to return the old state (This made some usage of this function much simpler)
Added testing for some functions that they caller have got the required mutexes before calling the function.
Use setrlimit() to ensure that we can write core file if one specifies --core-file.
Added --slave-compressed-protocol
Made 2 the minimum length for ft_min_word_len
Added variables foreign_key_checks & unique_checks.
Less logging from replication code (if not started with --log-warnings)
Changed that SHOW INNODB STATUS requre the SUPER privilege
More DBUG statements and a lot of new code comments
parent bc035c71
Loading
Loading
Loading
Loading
+31 −13
Original line number Diff line number Diff line
@@ -20058,14 +20058,16 @@ If the temporary file used for fast index creation would be bigger than
using the key cache by the amount specified here, then prefer the key
cache method.  This is mainly used to force long character keys in large
tables to use the slower key cache method to create the index.
@strong{Note} that this parameter is given in megabytes!
@strong{Note} that this parameter is given in megabytes before 4.0.3 and
in bytes starting from this version.
@item @code{myisam_max_sort_file_size}
The maximum size of the temporary file MySQL is allowed to use
while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
or @code{LOAD DATA INFILE}.  If the file-size would be bigger than this,
the index will be created through the key cache (which is slower).
@strong{Note} that this parameter is given in megabytes!
@strong{Note} that this parameter is given in megabytes before 4.0.3 and
in bytes starting from this version.
@item @code{net_buffer_length}
The communication buffer is reset to this size between queries. This
@@ -23246,11 +23248,11 @@ to the log file (by default named @file{'hostname'.log}). This log can
be very useful when you suspect an error in a client and want to know
exactly what @code{mysqld} thought the client sent to it.
By default, the @code{mysql.server} script starts the MySQL
server with the @code{-l} option.  If you need better performance when
you start using MySQL in a production environment, you can
remove the @code{-l} option from @code{mysql.server} or change it to
@code{--log-bin}.
By default, the @code{mysql.server} script starts the MySQL server with
the @code{-l} option (General query log).  If you need better
performance when you start using MySQL in a production environment, you
can remove the @code{-l} option from @code{mysql.server} or change it to
@code{--log-bin}. @xref{Binary log}.
The entries in this log are written as @code{mysqld} receives the questions.
This may be different from the order in which the statements are executed.
@@ -23329,7 +23331,9 @@ we recommend you to switch to this log format as soon as possible!
The binary log contains all information that is available in the update
log in a more efficient format. It also contains information about how long
every query that updated the database took.
every query that updated the database took.  It doesn't contain queries that
doesn't modify any data.  If you want to log all queries (for example to
find a problem query) you should use the general query log. @xref{Query log}.
The binary log is also used when you are replicating a slave from a master.
@xref{Replication}.
@@ -23900,7 +23904,8 @@ the slave to apply updates from one database on the master to the one
with a different name on the slave.
@item
Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'}
to get rid of old logs while the slave is running.
to get rid of old logs while the slave is running. This will remove all old
logs before, but not including @code{'log-name'}.
@item
Due to the non-transactional nature of MyISAM tables, it is possible to have
a query that will only partially update a table and return an error code. This
@@ -23933,7 +23938,6 @@ above bugs are conceptually very simple to fix, we have not yet found a way
to do this without a sigficant code change that would compromize the stability
status of 3.23 branch. There exists a workaround for both if in the rare case
it happens to affect your application -- use @code{slave-skip-errors}.
@end itemize
@@ -24203,6 +24207,10 @@ Example:
Tells the slave server not to start the slave on the startup.  The user
can start it later with @code{SLAVE START}.
@item @code{slave_compressed_protocol=#} @tab
If 1, then use compression on the slave/client protocol if both
slave and master supports this.
@item @code{slave_net_timeout=#} @tab
Number of seconds to wait for more data from the master before aborting
the read.
@@ -28698,6 +28706,7 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item delayed_queue_size @tab num @tab GLOBAL
@item flush @tab bool @tab GLOBAL
@item flush_time @tab num @tab GLOBAL
@item foreign_key_checks @tab bool @tab SESSION
@item identity @tab num @tab SESSION
@item insert_id @tab bool @tab SESSION
@item interactive_timeout @tab num @tab GLOBAL | SESSION
@@ -28734,6 +28743,7 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item rpl_recovery_rank @tab num @tab GLOBAL
@item safe_show_database @tab bool @tab GLOBAL
@item server_id @tab num @tab GLOBAL
@item slave_compressed_protocol @tab bool @tab GLOBAL
@item slave_net_timeout @tab num @tab GLOBAL
@item slow_launch_time @tab num @tab GLOBAL
@item sort_buffer_size @tab num @tab GLOBAL | SESSION
@@ -28759,6 +28769,7 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
@item tx_isolation @tab enum @tab GLOBAL | SESSION
@item version @tab string @tab GLOBAL
@item wait_timeout @tab num @tab GLOBAL | SESSION
@item unique_checks @tab bool @tab SESSION
@end multitable
Variables that are marked with @code{num} can be given a numerical
@@ -37647,8 +37658,8 @@ The following options to @code{mysqld} can be used to change the behaviour of
@item @code{--myisam-recover=#} @tab Automatic recovery of crashed tables.
@item @code{-O myisam_sort_buffer_size=#} @tab Buffer used when recovering tables.
@item @code{--delay-key-write-for-all-tables} @tab Don't flush key buffers between writes for any MyISAM table
@item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help MySQL to decide when to use the slow but safe key cache index create method. @strong{Note} that this parameter is given in megabytes!
@item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this.  @strong{Note} that this paramter is given in megabytes!
@item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help MySQL to decide when to use the slow but safe key cache index create method. @strong{Note} that this parameter is given in megabytes before 4.0.3 and in bytes starting from this version.
@item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this.  @strong{Note} that this parameter is given in megabytes before 4.0.3 and in bytes starting from this version.
@item @code{-O bulk_insert_buffer_size=#} @tab Size of tree cache used in bulk insert optimisation. @strong{Note} that this is a limit @strong{per thread}!
@end multitable
@@ -50016,9 +50027,14 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@appendixsubsec Changes in release 4.0.3
@itemize @bullet
@item
Big code cleanup in replication code.
@item
If one specifies @code{--code-file}, call @code{setrlmit()} to change allowed
core file size to unlimited, to be able to generate core files.
@item
Allow @code{DEFAULT} with @code{INSERT} statement.
@item
The startup parameters @code{myisam_max_extra_sort_file_size} and
The startup parameters @code{myisam_max_sort_file_size} and
@code{myisam_max_extra_sort_file_size} are now given in bytes, not megabytes.
@item
External system locking of MyISAM/ISAM files is now turned off by default.
@@ -50034,6 +50050,8 @@ Fixed a timing bug in @code{DROP DATABASE}
New @code{SET [GLOBAL | SESSION]} syntax to change thread specific and global
server variables at runtime.
@item
Added variable @code{slave_compressed_protocol}.
@item
Renamed variable @code{query_cache_startup_type} to @code{query_cache_type},
@code{myisam_bulk_insert_tree_size} to @code{bulk_insert_buffer_size},
@code{record_buffer} to @code{read_buffer_size} and
+133 −127
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@

**********************************************************************/

#define MTEST_VERSION "1.24"
#define MTEST_VERSION "1.25"

#include <my_global.h>
#include <mysql_embed.h>
@@ -316,8 +316,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)

  for (p= query; (c = *p); ++p)
  {
      switch(c)
	{
    switch(c) {
    case '$':
      if (escaped)
      {
@@ -347,6 +346,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
  }
}


static void close_cons()
{
  DBUG_ENTER("close_cons");
@@ -360,6 +360,7 @@ static void close_cons()
  DBUG_VOID_RETURN;
}


static void close_files()
{
  DBUG_ENTER("close_files");
@@ -371,6 +372,7 @@ static void close_files()
  DBUG_VOID_RETURN;
}


static void free_used_memory()
{
  uint i;
@@ -537,8 +539,7 @@ static int check_result(DYNAMIC_STRING* ds, const char* fname,

  if (res && require_option)
    abort_not_supported_test();
  switch (res)
  {
  switch (res) {
  case 0:
    break; /* ok */
  case 2:
@@ -944,6 +945,7 @@ int do_echo(struct st_query* q)
  return 0;
}


int do_sync_with_master(struct st_query* q)
{
  MYSQL_RES* res;
@@ -954,6 +956,10 @@ int do_sync_with_master(struct st_query* q)
  char* p = q->first_argument;
  int rpl_parse;

  if (!master_pos.file[0])
  {
    die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno);
  }
  rpl_parse = mysql_rpl_parse_enabled(mysql);
  mysql_disable_rpl_parse(mysql);

@@ -963,7 +969,7 @@ int do_sync_with_master(struct st_query* q)
  sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file,
	  master_pos.pos + offset);
  if (mysql_query(mysql, query_buf))
    die("At line %u: failed in %s: %d: %s", start_lineno, query_buf,
    die("line %u: failed in %s: %d: %s", start_lineno, query_buf,
	mysql_errno(mysql), mysql_error(mysql));

  if (!(last_result = res = mysql_store_result(mysql)))
@@ -979,6 +985,7 @@ int do_sync_with_master(struct st_query* q)
  return 0;
}


int do_save_master_pos()
{
  MYSQL_RES* res;
@@ -997,7 +1004,7 @@ int do_save_master_pos()
    die("line %u: mysql_store_result() retuned NULL", start_lineno);
  if (!(row = mysql_fetch_row(res)))
    die("line %u: empty result in show master status", start_lineno);
  strncpy(master_pos.file, row[0], sizeof(master_pos.file));
  strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
  master_pos.pos = strtoul(row[1], (char**) 0, 10);
  mysql_free_result(res); last_result=0;

@@ -2475,8 +2482,7 @@ int main(int argc, char** argv)
    if (!processed)
    {
      current_line_inc = 0;
      switch(q->type)
      {
      switch(q->type) {
      case Q_WHILE: do_while(q); break;
      case Q_END_BLOCK: do_done(q); break;
      default: current_line_inc = 1; break;
+3 −0
Original line number Diff line number Diff line
@@ -476,6 +476,9 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
#define pthread_mutex_trylock(A) pthread_mutex_lock(A)
#define pthread_mutex_t safe_mutex_t
#define safe_mutex_assert_owner(mp) DBUG_ASSERT((mp)->count > 0 && pthread_equal(pthread_self(),(mp)->thread))
#else
#define safe_mutex_assert_owner(mp)
#endif /* SAFE_MUTEX */

	/* READ-WRITE thread locking */
+2 −1
Original line number Diff line number Diff line
@@ -556,7 +556,7 @@ extern void init_glob_errs(void);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_chsize(File fd,my_off_t newlength,myf MyFlags);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_error _VARARGS((int nr,myf MyFlags, ...));
extern int my_printf_error _VARARGS((uint my_err, const char *format,
				     myf MyFlags, ...)
@@ -678,6 +678,7 @@ extern int end_io_cache(IO_CACHE *info);
extern uint my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
+7 −4
Original line number Diff line number Diff line
@@ -27,7 +27,10 @@ C_MODE_START
extern const char *raid_type_string[];
C_MODE_END

#if defined(USE_RAID) && !defined(DONT_USE_RAID)
#ifdef DONT_USE_RAID
#undef USE_RAID
#endif
#if defined(USE_RAID)

#ifdef __GNUC__
#pragma interface			/* gcc class implementation */
@@ -41,7 +44,7 @@ C_MODE_END
#define my_write(A,B,C,D)    my_raid_write(A,B,C,D)
#define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E)
#define my_pread(A,B,C,D,E)  my_raid_pread(A,B,C,D,E)
#define my_chsize(A,B,C)     my_raid_chsize(A,B,C)
#define my_chsize(A,B,C,D)   my_raid_chsize(A,B,C,D)
#define my_close(A,B)        my_raid_close(A,B)
#define my_tell(A,B)         my_raid_tell(A,B)
#define my_seek(A,B,C,D)     my_raid_seek(A,B,C,D)
@@ -82,7 +85,7 @@ extern "C" {

  int my_raid_lock(File,int locktype, my_off_t start, my_off_t length,
		   myf MyFlags);
  int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags);
  int my_raid_chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
  int my_raid_close(File, myf MyFlags);
  int my_raid_fstat(int Filedes, struct stat *buf,  myf MyFlags);

@@ -113,7 +116,7 @@ class RaidFd {
    int Write(const byte *Buffer, uint Count, myf MyFlags);
    int Read(const byte *Buffer, uint Count, myf MyFlags);
    int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags);
    int Chsize(File fd, my_off_t newlength, myf MyFlags);
    int Chsize(File fd, my_off_t newlength, int filler, myf MyFlags);
    int Fstat(int fd, MY_STAT *stat_area, myf MyFlags );
    int Close(myf MyFlags);
    static bool IsRaid(File fd);
Loading