@@ -51,6 +51,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA
5151#include < my_getopt.h>
5252#include < mysql_com.h>
5353#include < my_default.h>
54+ #include < scope.h>
5455#include < sql_class.h>
5556
5657#include < fcntl.h>
@@ -4603,13 +4604,6 @@ static bool xtrabackup_backup_func()
46034604}
46044605
46054606
4606- if (auto b = aligned_malloc (UNIV_PAGE_SIZE_MAX, 4096 )) {
4607- field_ref_zero = static_cast <byte*>(
4608- memset_aligned<4096 >(b, 0 , UNIV_PAGE_SIZE_MAX));
4609- } else {
4610- goto fail;
4611- }
4612-
46134607 {
46144608/* definition from recv_recovery_from_checkpoint_start() */
46154609ulint max_cp_field;
@@ -4626,10 +4620,6 @@ static bool xtrabackup_backup_func()
46264620msg (" Error: cannot read redo log header" );
46274621unlock_and_fail:
46284622mysql_mutex_unlock (&log_sys.mutex );
4629- free_and_fail:
4630- aligned_free (const_cast <byte*>(field_ref_zero));
4631- field_ref_zero = nullptr ;
4632- goto fail;
46334623}
46344624
46354625if (log_sys.log .format == 0 ) {
@@ -4655,7 +4645,7 @@ static bool xtrabackup_backup_func()
46554645xtrabackup_init_datasinks ();
46564646
46574647if (!select_history ()) {
4658- goto free_and_fail ;
4648+ goto fail ;
46594649}
46604650
46614651/* open the log file */
@@ -4664,7 +4654,7 @@ static bool xtrabackup_backup_func()
46644654if (dst_log_file == NULL ) {
46654655msg (" Error: failed to open the target stream for '%s'." ,
46664656 LOG_FILE_NAME);
4667- goto free_and_fail ;
4657+ goto fail ;
46684658}
46694659
46704660/* label it */
@@ -4702,7 +4692,7 @@ static bool xtrabackup_backup_func()
47024692if (ds_write (dst_log_file, log_hdr_buf, LOG_FILE_HDR_SIZE)) {
47034693msg (" error: write to logfile failed" );
47044694aligned_free (log_hdr_buf);
4705- goto free_and_fail ;
4695+ goto fail ;
47064696}
47074697
47084698aligned_free (log_hdr_buf);
@@ -4723,7 +4713,7 @@ static bool xtrabackup_backup_func()
47234713 " error %s." , ut_strerr (err));
47244714fail_before_log_copying_thread_start:
47254715log_copying_running = false ;
4726- goto free_and_fail ;
4716+ goto fail ;
47274717}
47284718
47294719/* copy log file by current position */
@@ -4746,7 +4736,7 @@ static bool xtrabackup_backup_func()
47464736
47474737/* FLUSH CHANGED_PAGE_BITMAPS call */
47484738if (!flush_changed_page_bitmaps ()) {
4749- goto free_and_fail ;
4739+ goto fail ;
47504740}
47514741
47524742ut_a (xtrabackup_parallel > 0 );
@@ -4814,9 +4804,6 @@ static bool xtrabackup_backup_func()
48144804if (opt_log_innodb_page_corruption)
48154805ok = corrupted_pages.print_to_file (MB_CORRUPTED_PAGES_FILE);
48164806
4817- aligned_free (const_cast <byte*>(field_ref_zero));
4818- field_ref_zero = nullptr ;
4819-
48204807if (!ok) {
48214808goto fail;
48224809}
@@ -7004,6 +6991,20 @@ static int main_low(char** argv)
70046991}
70056992}
70066993
6994+ ut_ad (!field_ref_zero);
6995+ if (auto b = aligned_malloc (UNIV_PAGE_SIZE_MAX, 4096 )) {
6996+ field_ref_zero = static_cast <byte*>(
6997+ memset_aligned<4096 >(b, 0 , UNIV_PAGE_SIZE_MAX));
6998+ } else {
6999+ msg (" Can't allocate memory for field_ref_zero" );
7000+ return EXIT_FAILURE;
7001+ }
7002+
7003+ auto _ = make_scope_exit ([]() {
7004+ aligned_free (const_cast <byte*>(field_ref_zero));
7005+ field_ref_zero = nullptr ;
7006+ });
7007+
70077008/* --backup */
70087009if (xtrabackup_backup && !xtrabackup_backup_func ()) {
70097010return (EXIT_FAILURE);
0 commit comments