Commit 8b6b2c3e authored by Marko Mäkelä's avatar Marko Mäkelä

Fix mariabackup leaks (except my_load_defaults)

parent 82675100
...@@ -1351,7 +1351,8 @@ backup_files(const char *from, bool prep_mode) ...@@ -1351,7 +1351,8 @@ backup_files(const char *from, bool prep_mode)
if (rsync_tmpfile == NULL) { if (rsync_tmpfile == NULL) {
msg("Error: can't open file %s\n", msg("Error: can't open file %s\n",
rsync_tmpfile_name); rsync_tmpfile_name);
return(false); ret = false;
goto out;
} }
while (fgets(path, sizeof(path), rsync_tmpfile)) { while (fgets(path, sizeof(path), rsync_tmpfile)) {
...@@ -1390,24 +1391,22 @@ backup_files(const char *from, bool prep_mode) ...@@ -1390,24 +1391,22 @@ backup_files(const char *from, bool prep_mode)
void backup_fix_ddl(void); void backup_fix_ddl(void);
#define LSN_PREFIX_IN_SHOW_STATUS "\nLog sequence number " static lsn_t get_current_lsn(MYSQL *connection)
static lsn_t get_current_lsn(MYSQL *connection) { {
MYSQL_RES *res = xb_mysql_query(connection, "SHOW ENGINE INNODB STATUS", true, false); static const char lsn_prefix[] = "\nLog sequence number ";
if (!res) lsn_t lsn = 0;
return 0; if (MYSQL_RES *res = xb_mysql_query(connection,
MYSQL_ROW row = mysql_fetch_row(res); "SHOW ENGINE INNODB STATUS",
DBUG_ASSERT(row); true, false)) {
if (row) { if (MYSQL_ROW row = mysql_fetch_row(res)) {
const char *p = strstr(row[2],LSN_PREFIX_IN_SHOW_STATUS); if (const char *p = strstr(row[2], lsn_prefix)) {
DBUG_ASSERT(p); p += sizeof lsn_prefix - 1;
if (p) lsn = lsn_t(strtoll(p, NULL, 10));
{ }
p += sizeof(LSN_PREFIX_IN_SHOW_STATUS) - 1;
return (lsn_t)strtoll(p, NULL, 10);
} }
mysql_free_result(res);
} }
mysql_free_result(res); return lsn;
return 0;
} }
lsn_t server_lsn_after_lock; lsn_t server_lsn_after_lock;
......
...@@ -916,6 +916,7 @@ DECLARE_THREAD(kill_mdl_waiters_thread(void *)) ...@@ -916,6 +916,7 @@ DECLARE_THREAD(kill_mdl_waiters_thread(void *))
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
mysql_free_result(result);
} }
mysql_close(mysql); mysql_close(mysql);
......
...@@ -523,7 +523,9 @@ static os_event_t dbug_start_query_thread( ...@@ -523,7 +523,9 @@ static os_event_t dbug_start_query_thread(
mysql_thread_id(par->con), wait_state); mysql_thread_id(par->con), wait_state);
for (;;) { for (;;) {
MYSQL_RES *result = xb_mysql_query(mysql_connection,q, true, true); 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; goto end;
} }
msg_ts("Waiting for query '%s' on connection %lu to " 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) ...@@ -578,7 +580,9 @@ std::string filename_to_spacename(const byte *filename, size_t len)
char *db = strrchr(f, '/'); char *db = strrchr(f, '/');
ut_a(db); ut_a(db);
*table = '/'; *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. /** Report an operation to create, delete, or rename a file during backup.
...@@ -4164,7 +4168,6 @@ xtrabackup_backup_func() ...@@ -4164,7 +4168,6 @@ xtrabackup_backup_func()
/* start back ground thread to copy newer log */ /* start back ground thread to copy newer log */
os_thread_id_t log_copying_thread_id; os_thread_id_t log_copying_thread_id;
datafiles_iter_t *it;
/* get current checkpoint_lsn */ /* get current checkpoint_lsn */
/* Look for the latest checkpoint from any of the log groups */ /* Look for the latest checkpoint from any of the log groups */
...@@ -4322,7 +4325,7 @@ xtrabackup_backup_func() ...@@ -4322,7 +4325,7 @@ xtrabackup_backup_func()
"Waiting for table metadata lock", 1, ER_QUERY_INTERRUPTED);); "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) { if (it == NULL) {
msg("mariabackup: Error: datafiles_iter_new() failed.\n"); msg("mariabackup: Error: datafiles_iter_new() failed.\n");
goto fail; goto fail;
...@@ -4531,7 +4534,7 @@ void backup_fix_ddl(void) ...@@ -4531,7 +4534,7 @@ void backup_fix_ddl(void)
fil_space_close(n->space->name); fil_space_close(n->space->name);
fil_space_free(n->space->id, false); fil_space_free(n->space->id, false);
} }
datafiles_iter_free(it);
for (std::set<std::string>::iterator iter = new_tables.begin(); for (std::set<std::string>::iterator iter = new_tables.begin();
iter != new_tables.end(); iter++) { iter != new_tables.end(); iter++) {
...@@ -4578,6 +4581,8 @@ void backup_fix_ddl(void) ...@@ -4578,6 +4581,8 @@ void backup_fix_ddl(void)
#endif #endif
xtrabackup_copy_datafile(node, 0, dest_name.c_str()/*, do_full_copy ? ULONGLONG_MAX:UNIV_PAGE_SIZE */); xtrabackup_copy_datafile(node, 0, dest_name.c_str()/*, do_full_copy ? ULONGLONG_MAX:UNIV_PAGE_SIZE */);
} }
datafiles_iter_free(it);
} }
/* ================= prepare ================= */ /* ================= prepare ================= */
......
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