Commit 6cb88685 authored by Vlad Lesin's avatar Vlad Lesin Committed by Oleksandr Byelkin

MDEV-24026: InnoDB: Failing assertion: os_total_large_mem_allocated >= size upon incremental backup

mariabackup deallocated uninitialized
write_filt_ctxt.u.wf_incremental_ctxt in xtrabackup_copy_datafile() when
some table should be skipped due to parsed DDL redo log record.
parent 9e3e4c0e
...@@ -1448,7 +1448,7 @@ backup_files(const char *from, bool prep_mode) ...@@ -1448,7 +1448,7 @@ backup_files(const char *from, bool prep_mode)
void backup_fix_ddl(void); void backup_fix_ddl(void);
static lsn_t get_current_lsn(MYSQL *connection) lsn_t get_current_lsn(MYSQL *connection)
{ {
static const char lsn_prefix[] = "\nLog sequence number "; static const char lsn_prefix[] = "\nLog sequence number ";
lsn_t lsn = 0; lsn_t lsn = 0;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define XTRABACKUP_BACKUP_COPY_H #define XTRABACKUP_BACKUP_COPY_H
#include <my_global.h> #include <my_global.h>
#include <mysql.h>
#include "datasink.h" #include "datasink.h"
/* special files */ /* special files */
...@@ -48,4 +49,7 @@ is_path_separator(char); ...@@ -48,4 +49,7 @@ is_path_separator(char);
bool bool
directory_exists(const char *dir, bool create); directory_exists(const char *dir, bool create);
lsn_t
get_current_lsn(MYSQL *connection);
#endif #endif
...@@ -2578,6 +2578,8 @@ static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n, ...@@ -2578,6 +2578,8 @@ static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n,
return(FALSE); return(FALSE);
} }
memset(&write_filt_ctxt, 0, sizeof(xb_write_filt_ctxt_t));
bool was_dropped; bool was_dropped;
pthread_mutex_lock(&backup_mutex); pthread_mutex_lock(&backup_mutex);
was_dropped = (ddl_tracker.drops.find(node->space->id) != ddl_tracker.drops.end()); was_dropped = (ddl_tracker.drops.find(node->space->id) != ddl_tracker.drops.end());
...@@ -2605,7 +2607,6 @@ static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n, ...@@ -2605,7 +2607,6 @@ static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n,
sizeof dst_name - 1); sizeof dst_name - 1);
dst_name[sizeof dst_name - 1] = '\0'; dst_name[sizeof dst_name - 1] = '\0';
memset(&write_filt_ctxt, 0, sizeof(xb_write_filt_ctxt_t));
ut_a(write_filter.process != NULL); ut_a(write_filter.process != NULL);
if (write_filter.init != NULL && if (write_filter.init != NULL &&
...@@ -2947,8 +2948,14 @@ static void dbug_mariabackup_event(const char *event,const char *key) ...@@ -2947,8 +2948,14 @@ static void dbug_mariabackup_event(const char *event,const char *key)
} }
#define DBUG_MARIABACKUP_EVENT(A, B) DBUG_EXECUTE_IF("mariabackup_events", dbug_mariabackup_event(A,B);); #define DBUG_MARIABACKUP_EVENT(A, B) DBUG_EXECUTE_IF("mariabackup_events", dbug_mariabackup_event(A,B););
#define DBUG_MB_INJECT_CODE(EVENT, KEY, CODE) \
DBUG_EXECUTE_IF("mariabackup_inject_code", {\
char *env = getenv(EVENT); \
if (env && !strcmp(env, KEY)) { CODE } \
})
#else #else
#define DBUG_MARIABACKUP_EVENT(A,B) #define DBUG_MARIABACKUP_EVENT(A,B)
#define DBUG_MB_INJECT_CODE(EVENT, KEY, CODE)
#endif #endif
/************************************************************************** /**************************************************************************
...@@ -2973,6 +2980,8 @@ data_copy_thread_func( ...@@ -2973,6 +2980,8 @@ data_copy_thread_func(
while ((node = datafiles_iter_next(ctxt->it)) != NULL) { while ((node = datafiles_iter_next(ctxt->it)) != NULL) {
DBUG_MARIABACKUP_EVENT("before_copy", node->space->name); DBUG_MARIABACKUP_EVENT("before_copy", node->space->name);
DBUG_MB_INJECT_CODE("wait_innodb_redo_before_copy", node->space->name,
backup_wait_for_lsn(get_current_lsn(mysql_connection)););
/* copy the datafile */ /* copy the datafile */
if (xtrabackup_copy_datafile(node, num, NULL, if (xtrabackup_copy_datafile(node, num, NULL,
xtrabackup_incremental ? wf_incremental : wf_write_through)) xtrabackup_incremental ? wf_incremental : wf_write_through))
......
...@@ -2,6 +2,7 @@ call mtr.add_suppression("InnoDB: New log files created"); ...@@ -2,6 +2,7 @@ call mtr.add_suppression("InnoDB: New log files created");
CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB;
CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB;
CREATE TABLE t3(i INT) ENGINE INNODB; CREATE TABLE t3(i INT) ENGINE INNODB;
CREATE TABLE t10(i INT PRIMARY KEY) ENGINE INNODB;
# Create full backup , modify table, then create incremental/differential backup # Create full backup , modify table, then create incremental/differential backup
INSERT into t1 values(1); INSERT into t1 values(1);
# Prepare full backup, apply incremental one # Prepare full backup, apply incremental one
......
...@@ -8,6 +8,7 @@ let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; ...@@ -8,6 +8,7 @@ let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB;
CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB; CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB;
CREATE TABLE t3(i INT) ENGINE INNODB; CREATE TABLE t3(i INT) ENGINE INNODB;
CREATE TABLE t10(i INT PRIMARY KEY) ENGINE INNODB;
echo # Create full backup , modify table, then create incremental/differential backup; echo # Create full backup , modify table, then create incremental/differential backup;
--disable_result_log --disable_result_log
...@@ -20,8 +21,11 @@ INSERT into t1 values(1); ...@@ -20,8 +21,11 @@ INSERT into t1 values(1);
--let after_copy_test_t1=RENAME TABLE test.t1 TO test.t1_renamed --let after_copy_test_t1=RENAME TABLE test.t1 TO test.t1_renamed
--let after_copy_test_t2=DROP TABLE test.t2 --let after_copy_test_t2=DROP TABLE test.t2
--let after_copy_test_t3=CREATE INDEX a_i ON test.t3(i); --let after_copy_test_t3=CREATE INDEX a_i ON test.t3(i);
--let before_copy_test_t10=DROP TABLE test.t10
--let wait_innodb_redo_before_copy=test/t10
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events; # mariabackup should crash with assertion if MDEV-24026 is not fixed
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code;
--let after_load_tablespaces= --let after_load_tablespaces=
--disable_result_log --disable_result_log
echo # Prepare full backup, apply incremental one; echo # Prepare full backup, apply incremental one;
......
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