List:Commits« Previous MessageNext Message »
From:Guilhem Bichot Date:January 26 2009 10:33am
Subject:bzr commit into mysql-6.0 branch (guilhem:2714)
View as plain text  
#At file:///home/mysql_src/bzrrepos/merge_6.0_myisam_changes_to_maria/mysql-6.0-maria-with-porting/ based on revid:guilhem@stripped

 2714 Guilhem Bichot	2009-01-26 [merge]
      Merge with latest 6.0-maria
modified:
  include/myisam.h
  mysql-test/lib/mtr_report.pl
  storage/maria/ha_maria.cc
  storage/maria/ha_maria.h
  storage/maria/ma_check.c
  storage/maria/ma_check_standalone.h
  storage/maria/ma_ft_update.c
  storage/maria/ma_locking.c
  storage/maria/maria_def.h

per-file messages:
  include/myisam.h
    unused constant
  mysql-test/lib/mtr_report.pl
    normal warning raised by maria-recover.test, now that WL#3951 has been ported to Maria
  storage/maria/ha_maria.cc
    Port of WL#3951. Deprecated code for LOAD DATA FROM MASTER removed.
  storage/maria/ha_maria.h
    Deprecated code for LOAD DATA FROM MASTER removed.
  storage/maria/ma_check.c
    Port of WL#1213
  storage/maria/ma_check_standalone.h
    Port of WL#3951
  storage/maria/ma_ft_update.c
    Assertion to check that code is dead
  storage/maria/ma_locking.c
    Port of WL#3951, and of Windows-specific changes
  storage/maria/maria_def.h
    Port of WL#3951
=== modified file 'include/myisam.h'
--- a/include/myisam.h	2008-10-20 09:16:47 +0000
+++ b/include/myisam.h	2009-01-19 20:25:23 +0000
@@ -52,7 +52,6 @@ extern "C" {
   The following defines can be increased if necessary.
   But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and MI_MAX_KEY_LENGTH.
 */
-#define MI_MAX_KEY_LENGTH           1332            /* Max length in bytes */
 #define MI_MAX_KEY_SEG              16              /* Max segments for key */
 
 #define MI_MAX_POSSIBLE_KEY_BUFF    HA_MAX_POSSIBLE_KEY_BUFF

=== modified file 'mysql-test/lib/mtr_report.pl'
--- a/mysql-test/lib/mtr_report.pl	2008-12-14 11:36:15 +0000
+++ b/mysql-test/lib/mtr_report.pl	2009-01-19 20:25:23 +0000
@@ -506,6 +506,7 @@ sub mtr_report_stats ($) {
                 # Bug#35161, test of auto repair --myisam-recover
                 /able.*_will_crash/ or
                 /Got an error from unknown thread, ha_myisam.cc:/ or
+                /Got an error from unknown thread, ha_maria.cc:/ or
 
                 # lowercase_table3 using case sensitive option on
                 # case insensitive filesystem (InnoDB error).

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2008-12-14 11:36:15 +0000
+++ b/storage/maria/ha_maria.cc	2009-01-19 20:25:23 +0000
@@ -693,6 +693,44 @@ void _ma_check_print_warning(HA_CHECK *p
   DBUG_VOID_RETURN;
 }
 
+/**
+  Report list of threads (and queries) accessing a table, thread_id of a
+  thread that detected corruption, ource file name and line number where
+  this corruption was detected, optional extra information (string).
+
+  This function is intended to be used when table corruption is detected.
+
+  @param[in] file      MARIA_HA object.
+  @param[in] message   Optional error message.
+  @param[in] sfile     Name of source file.
+  @param[in] sline     Line number in source file.
+
+  @return void
+*/
+
+void _ma_report_crashed(MARIA_HA *file, const char *message,
+                        const char *sfile, uint sline)
+{
+  THD *cur_thd;
+  LIST *element;
+  char buf[1024];
+  pthread_mutex_lock(&file->s->intern_lock);
+  if ((cur_thd= (THD*) file->in_use.data))
+    sql_print_error("Got an error from thread_id=%lu, %s:%d", cur_thd->thread_id,
+                    sfile, sline);
+  else
+    sql_print_error("Got an error from unknown thread, %s:%d", sfile, sline);
+  if (message)
+    sql_print_error("%s", message);
+  for (element= file->s->in_use; element; element= list_rest(element))
+  {
+    THD *thd= (THD*) element->data;
+    sql_print_error("%s", thd ? thd_security_context(thd, buf, sizeof(buf), 0)
+                              : "Unknown thread accessing table");
+  }
+  pthread_mutex_unlock(&file->s->intern_lock);
+}
+
 }
 
 /**
@@ -785,90 +823,6 @@ uint ha_maria::max_supported_key_length(
 }
 
 
-#ifdef HAVE_REPLICATION
-int ha_maria::net_read_dump(NET * net)
-{
-  int data_fd= file->dfile.file;
-  int error= 0;
-
-  my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
-  for (;;)
-  {
-    ulong packet_len= my_net_read(net);
-    if (!packet_len)
-      break;                                    // end of file
-    if (packet_len == packet_error)
-    {
-      sql_print_error("ha_maria::net_read_dump - read error ");
-      error= -1;
-      goto err;
-    }
-    if (my_write(data_fd, (uchar *) net->read_pos, (uint) packet_len,
-                 MYF(MY_WME | MY_FNABP)))
-    {
-      error= errno;
-      goto err;
-    }
-  }
-err:
-  return error;
-}
-
-
-int ha_maria::dump(THD * thd, int fd)
-{
-  MARIA_SHARE *share= file->s;
-  NET *net= &thd->net;
-  uint block_size= share->block_size;
-  my_off_t bytes_to_read= share->state.state.data_file_length;
-  int data_fd= file->dfile.file;
-  uchar *buf= (uchar *) my_malloc(block_size, MYF(MY_WME));
-  if (!buf)
-    return ENOMEM;
-
-  int error= 0;
-  my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
-  for (; bytes_to_read > 0;)
-  {
-    size_t bytes= my_read(data_fd, buf, block_size, MYF(MY_WME));
-    if (bytes == MY_FILE_ERROR)
-    {
-      error= errno;
-      goto err;
-    }
-
-    if (fd >= 0)
-    {
-      if (my_write(fd, buf, bytes, MYF(MY_WME | MY_FNABP)))
-      {
-        error= errno ? errno : EPIPE;
-        goto err;
-      }
-    }
-    else
-    {
-      if (my_net_write(net, buf, bytes))
-      {
-        error= errno ? errno : EPIPE;
-        goto err;
-      }
-    }
-    bytes_to_read -= bytes;
-  }
-
-  if (fd < 0)
-  {
-    if (my_net_write(net, (uchar*) "", 0))
-      error= errno ? errno : EPIPE;
-    net_flush(net);
-  }
-
-err:
-  my_free((uchar*) buf, MYF(0));
-  return error;
-}
-#endif                                          /* HAVE_REPLICATION */
-
         /* Name is here without an extension */
 
 int ha_maria::open(const char *name, int mode, uint test_if_locked)
@@ -2209,6 +2163,7 @@ int ha_maria::external_lock(THD *thd, in
 {
   TRN *trn= THD_TRN;
   DBUG_ENTER("ha_maria::external_lock");
+  file->in_use.data= thd;
   /*
     We don't test now_transactional because it may vary between lock/unlock
     and thus confuse our reference counting.
@@ -3065,8 +3020,8 @@ static int ha_maria_init(void *p)
   @brief Register a named table with a call back function to the query cache.
 
   @param thd The thread handle
-  @param table_key A pointer to the table name in the table cache
-  @param key_length The length of the table name
+  @param table_name A pointer to the table name in the table cache
+  @param table_name_len The length of the table name
   @param[out] engine_callback The pointer to the storage engine call back
     function, currently 0
   @param[out] engine_data Engine data will be set to 0.

=== modified file 'storage/maria/ha_maria.h'
--- a/storage/maria/ha_maria.h	2008-12-14 11:36:15 +0000
+++ b/storage/maria/ha_maria.h	2009-01-19 20:25:23 +0000
@@ -152,10 +152,6 @@ public:
   int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt);
   int preload_keys(THD * thd, HA_CHECK_OPT * check_opt);
   bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
-#ifdef HAVE_REPLICATION
-  int dump(THD * thd, int fd);
-  int net_read_dump(NET * net);
-#endif
 #ifdef HAVE_QUERY_CACHE
   my_bool register_query_cache_table(THD *thd, char *table_key,
                                      uint key_length,

=== modified file 'storage/maria/ma_check.c'
--- a/storage/maria/ma_check.c	2008-10-20 09:16:47 +0000
+++ b/storage/maria/ma_check.c	2009-01-19 20:25:23 +0000
@@ -808,7 +808,7 @@ static int chk_index(HA_CHECK *param, MA
 		     ha_checksum *key_checksum, uint level)
 {
   int flag;
-  uint used_length,comp_flag,page_flag,nod_flag;
+  uint used_length,comp_flag,page_flag,nod_flag,key_length=0;
   uchar *temp_buff, *keypos, *old_keypos, *endpos;
   my_off_t next_page,record;
   MARIA_SHARE *share= info->s;
@@ -888,8 +888,9 @@ static int chk_index(HA_CHECK *param, MA
     }
     old_keypos=keypos;
     if (keypos >= endpos ||
-	!(*keyinfo->get_key)(&tmp_key, page_flag, nod_flag, &keypos))
+	(key_length=(*keyinfo->get_key)(&tmp_key, page_flag, nod_flag, &keypos)) == 0)
       break;
+    DBUG_ASSERT(key_length <= sizeof(tmp_key_buff));
     if (keypos > endpos)
     {
       _ma_check_print_error(param,

=== modified file 'storage/maria/ma_check_standalone.h'
--- a/storage/maria/ma_check_standalone.h	2008-05-29 15:44:11 +0000
+++ b/storage/maria/ma_check_standalone.h	2009-01-19 20:25:23 +0000
@@ -28,6 +28,7 @@
   dependencies on mysqld.o, which make linking fail.
   The solution is to declare a dummy _mi_report_crashed() in the present
   header file, and include it in Maria standalone programs.
+  Same for _ma_report_crashed().
 
   Some standalone Maria programs, but less numerous than above, use objects
   from ma_check.o like maria_repair(). This brings in linking dependencies of
@@ -49,6 +50,16 @@ void _mi_report_crashed(MI_INFO *file __
 {
 }
 
+#ifndef _maria_h
+struct st_maria_handler;
+typedef struct st_maria_handler MARIA_HA;
+#endif
+void _ma_report_crashed(MARIA_HA *file __attribute__((unused)),
+                        const char *message __attribute__((unused)),
+                        const char *sfile __attribute__((unused)),
+                        uint sline __attribute__((unused)))
+{
+}
 
 #if defined(MA_CHECK_STANDALONE) && (MA_CHECK_STANDALONE == 1)
 

=== modified file 'storage/maria/ma_ft_update.c'
--- a/storage/maria/ma_ft_update.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_ft_update.c	2009-01-19 20:25:23 +0000
@@ -342,8 +342,10 @@ uint _ma_ft_convert_to_ft2(MARIA_HA *inf
   info->keyread_buff_used= info->page_changed=1;      /* info->buff is used */
   /**
     @todo RECOVERY BUG this is not logged yet. Ok as this code is never
-    called, but soon it will be.
+    called. We would need to pin pages until all REDOs are written. Probably
+    no need for an UNDO.
   */
+  DBUG_ASSERT(0);
   if ((root= _ma_new(info, DFLT_INIT_HITS, &page_link)) == HA_OFFSET_ERROR ||
       _ma_write_keypage(info, keyinfo, root, page_link->write_lock,
                         DFLT_INIT_HITS, info->buff))

=== modified file 'storage/maria/ma_locking.c'
--- a/storage/maria/ma_locking.c	2008-10-23 16:29:52 +0000
+++ b/storage/maria/ma_locking.c	2009-01-19 20:25:23 +0000
@@ -43,6 +43,7 @@ int maria_lock_database(MARIA_HA *info, 
     ++share->w_locks;
     ++share->tot_locks;
     info->lock_type= lock_type;
+    info->s->in_use= list_add(info->s->in_use, &info->in_use);
     DBUG_RETURN(0);
   }
 
@@ -136,6 +137,7 @@ int maria_lock_database(MARIA_HA *info, 
       }
       info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
       info->lock_type= F_UNLCK;
+      info->s->in_use= list_delete(info->s->in_use, &info->in_use);
       break;
     case F_RDLCK:
       if (info->lock_type == F_WRLCK)
@@ -166,6 +168,7 @@ int maria_lock_database(MARIA_HA *info, 
       share->r_locks++;
       share->tot_locks++;
       info->lock_type=lock_type;
+      info->s->in_use= list_add(info->s->in_use, &info->in_use);
       break;
     case F_WRLCK:
       if (info->lock_type == F_RDLCK)
@@ -216,13 +219,14 @@ int maria_lock_database(MARIA_HA *info, 
       info->invalidator=share->invalidator;
       share->w_locks++;
       share->tot_locks++;
+      info->s->in_use= list_add(info->s->in_use, &info->in_use);
       break;
     default:
       DBUG_ASSERT(0);
       break;				/* Impossible */
     }
   }
-#ifdef __WIN__
+#ifdef _WIN32
   else
   {
     /*
@@ -319,11 +323,11 @@ int _ma_writeinfo(register MARIA_HA *inf
       if ((error= _ma_state_info_write_sub(share->kfile.file,
                                            &share->state, 1)))
 	olderror=my_errno;
-#ifdef __WIN__
+#ifdef _WIN32
       if (maria_flush)
       {
-	_commit(share->kfile.file);
-	_commit(info->dfile.file);
+        my_sync(share->kfile,0);
+        my_sync(info->dfile,0);
       }
 #endif
       my_errno=olderror;

=== modified file 'storage/maria/maria_def.h'
--- a/storage/maria/maria_def.h	2008-12-14 11:36:15 +0000
+++ b/storage/maria/maria_def.h	2009-01-19 20:25:23 +0000
@@ -275,6 +275,7 @@ typedef struct st_maria_share
   MARIA_COLUMNDEF *columndef;		/* Pointer to column information */
   MARIA_PACK pack;			/* Data about packed records */
   MARIA_BLOB *blobs;			/* Pointer to blobs */
+  LIST *in_use;                         /* List of threads using this table */
   uint16 *column_nr;			/* Original column order */
   LEX_STRING unique_file_name;		/* realpath() of index file */
   LEX_STRING data_file_name;		/* Resolved path names from symlinks */
@@ -496,6 +497,7 @@ struct st_maria_handler
   DYNAMIC_ARRAY *ft1_to_ft2;		/* used only in ft1->ft2 conversion */
   MEM_ROOT      ft_memroot;             /* used by the parser               */
   MYSQL_FTPARSER_PARAM *ftparser_param;	/* share info between init/deinit */
+  LIST in_use;                          /* Thread using this table          */
   uchar *buff;				/* page buffer */
   uchar *keyread_buff;                   /* Buffer for last key read */
   uchar *lastkey_buff;			/* Last used search key */
@@ -661,8 +663,10 @@ struct st_maria_handler
 */
 #define int4store_aligned(A,B) int4store((A),(B))
 
+#define ma_report_crashed(A, B) _ma_report_crashed((A), (B), __FILE__, __LINE__)
 #define maria_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \
     DBUG_PRINT("error", ("Marked table crashed"));                      \
+    ma_report_crashed((x), 0);                                          \
   }while(0)
 #define maria_mark_crashed_share(x)                                     \
   do{(x)->state.changed|= STATE_CRASHED;                                \
@@ -787,7 +791,10 @@ extern pthread_mutex_t THR_LOCK_maria;
 
 
 /* Some extern variables */
+
+C_MODE_START
 extern LIST *maria_open_list;
+C_MODE_END
 extern uchar maria_file_magic[], maria_pack_file_magic[];
 extern uchar maria_uuid[MY_UUID_SIZE];
 extern uint32 maria_read_vec[], maria_readnext_vec[];
@@ -1224,3 +1231,5 @@ extern void ma_set_index_cond_func(MARIA
                                    void *func_arg);
 int ma_check_index_cond(register MARIA_HA *info, uint keynr, uchar *record);
 
+void _ma_report_crashed(MARIA_HA *file, const char *message,
+                        const char *sfile, uint sline);

Thread
bzr commit into mysql-6.0 branch (guilhem:2714) Guilhem Bichot26 Jan