summaryrefslogtreecommitdiffstats
path: root/extra/mariabackup/wsrep.cc
diff options
context:
space:
mode:
Diffstat (limited to 'extra/mariabackup/wsrep.cc')
-rw-r--r--extra/mariabackup/wsrep.cc48
1 files changed, 38 insertions, 10 deletions
diff --git a/extra/mariabackup/wsrep.cc b/extra/mariabackup/wsrep.cc
index acaf5c50..15463a85 100644
--- a/extra/mariabackup/wsrep.cc
+++ b/extra/mariabackup/wsrep.cc
@@ -55,6 +55,9 @@ permission notice:
#define XB_GALERA_INFO_FILENAME "xtrabackup_galera_info"
#define XB_GALERA_DONOR_INFO_FILENAME "donor_galera_info"
+/* backup copy of galera info file as sent by donor */
+#define XB_GALERA_INFO_FILENAME_SST "xtrabackup_galera_info_SST"
+
/***********************************************************************
Store Galera checkpoint info in the 'xtrabackup_galera_info' file, if that
information is present in the trx system header. Otherwise, do nothing. */
@@ -68,21 +71,47 @@ xb_write_galera_info(bool incremental_prepare)
long long seqno;
MY_STAT statinfo;
- /* Do not overwrite an existing file to be compatible with
- servers with older server versions */
- if (!incremental_prepare &&
- my_stat(XB_GALERA_INFO_FILENAME, &statinfo, MYF(0)) != NULL) {
-
- return;
- }
-
xid.null();
+ /* try to read last wsrep XID from innodb rsegs, we will use it
+ instead of galera info file received from donor
+ */
if (!trx_rseg_read_wsrep_checkpoint(xid)) {
-
+ /* no worries yet, SST may have brought in galera info file
+ from some old MariaDB version, which does not support
+ wsrep XID storing in innodb rsegs
+ */
return;
}
+ /* if SST brought in galera info file, copy it as *_SST file
+ this will not be used, saved just for future reference
+ */
+ if (my_stat(XB_GALERA_INFO_FILENAME, &statinfo, MYF(0)) != NULL) {
+ FILE* fp_in = fopen(XB_GALERA_INFO_FILENAME, "r");
+ FILE* fp_out = fopen(XB_GALERA_INFO_FILENAME_SST, "w");
+
+ char buf[BUFSIZ] = {'\0'};
+ size_t size;
+ while ((size = fread(buf, 1, BUFSIZ, fp_in))) {
+ if (fwrite(buf, 1, size, fp_out) != strlen(buf)) {
+ die(
+ "could not write to "
+ XB_GALERA_INFO_FILENAME_SST
+ ", errno = %d\n",
+ errno);
+ }
+ }
+ if (!feof(fp_in)) {
+ die(
+ XB_GALERA_INFO_FILENAME_SST
+ " not fully copied\n"
+ );
+ }
+ fclose(fp_out);
+ fclose(fp_in);
+ }
+
wsrep_uuid_t uuid;
memcpy(uuid.data, wsrep_xid_uuid(&xid), sizeof(uuid.data));
if (wsrep_uuid_print(&uuid, uuid_str,
@@ -97,7 +126,6 @@ xb_write_galera_info(bool incremental_prepare)
"could not create " XB_GALERA_INFO_FILENAME
", errno = %d\n",
errno);
- exit(EXIT_FAILURE);
}
seqno = wsrep_xid_seqno(&xid);