Skip to content

Commit 167fe66

Browse files
committed
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>
1 parent e695337 commit 167fe66

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ uint opt_safe_slave_backup_timeout = 0;
421421

422422
const char *opt_history = NULL;
423423

424+
/* Whether xtrabackup_binlog_info should be created on recovery */
425+
static bool recover_binlog_info;
426+
424427

425428
char mariabackup_exe[FN_REFLEN];
426429
char orig_argv1[FN_REFLEN];
@@ -2340,6 +2343,7 @@ xtrabackup_read_metadata(char *filename)
23402343
{
23412344
FILE *fp;
23422345
my_bool r = TRUE;
2346+
int t;
23432347

23442348
fp = fopen(filename,"r");
23452349
if(!fp) {
@@ -2370,6 +2374,9 @@ xtrabackup_read_metadata(char *filename)
23702374
}
23712375
/* Optional fields */
23722376

2377+
if (fscanf(fp, "recover_binlog_info = %d\n", &t) == 1) {
2378+
recover_binlog_info = (t == 1);
2379+
}
23732380
end:
23742381
fclose(fp);
23752382

@@ -2388,11 +2395,13 @@ xtrabackup_print_metadata(char *buf, size_t buf_len)
23882395
"backup_type = %s\n"
23892396
"from_lsn = " UINT64PF "\n"
23902397
"to_lsn = " UINT64PF "\n"
2391-
"last_lsn = " UINT64PF "\n",
2398+
"last_lsn = " UINT64PF "\n"
2399+
"recover_binlog_info = %d\n",
23922400
metadata_type,
23932401
metadata_from_lsn,
23942402
metadata_to_lsn,
2395-
metadata_last_lsn);
2403+
metadata_last_lsn,
2404+
MY_TEST(opt_binlog_info == BINLOG_INFO_LOCKLESS));
23962405
}
23972406

23982407
/***********************************************************************
@@ -6036,6 +6045,26 @@ static ibool prepare_handle_del_files(const char *datadir, const char *db, const
60366045
return TRUE;
60376046
}
60386047

6048+
6049+
/**************************************************************************
6050+
Store the current binary log coordinates in a specified file.
6051+
@return 'false' on error. */
6052+
static bool
6053+
store_binlog_info(const char *filename, const char* name, ulonglong pos)
6054+
{
6055+
FILE *fp = fopen(filename, "w");
6056+
6057+
if (!fp) {
6058+
msg("mariabackup: failed to open '%s'\n", filename);
6059+
return(false);
6060+
}
6061+
6062+
fprintf(fp, "%s\t%llu\n", name, pos);
6063+
fclose(fp);
6064+
6065+
return(true);
6066+
}
6067+
60396068
/** Implement --prepare
60406069
@return whether the operation succeeded */
60416070
static bool xtrabackup_prepare_func(char** argv)
@@ -6275,6 +6304,20 @@ static bool xtrabackup_prepare_func(char** argv)
62756304
msg("Last binlog file %s, position %lld",
62766305
trx_sys.recovered_binlog_filename,
62776306
longlong(trx_sys.recovered_binlog_offset));
6307+
6308+
/* output to xtrabackup_binlog_pos_innodb and (if
6309+
backup_safe_binlog_info was available on the server) to
6310+
xtrabackup_binlog_info. In the latter case
6311+
xtrabackup_binlog_pos_innodb becomes redundant and is created
6312+
only for compatibility. */
6313+
ok = store_binlog_info(
6314+
"xtrabackup_binlog_pos_innodb",
6315+
trx_sys.recovered_binlog_filename,
6316+
trx_sys.recovered_binlog_offset)
6317+
&& (!recover_binlog_info || store_binlog_info(
6318+
XTRABACKUP_BINLOG_INFO,
6319+
trx_sys.recovered_binlog_filename,
6320+
trx_sys.recovered_binlog_offset));
62786321
}
62796322

62806323
/* Check whether the log is applied enough or not. */

extra/mariabackup/xtrabackup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ extern uint opt_safe_slave_backup_timeout;
171171

172172
extern const char *opt_history;
173173

174-
enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_ON,
174+
enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_LOCKLESS, BINLOG_INFO_ON,
175175
BINLOG_INFO_AUTO};
176176

177177
extern ulong opt_binlog_info;

0 commit comments

Comments
 (0)