• unknown's avatar
    BUG#23175 - MYISAM crash/repair failed during repair · 48e84fb9
    unknown authored
    Repair table could crash a server if there is not sufficient
    memory (myisam_sort_buffer_size) to operate. Affects not only
    repair, but also all statements that use create index by sort:
    repair by sort, parallel repair, bulk insert.
    
    Return an error if there is not sufficient memory to store at
    least one key per BUFFPEK.
    
    Also fixed memory leak if thr_find_all_keys returns an error.
    
    
    myisam/sort.c:
      maxbuffer is number of BUFFPEK-s for repair. It is calculated
      as records / keys. keys is number of keys that can be stored
      in memory (myisam_sort_buffer_size). There must be sufficient
      memory to store both BUFFPEK-s and keys. It was checked
      correctly before this patch. However there is another
      requirement that wasn't checked: there must be sufficient
      memory for at least one key per BUFFPEK, otherwise repair
      by sort/parallel repair cannot operate.
      
      Return an error if there is not sufficient memory to store at
      least one key per BUFFPEK.
      
      Also fixed memory leak if thr_find_all_keys returns an error.
    mysql-test/r/repair.result:
      A test case for BUG#23175.
    mysql-test/t/repair.test:
      A test case for BUG#23175.
    48e84fb9
repair.test 2.25 KB