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)
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 @@ backup_files(const char *from, bool prep_mode)
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;
......
......@@ -916,6 +916,7 @@ DECLARE_THREAD(kill_mdl_waiters_thread(void *))
exit(EXIT_FAILURE);
}
}
mysql_free_result(result);
}
mysql_close(mysql);
......
......@@ -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 @@ xtrabackup_backup_func()
/* 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 @@ xtrabackup_backup_func()
"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 ================= */
......
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