mydumper -r can not handle negative index

Bug #1418355 reported by Thomas Wen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Data Dumper
Triaged
Medium
Max Bubenick

Bug Description

when i use mydumper -r to dump a blog database (this blog use a negative primary key). mydumer master thread hung. and dump thread can not get job to do.
i found the codes in get_chunks_for_table below is the reason:

 /* This is estimate, not to use as guarantee! Every chunk would have eventual adjustments */
 guint64 estimated_chunks = rows / rows_per_file;
 guint64 estimated_step, nmin, nmax, cutoff;

 /* Support just bigger INTs for now, very dumb, no verify approach */
 switch (fields[0].type) {
  case MYSQL_TYPE_LONG:
  case MYSQL_TYPE_LONGLONG:
  case MYSQL_TYPE_INT24:
   /* static stepping */
   nmin = strtoll(min,NULL,10);
   nmax = strtoll(max,NULL,10);
   estimated_step = (nmax-nmin)/estimated_chunks+1;
   cutoff = nmin;
   while(cutoff<=nmax) {
    chunks=g_list_append(chunks,g_strdup_printf("%s%s%s%s(`%s` >= %llu AND `%s` < %llu)",
      !showed_nulls?"`":"",
      !showed_nulls?field:"",
      !showed_nulls?"`":"",
      !showed_nulls?" IS NULL OR ":"",
      field, (unsigned long long)cutoff,
      field, (unsigned long long)(cutoff+estimated_step)));
    cutoff+=estimated_step;
    showed_nulls=1;
   }

  default:
   goto cleanup;
 }

nmin and nmax should be gint64, not guint64
may the codes below is correct:

 /* This is estimate, not to use as guarantee! Every chunk would have eventual adjustments */
 gint64 estimated_chunks = rows / rows_per_file;
 gint64 estimated_step, nmin, nmax, cutoff;

 /* Support just bigger INTs for now, very dumb, no verify approach */
 switch (fields[0].type) {
  case MYSQL_TYPE_LONG:
  case MYSQL_TYPE_LONGLONG:
  case MYSQL_TYPE_INT24:
   /* static stepping */
   nmin = strtoll(min,NULL,10);
   nmax = strtoll(max,NULL,10);
   estimated_step = (nmax-nmin)/estimated_chunks+1;
   cutoff = nmin;
   while(cutoff<=nmax) {
    chunks=g_list_append(chunks,g_strdup_printf("%s%s%s%s(`%s` >= %lld AND `%s` < %lld)",
      !showed_nulls?"`":"",
      !showed_nulls?field:"",
      !showed_nulls?"`":"",
      !showed_nulls?" IS NULL OR ":"",
      field, (long long)cutoff,
      field, (long long)(cutoff+estimated_step)));
    cutoff+=estimated_step;
    showed_nulls=1;
   }

  default:
   goto cleanup;
 }

Changed in mydumper:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Max Bubenick (max-bubenick)
milestone: none → 0.9.3
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.