Bug #38848 myisam_use_mmap causes widespread myisam corruption on windows
Submitted: 18 Aug 2008 11:16 Modified: 12 May 2009 2:36
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S2 (Serious)
Version:5.1.21, 5.1.31, 6.0.5 OS:Microsoft Windows
Assigned to: CPU Architecture:Any
Tags: corruption, mmap, myisam_use_mmap
Triage: Triaged: D2 (Serious)

[18 Aug 2008 11:16] Shane Bester
Description:
when mysqld is run with --myisam_use_mmap=1 all myisam tables get crashed:

mysql> check table user;
+------------+-------+----------+-----------------------------------------------+
| Table      | Op    | Msg_type | Msg_text                                      |
+------------+-------+----------+-----------------------------------------------+
| mysql.user | check | warning  | Size of datafile is: 251       Should be: 244 |
| mysql.user | check | error    | Wrong bytesec: 0-0-0 at linkstart: 244        |
| mysql.user | check | error    | Corrupt                                       |
+------------+-------+----------+-----------------------------------------------+
3 rows in set (0.08 sec)

How to repeat:
mysqld --skip-grant-tables --skip-name-resolve --skip-innodb --myisam_use_mmap=1

check table mysql.user;
[18 Aug 2008 11:24] Shane Bester
looks to be a windows specific issue so far.
[27 Mar 2009 12:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/70672

2831 Narayanan V	2009-03-27
      Bug#38848 myisam_use_mmap causes widespread myisam corruption on windows
      
      Currently the memory map is being created
      with a size that is greater than the size 
      of the underlying datafile. This can cause
      varying behaviour,
      
      e.g. 
      
      In windows the size of the datafile
      is increased, while on linux it remains
      the same.
      
      This fix removes the increment factor to
      the size that is used while creating the
      memory map.
     @ storage/myisam/mi_dynrec.c
        remove the factor MEMMAP_EXTRA_MARGIN,
        that is used as the increment factor to the
        underlying datafile size while creating
        the mmap.
     @ storage/myisam/mi_packrec.c
        The size of the underlying datafile is
        increased by MEMMAP_EXTRA_MARGIN when
        using a packed record format. Hence in this
        case the size of the memory map should be incremented by the same factor.
[8 Apr 2009 6:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/71606

2855 Narayanan V	2009-04-08
      Bug#38848 myisam_use_mmap causes widespread myisam corruption on windows
            
      Currently the memory map is being created
      with a size that is greater than the size 
      of the underlying datafile. This can cause
      varying behaviour,
      
      e.g. 
      
      In windows the size of the datafile
      is increased, while on linux it remains
      the same.
      
      This fix removes the increment margin to
      the size that is used while creating the
      memory map.
     @ storage/myisam/mi_dynrec.c
        remove MEMMAP_EXTRA_MARGIN that is used as
        the increment margin to the underlying 
        datafile size while creating the mmap.
     @ storage/myisam/mi_packrec.c
        The size of the underlying datafile is
        increased by MEMMAP_EXTRA_MARGIN when
        using a packed record format. Hence in 
        this case the size of the memory map should 
        be incremented by the same factor.
[9 Apr 2009 8:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/71738

2861 Narayanan V	2009-04-09
      Bug#38848 myisam_use_mmap causes widespread myisam corruption on windows
                  
      Currently the memory map is being created
      with a size that is greater than the size 
      of the underlying datafile. This can cause
      varying behaviour,
      
      e.g. 
      
      In windows the size of the datafile
      is increased, while on linux it remains
      the same.
      
      This fix removes the increment margin to
      the size that is used while creating the
      memory map.
     @ storage/myisam/mi_dynrec.c
        remove MEMMAP_EXTRA_MARGIN that is used as
        the increment margin to the underlying 
        datafile size while creating the mmap.
     @ storage/myisam/mi_packrec.c
        The size of the underlying datafile is
        increased by MEMMAP_EXTRA_MARGIN when
        using a packed record format. Hence in 
        this case the size of the memory map should 
        be incremented by the same factor.
[5 May 2009 19:41] Bugs System
Pushed into 5.1.35 (revid:davi.arnaut@sun.com-20090505190206-9xmh7dlc6kom8exp) (version source revid:davi.arnaut@sun.com-20090505190206-9xmh7dlc6kom8exp) (merge vers: 5.1.35) (pib:6)
[6 May 2009 14:10] Bugs System
Pushed into 6.0.12-alpha (revid:svoj@sun.com-20090506125450-yokcmvqf2g7jhujq) (version source revid:v.narayanan@sun.com-20090409090237-srral27x7ru9lrur) (merge vers: 6.0.11-alpha) (pib:6)
[12 May 2009 2:36] Paul Dubois
Noted in 5.1.35, 6.0.12 changelogs.

On WIndows, running the server with myisam_use_mmap enabled caused
MyISAM table corruption.
[15 Jun 2009 8:28] Bugs System
Pushed into 5.1.35-ndb-6.3.26 (revid:jonas@mysql.com-20090615074202-0r5r2jmi83tww6sf) (version source revid:jonas@mysql.com-20090615070837-9pccutgc7repvb4d) (merge vers: 5.1.35-ndb-6.3.26) (pib:6)
[15 Jun 2009 9:07] Bugs System
Pushed into 5.1.35-ndb-7.0.7 (revid:jonas@mysql.com-20090615074335-9hcltksp5cu5fucn) (version source revid:jonas@mysql.com-20090615072714-rmfkvrbbipd9r32c) (merge vers: 5.1.35-ndb-7.0.7) (pib:6)
[15 Jun 2009 9:48] Bugs System
Pushed into 5.1.35-ndb-6.2.19 (revid:jonas@mysql.com-20090615061520-sq7ds4yw299ggugm) (version source revid:jonas@mysql.com-20090615054654-ebgpz7elwu1xj36j) (merge vers: 5.1.35-ndb-6.2.19) (pib:6)