List:Commits« Previous MessageNext Message »
From:Ramil Kalimullin Date:July 28 2008 6:05am
Subject:bzr commit into mysql-5.1 branch (ramil:2680) Bug#37756
View as plain text  
#At file:///home/ram/mysql/b37756.5.1/

 2680 Ramil Kalimullin	2008-07-28
      Fix for bug#37756: enabling fulltext indexes with myisam_repair_threads > 1 causes crash
      
      Problem: fulltext doesn't support parallel idexes repair.
      
      Fix: support it.
modified:
  storage/myisam/ft_parser.c
  storage/myisam/ftdefs.h
  storage/myisam/mi_check.c

per-file messages:
  storage/myisam/ft_parser.c
    Fix for bug#37756: enabling fulltext indexes with myisam_repair_threads > 1 causes crash
    
    In ftparser_call_initializer() we "group" parsers
    and allocate parameters for each unique parser used.
    In case of parallel repairing we may have a bunch
    of parsers that use the only MI_INFO structure.
    Each of these parsers must have its own parameter
    structure in order not to interfere with others.
    
    Moreover, the allocation is done without mutex
    lock so parallel ftparser_call_initializer() calls
    are unsafe.
    
    Now the fulltext parser parameter allocation code moved
    to ftparser_alloc_param() function which is called
    from mi_repair_parallel() to allocate parameters for
    each used parser.
=== modified file 'storage/myisam/ft_parser.c'
--- a/storage/myisam/ft_parser.c	2007-11-14 14:32:03 +0000
+++ b/storage/myisam/ft_parser.c	2008-07-28 06:05:03 +0000
@@ -324,6 +324,23 @@ int ft_parse(TREE *wtree, uchar *doc, in
 }
 
 #define MAX_PARAM_NR 2
+
+
+MYSQL_FTPARSER_PARAM* ftparser_alloc_param(MI_INFO *info)
+{
+  /*
+    We have to allocate two MYSQL_FTPARSER_PARAM structures per plugin
+    because in a boolean search a parser is called recursively
+    ftb_find_relevance* calls ftb_check_phrase * (MAX_PARAM_NR == 2).
+  */
+  info->ftparser_param= (MYSQL_FTPARSER_PARAM *)
+    my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
+              info->s->ftparsers, MYF(MY_WME | MY_ZEROFILL));
+  init_alloc_root(&info->ft_memroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
+  return info->ftparser_param;
+}
+
+
 MYSQL_FTPARSER_PARAM *ftparser_call_initializer(MI_INFO *info,
                                                 uint keynr, uint paramnr)
 {
@@ -364,17 +381,7 @@ MYSQL_FTPARSER_PARAM *ftparser_call_init
       }
       info->s->ftparsers= ftparsers;
     }
-    /*
-      We have to allocate two MYSQL_FTPARSER_PARAM structures per plugin
-      because in a boolean search a parser is called recursively
-      ftb_find_relevance* calls ftb_check_phrase*
-      (MAX_PARAM_NR=2)
-    */
-    info->ftparser_param= (MYSQL_FTPARSER_PARAM *)
-      my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
-                info->s->ftparsers, MYF(MY_WME|MY_ZEROFILL));
-    init_alloc_root(&info->ft_memroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-    if (! info->ftparser_param)
+    if (!ftparser_alloc_param(info))
       return 0;
   }
   if (keynr == NO_SUCH_KEY)

=== modified file 'storage/myisam/ftdefs.h'
--- a/storage/myisam/ftdefs.h	2007-05-10 09:59:39 +0000
+++ b/storage/myisam/ftdefs.h	2008-07-28 06:05:03 +0000
@@ -146,6 +146,7 @@ void ft_boolean_close_search(FT_INFO *);
 float ft_boolean_get_relevance(FT_INFO *);
 my_off_t ft_boolean_get_docid(FT_INFO *);
 void ft_boolean_reinit_search(FT_INFO *);
+MYSQL_FTPARSER_PARAM* ftparser_alloc_param(MI_INFO *info);
 extern MYSQL_FTPARSER_PARAM *ftparser_call_initializer(MI_INFO *info,
                                                        uint keynr,
                                                        uint paramnr);

=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c	2008-03-31 07:40:39 +0000
+++ b/storage/myisam/mi_check.c	2008-07-28 06:05:03 +0000
@@ -2652,6 +2652,7 @@ int mi_repair_parallel(MI_CHECK *param, 
   ulonglong key_map;
   pthread_attr_t thr_attr;
   ulong max_pack_reclength;
+  uint ftparsers= 1;
   DBUG_ENTER("mi_repair_parallel");
   LINT_INIT(key_map);
 
@@ -2840,6 +2841,7 @@ int mi_repair_parallel(MI_CHECK *param, 
       printf ("- Fixing index %d\n",key+1);
     if (sort_param[i].keyinfo->flag & HA_FULLTEXT)
     {
+      sort_param[i].keyinfo->ftparser_nr= ftparsers++;
       sort_param[i].key_read=sort_ft_key_read;
       sort_param[i].key_write=sort_ft_key_write;
     }
@@ -2894,6 +2896,13 @@ int mi_repair_parallel(MI_CHECK *param, 
   sort_param[0].fix_datafile= (my_bool)(! rep_quick);
   sort_param[0].calc_checksum= test(param->testflag & T_CALC_CHECKSUM);
 
+  if (ftparsers > 1)
+  {
+    info->s->ftparsers= ftparsers;
+    if (!ftparser_alloc_param(info))
+      goto err;
+  }
+
   sort_info.got_error=0;
   pthread_mutex_lock(&sort_info.mutex);
 

Thread
bzr commit into mysql-5.1 branch (ramil:2680) Bug#37756Ramil Kalimullin28 Jul