mirror of
https://github.com/MariaDB/server.git
synced 2026-04-19 06:45:32 +02:00
Restore getting InnoDB position from mariabackup --no-lock
Revert the patch for MDEV-18917, which removed this functionality. This restores that mariabackup --prepare recovers the transactional binlog position from the redo log, and writes it to the file xtrabackup_binlog_pos_innodb. This position is updated only on every InnoDB commit. This means that if the last event in the binlog at the time of backup is a DDL or non-transactional update, the recovered position from --no-lock will be behind the state of the backup. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
parent
e695337448
commit
167fe6646d
2 changed files with 46 additions and 3 deletions
|
|
@ -421,6 +421,9 @@ uint opt_safe_slave_backup_timeout = 0;
|
|||
|
||||
const char *opt_history = NULL;
|
||||
|
||||
/* Whether xtrabackup_binlog_info should be created on recovery */
|
||||
static bool recover_binlog_info;
|
||||
|
||||
|
||||
char mariabackup_exe[FN_REFLEN];
|
||||
char orig_argv1[FN_REFLEN];
|
||||
|
|
@ -2340,6 +2343,7 @@ xtrabackup_read_metadata(char *filename)
|
|||
{
|
||||
FILE *fp;
|
||||
my_bool r = TRUE;
|
||||
int t;
|
||||
|
||||
fp = fopen(filename,"r");
|
||||
if(!fp) {
|
||||
|
|
@ -2370,6 +2374,9 @@ xtrabackup_read_metadata(char *filename)
|
|||
}
|
||||
/* Optional fields */
|
||||
|
||||
if (fscanf(fp, "recover_binlog_info = %d\n", &t) == 1) {
|
||||
recover_binlog_info = (t == 1);
|
||||
}
|
||||
end:
|
||||
fclose(fp);
|
||||
|
||||
|
|
@ -2388,11 +2395,13 @@ xtrabackup_print_metadata(char *buf, size_t buf_len)
|
|||
"backup_type = %s\n"
|
||||
"from_lsn = " UINT64PF "\n"
|
||||
"to_lsn = " UINT64PF "\n"
|
||||
"last_lsn = " UINT64PF "\n",
|
||||
"last_lsn = " UINT64PF "\n"
|
||||
"recover_binlog_info = %d\n",
|
||||
metadata_type,
|
||||
metadata_from_lsn,
|
||||
metadata_to_lsn,
|
||||
metadata_last_lsn);
|
||||
metadata_last_lsn,
|
||||
MY_TEST(opt_binlog_info == BINLOG_INFO_LOCKLESS));
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
@ -6036,6 +6045,26 @@ static ibool prepare_handle_del_files(const char *datadir, const char *db, const
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
Store the current binary log coordinates in a specified file.
|
||||
@return 'false' on error. */
|
||||
static bool
|
||||
store_binlog_info(const char *filename, const char* name, ulonglong pos)
|
||||
{
|
||||
FILE *fp = fopen(filename, "w");
|
||||
|
||||
if (!fp) {
|
||||
msg("mariabackup: failed to open '%s'\n", filename);
|
||||
return(false);
|
||||
}
|
||||
|
||||
fprintf(fp, "%s\t%llu\n", name, pos);
|
||||
fclose(fp);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/** Implement --prepare
|
||||
@return whether the operation succeeded */
|
||||
static bool xtrabackup_prepare_func(char** argv)
|
||||
|
|
@ -6275,6 +6304,20 @@ static bool xtrabackup_prepare_func(char** argv)
|
|||
msg("Last binlog file %s, position %lld",
|
||||
trx_sys.recovered_binlog_filename,
|
||||
longlong(trx_sys.recovered_binlog_offset));
|
||||
|
||||
/* output to xtrabackup_binlog_pos_innodb and (if
|
||||
backup_safe_binlog_info was available on the server) to
|
||||
xtrabackup_binlog_info. In the latter case
|
||||
xtrabackup_binlog_pos_innodb becomes redundant and is created
|
||||
only for compatibility. */
|
||||
ok = store_binlog_info(
|
||||
"xtrabackup_binlog_pos_innodb",
|
||||
trx_sys.recovered_binlog_filename,
|
||||
trx_sys.recovered_binlog_offset)
|
||||
&& (!recover_binlog_info || store_binlog_info(
|
||||
XTRABACKUP_BINLOG_INFO,
|
||||
trx_sys.recovered_binlog_filename,
|
||||
trx_sys.recovered_binlog_offset));
|
||||
}
|
||||
|
||||
/* Check whether the log is applied enough or not. */
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ extern uint opt_safe_slave_backup_timeout;
|
|||
|
||||
extern const char *opt_history;
|
||||
|
||||
enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_ON,
|
||||
enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_LOCKLESS, BINLOG_INFO_ON,
|
||||
BINLOG_INFO_AUTO};
|
||||
|
||||
extern ulong opt_binlog_info;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue