bk commit into 4.1 tree (holyfoot:1.2688) BUG#31305
Below is the list of changes that have just been committed into a local
4.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@1.2688, 2007-10-29 11:25:45+04:00, holyfoot@mysql.com +1 -0
Bug #31305 myisam tables crash when they are near capacity.
When we insert a record into MYISAM table which is almost 'full',
we first write record data in the free space inside a file, and then
check if we have enough space after the end of the file.
So if we don't have the space, table will left corrupted.
Similar error also happens when we updata MYISAM tables.
Fixed by modifying write_dynamic_record and update_dynamic_record functions
to check for free space before writing parts of a record
myisam/mi_dynrec.c@1.43, 2007-10-29 11:25:44+04:00, holyfoot@mysql.com +45 -0
Bug #31305 myisam tables crash when they are near capacity.
now we check space left in table in write_dynamic_record
and update_dynamic_record functions.
If we don't have enough room for the new (updated) record, return with the
error.
diff -Nrup a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c
--- a/myisam/mi_dynrec.c 2006-12-01 19:11:41 +04:00
+++ b/myisam/mi_dynrec.c 2007-10-29 11:25:44 +04:00
@@ -26,6 +26,8 @@
#include "myisamdef.h"
+#define MAX_HEADER_LENGTH 16 +
/* Enough for comparing if number is zero */
static char zero_string[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
@@ -145,6 +147,27 @@ static int write_dynamic_record(MI_INFO
DBUG_ENTER("write_dynamic_record");
flag=0;
+ + /* + Check if we have enough room for the new record. + First we do simplified check to make usual case faster. + Then we do more precise check for the space left. + Though it still is not absolutely precise, as + we always use MAX_HEADER_LEGNTH while it can be + less in the most of the cases + */ + + if (unlikely(info->s->base.max_data_file_length - + info->state->data_file_length < reclength)) + { + if (info->s->base.max_data_file_length - info->state->data_file_length + + info->state->empty - info->state->del * MAX_HEADER_LENGTH < reclength) + { + my_errno=HA_ERR_RECORD_FILE_FULL; + DBUG_RETURN(1);
+ } + } +
do
{
if (_mi_find_writepos(info,reclength,&filepos,&length))
@@ -596,6 +619,28 @@ static int update_dynamic_record(MI_INFO
{
uint tmp=MY_ALIGN(reclength - length + 3 +
test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
+ + /* + Check if we have enough room for the record. + First we do simplified check to make usual case faster. + Then we do more precise check for the space left. + Though it still is not absolutely precise, as + we always use MAX_HEADER_LEGNTH while it can be + less in the most of the cases + */ + + if (unlikely(info->s->base.max_data_file_length - + info->state->data_file_length < reclength)) + { + if (info->s->base.max_data_file_length - info->state->data_file_length + + info->state->empty - info->state->del * MAX_HEADER_LENGTH < + reclength - length) + { + my_errno=HA_ERR_RECORD_FILE_FULL; + DBUG_RETURN(1); + } + } +
/* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
/* Check if we can extend this block */
--
MySQL Code Commits Mailing List
For list archives:
http://lists.mysql.com/commits
To unsubscribe:
http://lists.mysql.com/commits?unsub=lists@pantek.com
Received on Mon Oct 29 04:30:58 2007
This archive was generated by hypermail 2.1.8
: Thu Jul 03 2008 - 10:52:18 EDT
|