Commit 82fc3547 authored by He Zhenxing's avatar He Zhenxing

BUG#22082 Slave hangs(holds mutex) on "disk full"

When disk is full, server may waiting for free space while
writing binlog, relay-log or MyISAM tables. The server will 
continue after user have freed some space. But the error
message printed was not quite clear about the how often the
error message is printed, and there will be a delay before
the server continue and user freeing space. And caused users
thinking that the server was hanging forever.

This patch fixed the problem by making the error messages
printed more clear. The error message is split into two part,
the first part will only be printed once, and the second part
will be printed very 10 times.

Message first part:
Disk is full writing '<filename>' (Errcode: <errorno>). Waiting
for someone to free space... (Expect up to 60 secs delay for 
server to continue after freeing disk space)

Message second part:
Retry in 60 secs, Message reprinted in 600 secs
parent 62d5d85c
...@@ -636,6 +636,7 @@ extern int nt_share_delete(const char *name,myf MyFlags); ...@@ -636,6 +636,7 @@ extern int nt_share_delete(const char *name,myf MyFlags);
extern void TERMINATE(FILE *file); extern void TERMINATE(FILE *file);
#endif #endif
extern void init_glob_errs(void); extern void init_glob_errs(void);
extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags); extern int my_fclose(FILE *fd,myf MyFlags);
......
...@@ -39,7 +39,7 @@ const char * NEAR globerrs[GLOBERRS]= ...@@ -39,7 +39,7 @@ const char * NEAR globerrs[GLOBERRS]=
"Can't change dir to '%s' (Errcode: %d)", "Can't change dir to '%s' (Errcode: %d)",
"Warning: '%s' had %d links", "Warning: '%s' had %d links",
"%d files and %d streams is left open\n", "%d files and %d streams is left open\n",
"Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... Retry in %d secs", "Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
"Can't create directory '%s' (Errcode: %d)", "Can't create directory '%s' (Errcode: %d)",
"Character set '%s' is not a compiled character set and is not specified in the '%s' file", "Character set '%s' is not a compiled character set and is not specified in the '%s' file",
"Out of resources when opening file '%s' (Errcode: %d)", "Out of resources when opening file '%s' (Errcode: %d)",
...@@ -90,3 +90,17 @@ void init_glob_errs() ...@@ -90,3 +90,17 @@ void init_glob_errs()
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)";
} }
#endif #endif
void wait_for_free_space(const char *filename, int errors)
{
if (errors == 0)
my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
filename,my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE))
my_printf_error(EE_DISK_FULL,
"Retry in %d secs. Message reprinted in %d secs",
MYF(ME_BELL | ME_NOREFRESH),
MY_WAIT_FOR_USER_TO_FIX_PANIC,
MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC );
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
}
...@@ -116,10 +116,8 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags) ...@@ -116,10 +116,8 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags)
if ((errno == ENOSPC || errno == EDQUOT) && if ((errno == ENOSPC || errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL)) (MyFlags & MY_WAIT_IF_FULL))
{ {
if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE)) wait_for_free_space("[stream]", errors);
my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH), errors++;
"[stream]",my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0))); VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0)));
continue; continue;
} }
......
...@@ -121,10 +121,8 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset, ...@@ -121,10 +121,8 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
if ((my_errno == ENOSPC || my_errno == EDQUOT) && if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL)) (MyFlags & MY_WAIT_IF_FULL))
{ {
if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE)) wait_for_free_space(my_filename(Filedes), errors);
my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH), errors++;
my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
continue; continue;
} }
if ((writenbytes > 0 && (uint) writenbytes != (uint) -1) || if ((writenbytes > 0 && (uint) writenbytes != (uint) -1) ||
......
...@@ -54,10 +54,8 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) ...@@ -54,10 +54,8 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
if ((my_errno == ENOSPC || my_errno == EDQUOT) && if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL)) (MyFlags & MY_WAIT_IF_FULL))
{ {
if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE)) wait_for_free_space(my_filename(Filedes), errors);
my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH), errors++;
my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment