#At file:///export/home/log/Narayanan/mysql_checkouts_bazaar/5.1_main_repository/mysql-5.1-bugteam-38848/ based on revid:satya.bn@stripped
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.
modified:
storage/myisam/mi_dynrec.c
storage/myisam/mi_packrec.c
=== modified file 'storage/myisam/mi_dynrec.c'
--- a/storage/myisam/mi_dynrec.c 2008-03-31 07:40:39 +0000
+++ b/storage/myisam/mi_dynrec.c 2009-04-08 06:48:43 +0000
@@ -66,7 +66,7 @@ static int _mi_cmp_buffer(File file, con
my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
{
DBUG_ENTER("mi_dynmap_file");
- if (size > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN)
+ if (size > (my_off_t) (~((size_t) 0)))
{
DBUG_PRINT("warning", ("File is too large for mmap"));
DBUG_RETURN(1);
@@ -80,7 +80,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my
upon a write if no physical memory is available.
*/
info->s->file_map= (uchar*)
- my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
+ my_mmap(0, (size_t) size,
info->s->mode==O_RDONLY ? PROT_READ :
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE,
@@ -113,7 +113,7 @@ void mi_remap_file(MI_INFO *info, my_off
if (info->s->file_map)
{
VOID(my_munmap((char*) info->s->file_map,
- (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
+ (size_t) info->s->mmaped_length));
mi_dynmap_file(info, size);
}
}
=== modified file 'storage/myisam/mi_packrec.c'
--- a/storage/myisam/mi_packrec.c 2009-04-07 11:36:15 +0000
+++ b/storage/myisam/mi_packrec.c 2009-04-08 06:48:43 +0000
@@ -1502,7 +1502,8 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_PRINT("warning",("File isn't extended for memmap"));
DBUG_RETURN(0);
}
- if (mi_dynmap_file(info, share->state.state.data_file_length))
+ if (mi_dynmap_file(info,
+ share->state.state.data_file_length + MEMMAP_EXTRA_MARGIN))
DBUG_RETURN(0);
}
info->opt_flag|= MEMMAP_USED;
Attachment: [text/bzr-bundle] bzr/v.narayanan@sun.com-20090408064843-5heh243ivbwpdugl.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (v.narayanan:2855) Bug#38848 | Narayanan V | 8 Apr |