Commit 9c88a54c authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-11179: WSREP transaction excceded size limit in Galera cluster

... causes MariaDB to crash

On error, the wsrep replication buffer (binlog) is dumped to a file
to aid investigations. In order to also include the binlog header,
FDLE object is also needed. This object is only available for wsrep-
threads.
Fix: Instantiate an FDLE object for non-wsrep threads.
parent dbb06d2e
...@@ -73,6 +73,9 @@ Format_description_log_event* wsrep_get_apply_format(THD* thd) ...@@ -73,6 +73,9 @@ Format_description_log_event* wsrep_get_apply_format(THD* thd)
{ {
return (Format_description_log_event*) thd->wsrep_apply_format; return (Format_description_log_event*) thd->wsrep_apply_format;
} }
DBUG_ASSERT(thd->wsrep_rgi);
return thd->wsrep_rgi->rli->relay_log.description_event_for_exec; return thd->wsrep_rgi->rli->relay_log.description_event_for_exec;
} }
......
...@@ -442,11 +442,13 @@ void thd_binlog_flush_pending_rows_event(THD *thd, bool stmt_end) ...@@ -442,11 +442,13 @@ void thd_binlog_flush_pending_rows_event(THD *thd, bool stmt_end)
void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf,
size_t buf_len) size_t buf_len)
{ {
DBUG_ENTER("wsrep_dump_rbr_buf_with_header");
char filename[PATH_MAX]= {0}; char filename[PATH_MAX]= {0};
File file; File file;
IO_CACHE cache; IO_CACHE cache;
Log_event_writer writer(&cache); Log_event_writer writer(&cache);
Format_description_log_event *ev= wsrep_get_apply_format(thd); Format_description_log_event *ev;
int len= my_snprintf(filename, PATH_MAX, "%s/GRA_%ld_%lld_v2.log", int len= my_snprintf(filename, PATH_MAX, "%s/GRA_%ld_%lld_v2.log",
wsrep_data_home_dir, thd->thread_id, wsrep_data_home_dir, thd->thread_id,
...@@ -455,7 +457,7 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, ...@@ -455,7 +457,7 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf,
if (len >= PATH_MAX) if (len >= PATH_MAX)
{ {
WSREP_ERROR("RBR dump path too long: %d, skipping dump.", len); WSREP_ERROR("RBR dump path too long: %d, skipping dump.", len);
return; DBUG_VOID_RETURN;
} }
if ((file= mysql_file_open(key_file_wsrep_gra_log, filename, if ((file= mysql_file_open(key_file_wsrep_gra_log, filename,
...@@ -477,6 +479,13 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, ...@@ -477,6 +479,13 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf,
goto cleanup2; goto cleanup2;
} }
/*
Instantiate an FDLE object for non-wsrep threads (to be written
to the dump file).
*/
ev= (thd->wsrep_applier) ? wsrep_get_apply_format(thd) :
(new Format_description_log_event(4));
if (writer.write(ev) || my_b_write(&cache, (uchar*)rbr_buf, buf_len) || if (writer.write(ev) || my_b_write(&cache, (uchar*)rbr_buf, buf_len) ||
flush_io_cache(&cache)) flush_io_cache(&cache))
{ {
...@@ -489,5 +498,9 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, ...@@ -489,5 +498,9 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf,
cleanup1: cleanup1:
mysql_file_close(file, MYF(MY_WME)); mysql_file_close(file, MYF(MY_WME));
if (!thd->wsrep_applier) delete ev;
DBUG_VOID_RETURN;
} }
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