Skip to content

Commit 6cb8868

Browse files
vlad-lesinsanja-byelkin
authored andcommitted
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.
1 parent 9e3e4c0 commit 6cb8868

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

extra/mariabackup/backup_copy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ backup_files(const char *from, bool prep_mode)
14481448

14491449
void backup_fix_ddl(void);
14501450

1451-
static lsn_t get_current_lsn(MYSQL *connection)
1451+
lsn_t get_current_lsn(MYSQL *connection)
14521452
{
14531453
static const char lsn_prefix[] = "\nLog sequence number ";
14541454
lsn_t lsn = 0;

extra/mariabackup/backup_copy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define XTRABACKUP_BACKUP_COPY_H
44

55
#include <my_global.h>
6+
#include <mysql.h>
67
#include "datasink.h"
78

89
/* special files */
@@ -48,4 +49,7 @@ is_path_separator(char);
4849
bool
4950
directory_exists(const char *dir, bool create);
5051

52+
lsn_t
53+
get_current_lsn(MYSQL *connection);
54+
5155
#endif

extra/mariabackup/xtrabackup.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,6 +2578,8 @@ static my_bool xtrabackup_copy_datafile(fil_node_t *node, uint thread_n,
25782578
return(FALSE);
25792579
}
25802580

2581+
memset(&write_filt_ctxt, 0, sizeof(xb_write_filt_ctxt_t));
2582+
25812583
bool was_dropped;
25822584
pthread_mutex_lock(&backup_mutex);
25832585
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,
26052607
sizeof dst_name - 1);
26062608
dst_name[sizeof dst_name - 1] = '\0';
26072609

2608-
memset(&write_filt_ctxt, 0, sizeof(xb_write_filt_ctxt_t));
26092610
ut_a(write_filter.process != NULL);
26102611

26112612
if (write_filter.init != NULL &&
@@ -2947,8 +2948,14 @@ static void dbug_mariabackup_event(const char *event,const char *key)
29472948

29482949
}
29492950
#define DBUG_MARIABACKUP_EVENT(A, B) DBUG_EXECUTE_IF("mariabackup_events", dbug_mariabackup_event(A,B););
2951+
#define DBUG_MB_INJECT_CODE(EVENT, KEY, CODE) \
2952+
DBUG_EXECUTE_IF("mariabackup_inject_code", {\
2953+
char *env = getenv(EVENT); \
2954+
if (env && !strcmp(env, KEY)) { CODE } \
2955+
})
29502956
#else
29512957
#define DBUG_MARIABACKUP_EVENT(A,B)
2958+
#define DBUG_MB_INJECT_CODE(EVENT, KEY, CODE)
29522959
#endif
29532960

29542961
/**************************************************************************
@@ -2973,6 +2980,8 @@ data_copy_thread_func(
29732980

29742981
while ((node = datafiles_iter_next(ctxt->it)) != NULL) {
29752982
DBUG_MARIABACKUP_EVENT("before_copy", node->space->name);
2983+
DBUG_MB_INJECT_CODE("wait_innodb_redo_before_copy", node->space->name,
2984+
backup_wait_for_lsn(get_current_lsn(mysql_connection)););
29762985
/* copy the datafile */
29772986
if (xtrabackup_copy_datafile(node, num, NULL,
29782987
xtrabackup_incremental ? wf_incremental : wf_write_through))

mysql-test/suite/mariabackup/incremental_ddl_during_backup.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ call mtr.add_suppression("InnoDB: New log files created");
22
CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB;
33
CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB;
44
CREATE TABLE t3(i INT) ENGINE INNODB;
5+
CREATE TABLE t10(i INT PRIMARY KEY) ENGINE INNODB;
56
# Create full backup , modify table, then create incremental/differential backup
67
INSERT into t1 values(1);
78
# Prepare full backup, apply incremental one

mysql-test/suite/mariabackup/incremental_ddl_during_backup.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
88
CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB;
99
CREATE TABLE t2(i INT PRIMARY KEY) ENGINE INNODB;
1010
CREATE TABLE t3(i INT) ENGINE INNODB;
11+
CREATE TABLE t10(i INT PRIMARY KEY) ENGINE INNODB;
1112

1213
echo # Create full backup , modify table, then create incremental/differential backup;
1314
--disable_result_log
@@ -20,8 +21,11 @@ INSERT into t1 values(1);
2021
--let after_copy_test_t1=RENAME TABLE test.t1 TO test.t1_renamed
2122
--let after_copy_test_t2=DROP TABLE test.t2
2223
--let after_copy_test_t3=CREATE INDEX a_i ON test.t3(i);
24+
--let before_copy_test_t10=DROP TABLE test.t10
25+
--let wait_innodb_redo_before_copy=test/t10
2326

24-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events;
27+
# mariabackup should crash with assertion if MDEV-24026 is not fixed
28+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code;
2529
--let after_load_tablespaces=
2630
--disable_result_log
2731
echo # Prepare full backup, apply incremental one;

0 commit comments

Comments
 (0)