MDEV-33980 mariadb-backup --backup is missing retry logic for undo tablespaces

- This is a merge of commit f378e764
from 10.4 to 10.5.
parent b88c20ce
...@@ -4264,15 +4264,7 @@ bool fil_node_t::read_page0() ...@@ -4264,15 +4264,7 @@ bool fil_node_t::read_page0()
} }
aligned_free(page); aligned_free(page);
DBUG_EXECUTE_IF("undo_space_read_fail",
if (space_id == srv_undo_space_id_start) {
goto wrong_space_id;
});
if (UNIV_UNLIKELY(space_id != space->id)) { if (UNIV_UNLIKELY(space_id != space->id)) {
#ifndef DBUG_OFF
wrong_space_id:
#endif
ib::error() << "Expected tablespace id " << space->id ib::error() << "Expected tablespace id " << space->id
<< " but found " << space_id << " but found " << space_id
<< " in the file " << name; << " in the file " << name;
......
...@@ -489,7 +489,6 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) ...@@ -489,7 +489,6 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
char undo_name[sizeof "innodb_undo000"]; char undo_name[sizeof "innodb_undo000"];
ulint space_id= 0; ulint space_id= 0;
ulint fsp_flags= 0; ulint fsp_flags= 0;
ulint n_retries= 5;
if (create) if (create)
{ {
...@@ -506,7 +505,6 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) ...@@ -506,7 +505,6 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
} }
} }
undo_retry:
pfs_os_file_t fh= os_file_create(innodb_data_file_key, name, OS_FILE_OPEN | pfs_os_file_t fh= os_file_create(innodb_data_file_key, name, OS_FILE_OPEN |
OS_FILE_ON_ERROR_NO_EXIT | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT, OS_FILE_ON_ERROR_SILENT,
...@@ -516,6 +514,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) ...@@ -516,6 +514,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
if (!success) if (!success)
return 0; return 0;
ulint n_retries = 5;
os_offset_t size= os_file_get_size(fh); os_offset_t size= os_file_get_size(fh);
ut_a(size != os_offset_t(-1)); ut_a(size != os_offset_t(-1));
...@@ -523,15 +522,25 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) ...@@ -523,15 +522,25 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
{ {
page_t *page= static_cast<byte*>(aligned_malloc(srv_page_size, page_t *page= static_cast<byte*>(aligned_malloc(srv_page_size,
srv_page_size)); srv_page_size));
undo_retry:
if (os_file_read(IORequestRead, fh, page, 0, srv_page_size) != if (os_file_read(IORequestRead, fh, page, 0, srv_page_size) !=
DB_SUCCESS) DB_SUCCESS)
{ {
err_exit: err_exit:
if (n_retries && srv_operation == SRV_OPERATION_BACKUP)
{
sql_print_information("InnoDB: Retrying to read undo "
"tablespace %s", name);
n_retries--;
goto undo_retry;
}
ib::error() << "Unable to read first page of file " << name; ib::error() << "Unable to read first page of file " << name;
aligned_free(page); aligned_free(page);
return ULINT_UNDEFINED; return ULINT_UNDEFINED;
} }
DBUG_EXECUTE_IF("undo_space_read_fail", goto err_exit;);
uint32_t id= mach_read_from_4(FIL_PAGE_SPACE_ID + page); uint32_t id= mach_read_from_4(FIL_PAGE_SPACE_ID + page);
if (id == 0 || id >= SRV_SPACE_ID_UPPER_BOUND || if (id == 0 || id >= SRV_SPACE_ID_UPPER_BOUND ||
memcmp_aligned<2>(FIL_PAGE_SPACE_ID + page, memcmp_aligned<2>(FIL_PAGE_SPACE_ID + page,
...@@ -576,7 +585,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) ...@@ -576,7 +585,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
space->set_sizes(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES); space->set_sizes(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES);
space->size= file->size= uint32_t(size >> srv_page_size_shift); space->size= file->size= uint32_t(size >> srv_page_size_shift);
} }
else if (!(success = file->read_page0())) else if (!file->read_page0())
{ {
os_file_close(file->handle); os_file_close(file->handle);
file->handle= OS_FILE_CLOSED; file->handle= OS_FILE_CLOSED;
...@@ -585,18 +594,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) ...@@ -585,18 +594,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
} }
mutex_exit(&fil_system.mutex); mutex_exit(&fil_system.mutex);
return space_id;
if (!success && n_retries &&
srv_operation == SRV_OPERATION_BACKUP)
{
sql_print_information("InnoDB: Retrying to read undo "
"tablespace %s", undo_name);
fil_space_free(space_id, false);
n_retries--;
goto undo_retry;
}
return success ? space_id : ULINT_UNDEFINED;
} }
/** Check if undo tablespaces and redo log files exist before creating a /** Check if undo tablespaces and redo log files exist before creating a
......
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