mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#11747416 : 32228 A disk full makes binary log corrupt
Binary log of master can get a partially logged event if the server runs out of disk space and, while waiting for some space to be freed, is shut down (or crashes). If the server is not stopped, it will just wait endlessly for space to be freed, thus no partial event anomaly occurs. The restarted master server has had a dubious policy to send the incomplete event to slave which it apparently can't handle. Although an error was printed out the fact of sending with unclear error message is a source of confusion. Actually the problem of presence an incomplete event in the binary log was already fixed by WL 5493 (which was merged to our current trunk branch, major version 5.6). The fix makes the server truncate the binary log on server restart and recovery. However 5.5 master can't do that. So the current issue is a problem of sending incomplete events to the slave by 5.5 master. It is fixed in this patch by changing the policy so that only complete events are pushed by the dump thread to the IO thread. In addition, the error text that master sends to the slave when an incomplete event is found, now states that incomplete event may have been caused by an out-of-disk space situation and provides coordinates of the first and the last event bytes read.
This commit is contained in:
@ -4701,14 +4701,14 @@ ER_NOT_SUPPORTED_YET 42000
|
||||
spa "Esta versión de MySQL no soporta todavia '%s'"
|
||||
swe "Denna version av MySQL kan ännu inte utföra '%s'"
|
||||
ER_MASTER_FATAL_ERROR_READING_BINLOG
|
||||
nla "Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log"
|
||||
eng "Got fatal error %d from master when reading data from binary log: '%-.128s'"
|
||||
ger "Schwerer Fehler %d: '%-.128s vom Master beim Lesen des binären Logs"
|
||||
ita "Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario"
|
||||
por "Obteve fatal erro %d: '%-.128s' do master quando lendo dados do binary log"
|
||||
rus "Получена неисправимая ошибка %d: '%-.128s' от головного сервера в процессе выборки данных из двоичного журнала"
|
||||
spa "Recibió fatal error %d: '%-.128s' del master cuando leyendo datos del binary log"
|
||||
swe "Fick fatalt fel %d: '%-.128s' från master vid läsning av binärloggen"
|
||||
nla "Kreeg fatale fout %d: '%-.256s' van master tijdens lezen van data uit binaire log"
|
||||
eng "Got fatal error %d from master when reading data from binary log: '%-.256s'"
|
||||
ger "Schwerer Fehler %d: '%-.256s vom Master beim Lesen des binären Logs"
|
||||
ita "Errore fatale %d: '%-.256s' dal master leggendo i dati dal log binario"
|
||||
por "Obteve fatal erro %d: '%-.256s' do master quando lendo dados do binary log"
|
||||
rus "Получена неисправимая ошибка %d: '%-.256s' от головного сервера в процессе выборки данных из двоичного журнала"
|
||||
spa "Recibió fatal error %d: '%-.256s' del master cuando leyendo datos del binary log"
|
||||
swe "Fick fatalt fel %d: '%-.256s' från master vid läsning av binärloggen"
|
||||
ER_SLAVE_IGNORED_TABLE
|
||||
eng "Slave SQL thread ignored the query because of replicate-*-table rules"
|
||||
ger "Slave-SQL-Thread hat die Abfrage aufgrund von replicate-*-table-Regeln ignoriert"
|
||||
|
@ -352,7 +352,7 @@ Increase max_allowed_packet on master";
|
||||
*errmsg = "memory allocation failed reading log event";
|
||||
break;
|
||||
case LOG_READ_TRUNC:
|
||||
*errmsg = "binlog truncated in the middle of event";
|
||||
*errmsg = "binlog truncated in the middle of event; consider out of disk space on master";
|
||||
break;
|
||||
default:
|
||||
*errmsg = "unknown error reading log event on the master";
|
||||
@ -447,6 +447,9 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
|
||||
String* packet = &thd->packet;
|
||||
int error;
|
||||
const char *errmsg = "Unknown error";
|
||||
const char *fmt= "%s; the last event was read from %s at %s, the last byte read was read from %s at %s.";
|
||||
char llbuff1[22], llbuff2[22];
|
||||
char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message()
|
||||
NET* net = &thd->net;
|
||||
mysql_mutex_t *log_lock;
|
||||
mysql_cond_t *log_cond;
|
||||
@ -677,10 +680,8 @@ impossible position";
|
||||
if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
|
||||
goto err;
|
||||
|
||||
my_off_t prev_pos= pos;
|
||||
while (!(error = Log_event::read_log_event(&log, packet, log_lock)))
|
||||
while (!(error= Log_event::read_log_event(&log, packet, log_lock)))
|
||||
{
|
||||
prev_pos= my_b_tell(&log);
|
||||
#ifndef DBUG_OFF
|
||||
if (max_binlog_dump_events && !left_events--)
|
||||
{
|
||||
@ -766,17 +767,6 @@ impossible position";
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
here we were reading binlog that was not closed properly (as a result
|
||||
of a crash ?). treat any corruption as EOF
|
||||
*/
|
||||
if (binlog_can_be_corrupted &&
|
||||
error != LOG_READ_MEM && error != LOG_READ_EOF)
|
||||
{
|
||||
my_b_seek(&log, prev_pos);
|
||||
error=LOG_READ_EOF;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: now that we are logging the offset, check to make sure
|
||||
the recorded offset and the actual match.
|
||||
@ -1021,6 +1011,16 @@ end:
|
||||
|
||||
err:
|
||||
thd_proc_info(thd, "Waiting to finalize termination");
|
||||
if (my_errno == ER_MASTER_FATAL_ERROR_READING_BINLOG && my_b_inited(&log))
|
||||
/*
|
||||
detailing the fatal error message with coordinates
|
||||
of the last position read.
|
||||
*/
|
||||
my_snprintf(error_text, sizeof(error_text), fmt, errmsg,
|
||||
coord->file_name, (llstr(coord->pos, llbuff1), llbuff1),
|
||||
log_file_name, (llstr(my_b_tell(&log), llbuff2), llbuff2));
|
||||
else
|
||||
strcpy(error_text, errmsg);
|
||||
end_io_cache(&log);
|
||||
RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags));
|
||||
/*
|
||||
@ -1037,7 +1037,7 @@ err:
|
||||
mysql_file_close(file, MYF(MY_WME));
|
||||
thd->variables.max_allowed_packet= old_max_allowed_packet;
|
||||
|
||||
my_message(my_errno, errmsg, MYF(0));
|
||||
my_message(my_errno, error_text, MYF(0));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user