diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-09-21 11:18:59 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-09-21 11:18:59 +0300 |
commit | 8b6b2c3ea16ab2a3ad2591e49a5e9eea9e9b2bfc (patch) | |
tree | 745a15bbfb4fe19ee15be05d22f70cf1817d02da /extra/mariabackup | |
parent | 82675100d1ae015b21fc681c0c60461a6f3762a9 (diff) | |
download | mariadb-git-8b6b2c3ea16ab2a3ad2591e49a5e9eea9e9b2bfc.tar.gz |
Fix mariabackup leaks (except my_load_defaults)
Diffstat (limited to 'extra/mariabackup')
-rw-r--r-- | extra/mariabackup/backup_copy.cc | 33 | ||||
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 1 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 15 |
3 files changed, 27 insertions, 22 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 6d1c4295852..f4ed8726802 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1351,7 +1351,8 @@ backup_files(const char *from, bool prep_mode) if (rsync_tmpfile == NULL) { msg("Error: can't open file %s\n", rsync_tmpfile_name); - return(false); + ret = false; + goto out; } while (fgets(path, sizeof(path), rsync_tmpfile)) { @@ -1390,24 +1391,22 @@ out: void backup_fix_ddl(void); -#define LSN_PREFIX_IN_SHOW_STATUS "\nLog sequence number " -static lsn_t get_current_lsn(MYSQL *connection) { - MYSQL_RES *res = xb_mysql_query(connection, "SHOW ENGINE INNODB STATUS", true, false); - if (!res) - return 0; - MYSQL_ROW row = mysql_fetch_row(res); - DBUG_ASSERT(row); - if (row) { - const char *p = strstr(row[2],LSN_PREFIX_IN_SHOW_STATUS); - DBUG_ASSERT(p); - if (p) - { - p += sizeof(LSN_PREFIX_IN_SHOW_STATUS) - 1; - return (lsn_t)strtoll(p, NULL, 10); +static lsn_t get_current_lsn(MYSQL *connection) +{ + static const char lsn_prefix[] = "\nLog sequence number "; + lsn_t lsn = 0; + if (MYSQL_RES *res = xb_mysql_query(connection, + "SHOW ENGINE INNODB STATUS", + true, false)) { + if (MYSQL_ROW row = mysql_fetch_row(res)) { + if (const char *p = strstr(row[2], lsn_prefix)) { + p += sizeof lsn_prefix - 1; + lsn = lsn_t(strtoll(p, NULL, 10)); + } } + mysql_free_result(res); } - mysql_free_result(res); - return 0; + return lsn; } lsn_t server_lsn_after_lock; diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index efa21965965..aa9200f42fd 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -916,6 +916,7 @@ DECLARE_THREAD(kill_mdl_waiters_thread(void *)) exit(EXIT_FAILURE); } } + mysql_free_result(result); } mysql_close(mysql); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index a5a4553214a..b046f70510b 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -523,7 +523,9 @@ static os_event_t dbug_start_query_thread( mysql_thread_id(par->con), wait_state); for (;;) { MYSQL_RES *result = xb_mysql_query(mysql_connection,q, true, true); - if (mysql_fetch_row(result)) { + bool exists = mysql_fetch_row(result) != NULL; + mysql_free_result(result); + if (exists) { goto end; } msg_ts("Waiting for query '%s' on connection %lu to " @@ -578,7 +580,9 @@ std::string filename_to_spacename(const byte *filename, size_t len) char *db = strrchr(f, '/'); ut_a(db); *table = '/'; - return std::string(db+1); + std::string s(db+1); + free(f); + return s; } /** Report an operation to create, delete, or rename a file during backup. @@ -4164,7 +4168,6 @@ fail: /* start back ground thread to copy newer log */ os_thread_id_t log_copying_thread_id; - datafiles_iter_t *it; /* get current checkpoint_lsn */ /* Look for the latest checkpoint from any of the log groups */ @@ -4322,7 +4325,7 @@ fail_before_log_copying_thread_start: "Waiting for table metadata lock", 1, ER_QUERY_INTERRUPTED);); } - it = datafiles_iter_new(fil_system); + datafiles_iter_t *it = datafiles_iter_new(fil_system); if (it == NULL) { msg("mariabackup: Error: datafiles_iter_new() failed.\n"); goto fail; @@ -4531,7 +4534,7 @@ void backup_fix_ddl(void) fil_space_close(n->space->name); fil_space_free(n->space->id, false); } - + datafiles_iter_free(it); for (std::set<std::string>::iterator iter = new_tables.begin(); iter != new_tables.end(); iter++) { @@ -4578,6 +4581,8 @@ void backup_fix_ddl(void) #endif xtrabackup_copy_datafile(node, 0, dest_name.c_str()/*, do_full_copy ? ULONGLONG_MAX:UNIV_PAGE_SIZE */); } + + datafiles_iter_free(it); } /* ================= prepare ================= */ |