diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-03-22 18:02:40 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-03-22 18:02:40 +0200 |
commit | e80a842000cf42095b1bde4fb1449e709ed51b84 (patch) | |
tree | d6742633326e04a1ac7a36a1bab3693fd6e112c6 /extra | |
parent | 2fb31821deb98d4324b1555ff5ede21feba77f6c (diff) | |
parent | 0cba2c1ccb28bd9ef65926f3c91d5f6cc9f08cf9 (diff) | |
download | mariadb-git-e80a842000cf42095b1bde4fb1449e709ed51b84.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/common.h | 4 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 83 |
2 files changed, 86 insertions, 1 deletions
diff --git a/extra/mariabackup/common.h b/extra/mariabackup/common.h index 4d73742af49..fae466adc97 100644 --- a/extra/mariabackup/common.h +++ b/extra/mariabackup/common.h @@ -28,7 +28,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include <my_sys.h> -# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open) +/** Determine if (i) is a user tablespace id or not. */ +# define fil_is_user_tablespace_id(i) (i != 0 \ + && !srv_is_undo_tablespace(i)) #ifdef _MSC_VER #define stat _stati64 diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 78c0ae7d944..8318485fa2f 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2939,6 +2939,83 @@ next_datadir_item: return(err); } +/** Assign srv_undo_space_id_start variable if there are undo tablespace present. +Read the TRX_SYS page from ibdata1 file and get the minimum space id from +the first slot rollback segments of TRX_SYS_PAGE_NO. +@retval DB_ERROR if file open or page read failed. +@retval DB_SUCCESS if srv_undo_space_id assigned successfully. */ +static dberr_t xb_assign_undo_space_start() +{ + ulint dirnamelen; + char name[1000]; + pfs_os_file_t file; + byte* buf; + byte* page; + bool ret; + dberr_t error = DB_SUCCESS; + ulint space, page_no; + + if (srv_undo_tablespaces == 0) { + return error; + } + + os_normalize_path(srv_data_home); + dirnamelen = strlen(srv_data_home); + memcpy(name, srv_data_home, dirnamelen); + + if (dirnamelen && name[dirnamelen - 1] != OS_PATH_SEPARATOR) { + name[dirnamelen++] = OS_PATH_SEPARATOR; + } + + snprintf(name + dirnamelen, strlen(name) + strlen("ibdata1"), + "%s", "ibdata1"); + + file = os_file_create(0, name, OS_FILE_OPEN, + OS_FILE_NORMAL, OS_DATA_FILE, true, &ret); + + if (!ret) { + msg("mariabackup: Error in opening %s\n", name); + return DB_ERROR; + } + + buf = static_cast<byte*>(ut_malloc_nokey(2 * UNIV_PAGE_SIZE)); + page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE)); + +retry: + if (!os_file_read(IORequestRead, file, page, TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE, + UNIV_PAGE_SIZE)) { + msg("mariabackup: Reading TRX_SYS page failed.\n"); + error = DB_ERROR; + goto func_exit; + } + + /* TRX_SYS page can't be compressed or encrypted. */ + if (buf_page_is_corrupted(false, page, univ_page_size)) { + goto retry; + } + + /* 0th slot always points to system tablespace. + 1st slot should point to first undotablespace which is minimum. */ + + page_no = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS + + TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_PAGE_NO + page, MLOG_4BYTES); + ut_ad(page_no != FIL_NULL); + + space = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS + + TRX_SYS_RSEG_SLOT_SIZE + + TRX_SYS_RSEG_SPACE + page, MLOG_4BYTES); + + srv_undo_space_id_start = space; + +func_exit: + ut_free(buf); + ret = os_file_close(file); + ut_a(ret); + + return error; +} + /**************************************************************************** Populates the tablespace memory cache by scanning for and opening data files. @returns DB_SUCCESS or error code.*/ @@ -2973,6 +3050,12 @@ xb_load_tablespaces() /* Add separate undo tablespaces to fil_system */ + err = xb_assign_undo_space_start(); + + if (err != DB_SUCCESS) { + return err; + } + err = srv_undo_tablespaces_init(false); if (err != DB_SUCCESS) { |