From 477285c8ead70d78e69faf3052401e09a38238c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 12 May 2023 14:57:14 +0300 Subject: [PATCH 1/6] MDEV-31253 Freed data pages are not always being scrubbed fil_space_t::flush_freed(): Renamed from buf_flush_freed_pages(); this is a backport of aa45850687409ba857eb3a0eb19e7ccc28dc02f7 from 10.6. Invoke log_write_up_to() on last_freed_lsn, instead of avoiding the operation when the log has not yet been written. A more costly alternative would be that log_checkpoint() would invoke this function on every affected tablespace. --- storage/innobase/buf/buf0flu.cc | 58 +++++++++++++++--------------- storage/innobase/buf/buf0rea.cc | 9 ++++- storage/innobase/include/fil0fil.h | 26 ++++++++------ 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 36ea302a403..ce75f95602c 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1042,63 +1042,65 @@ static page_id_t buf_flush_check_neighbors(const fil_space_t &space, return i; } -MY_ATTRIBUTE((nonnull, warn_unused_result)) -/** Write punch-hole or zeroes of the freed ranges when -innodb_immediate_scrub_data_uncompressed from the freed ranges. -@param space tablespace which may contain ranges of freed pages -@param writable whether the tablespace is writable +MY_ATTRIBUTE((warn_unused_result)) +/** Apply freed_ranges to the file. +@param writable whether the file is writable @return number of pages written or hole-punched */ -static uint32_t buf_flush_freed_pages(fil_space_t *space, bool writable) +uint32_t fil_space_t::flush_freed(bool writable) { - const bool punch_hole= space->punch_hole; if (!punch_hole && !srv_immediate_scrub_data_uncompressed) return 0; mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex); mysql_mutex_assert_not_owner(&buf_pool.mutex); - space->freed_range_mutex.lock(); - if (space->freed_ranges.empty() || - log_sys.get_flushed_lsn() < space->get_last_freed_lsn()) + for (;;) { - space->freed_range_mutex.unlock(); - return 0; + freed_range_mutex.lock(); + if (freed_ranges.empty()) + { + freed_range_mutex.unlock(); + return 0; + } + const lsn_t flush_lsn= last_freed_lsn; + if (log_sys.get_flushed_lsn() >= flush_lsn) + break; + freed_range_mutex.unlock(); + log_write_up_to(flush_lsn, true); } - const unsigned physical_size{space->physical_size()}; + const unsigned physical{physical_size()}; - range_set freed_ranges= std::move(space->freed_ranges); + range_set freed= std::move(freed_ranges); uint32_t written= 0; if (!writable); else if (punch_hole) { - for (const auto &range : freed_ranges) + for (const auto &range : freed) { written+= range.last - range.first + 1; - space->reacquire(); - space->io(IORequest(IORequest::PUNCH_RANGE), - os_offset_t{range.first} * physical_size, - (range.last - range.first + 1) * physical_size, - nullptr); + reacquire(); + io(IORequest(IORequest::PUNCH_RANGE), + os_offset_t{range.first} * physical, + (range.last - range.first + 1) * physical, nullptr); } } else { - for (const auto &range : freed_ranges) + for (const auto &range : freed) { written+= range.last - range.first + 1; for (os_offset_t i= range.first; i <= range.last; i++) { - space->reacquire(); - space->io(IORequest(IORequest::WRITE_ASYNC), - i * physical_size, physical_size, - const_cast(field_ref_zero)); + reacquire(); + io(IORequest(IORequest::WRITE_ASYNC), i * physical, physical, + const_cast(field_ref_zero)); } } } - space->freed_range_mutex.unlock(); + freed_range_mutex.unlock(); return written; } @@ -1225,7 +1227,7 @@ static ulint buf_free_from_unzip_LRU_list_batch(ulint max) static std::pair buf_flush_space(const uint32_t id) { if (fil_space_t *space= fil_space_t::get(id)) - return {space, buf_flush_freed_pages(space, true)}; + return {space, space->flush_freed(true)}; return {nullptr, 0}; } @@ -1617,7 +1619,7 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed) bool acquired= space->acquire(); { - const uint32_t written{buf_flush_freed_pages(space, acquired)}; + const uint32_t written{space->flush_freed(acquired)}; mysql_mutex_lock(&buf_pool.mutex); if (written) buf_pool.stat.n_pages_written+= written; diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 26a84939306..97bfd6f64ec 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -728,6 +728,13 @@ failed: return count; } +/** @return whether a page has been freed */ +inline bool fil_space_t::is_freed(uint32_t page) +{ + std::lock_guard freed_lock(freed_range_mutex); + return freed_ranges.contains(page); +} + /** Issues read requests for pages which recovery wants to read in. @param[in] space_id tablespace id @param[in] page_nos array of page numbers to read, with the @@ -747,7 +754,7 @@ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n) for (ulint i = 0; i < n; i++) { /* Ignore if the page already present in freed ranges. */ - if (space->freed_ranges.contains(page_nos[i])) { + if (space->is_freed(page_nos[i])) { continue; } diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 385d547a060..10365d167b7 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -415,16 +415,16 @@ public: punch hole */ bool punch_hole; - /** mutex to protect freed ranges */ - std::mutex freed_range_mutex; +private: + /** mutex to protect freed_ranges and last_freed_lsn */ + std::mutex freed_range_mutex; - /** Variables to store freed ranges. This can be used to write - zeroes/punch the hole in files. Protected by freed_mutex */ - range_set freed_ranges; - - /** Stores last page freed lsn. Protected by freed_mutex */ - lsn_t last_freed_lsn; + /** Ranges of freed page numbers; protected by freed_range_mutex */ + range_set freed_ranges; + /** LSN of freeing last page; protected by freed_range_mutex */ + lsn_t last_freed_lsn; +public: ulint magic_n;/*!< FIL_SPACE_MAGIC_N */ /** @return whether doublewrite buffering is needed */ @@ -434,6 +434,14 @@ public: buf_dblwr.is_initialised(); } + /** @return whether a page has been freed */ + inline bool is_freed(uint32_t page); + + /** Apply freed_ranges to the file. + @param writable whether the file is writable + @return number of pages written or hole-punched */ + uint32_t flush_freed(bool writable); + /** Append a file to the chain of files of a space. @param[in] name file name of a file that is not open @param[in] handle file handle, or OS_FILE_CLOSED @@ -589,8 +597,6 @@ public: /** Close all tablespace files at shutdown */ static void close_all(); - /** @return last_freed_lsn */ - lsn_t get_last_freed_lsn() { return last_freed_lsn; } /** Update last_freed_lsn */ void update_last_freed_lsn(lsn_t lsn) { From c9eff1a144ba44846373660a30d342d3f0dc91a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 12 May 2023 15:04:50 +0300 Subject: [PATCH 2/6] MDEV-31254 InnoDB: Trying to read doublewrite buffer page buf_read_page_low(): Remove an error message and a debug assertion that can be triggered when using innodb_page_size=4k and innodb_file_per_table=0. In that case, buf_read_ahead_linear() may be invoked on page 255, which is one less than the first page of the doublewrite buffer (256). --- storage/innobase/buf/buf0rea.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 97bfd6f64ec..822c424fe46 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -280,9 +280,7 @@ buf_read_page_low( *err = DB_SUCCESS; if (buf_dblwr.is_inside(page_id)) { - ib::error() << "Trying to read doublewrite buffer page " - << page_id; - ut_ad(0); + *err = DB_CORRUPTION; nothing_read: space->release(); return false; From f522b0f2303e5556e3fc98c50cdc7999f6f5834a Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Wed, 10 May 2023 11:57:48 +0300 Subject: [PATCH 3/6] MDEV-30951: Fix small perlcritic and enable modern Perl Add Modern Perl headers. Perl 5.16 is still fairly old from 2012. Enable UTF-8, warnings and make script 'strict' Small fixes for perlcritic reported problems and some crashes I/O layer ":utf8" used at line 268, column 16. Use ":encoding(UTF-8)" to get strict validation. (Severity: 5) "return" statement with explicit "undef" at line 806, column 4. See page 199 of PBP. (Severity: 5) "return" statement with explicit "undef" at line 6844, column 4. See page 199 of PBP. (Severity: 5) "return" statement with explicit "undef" at line 7524, column 4. See page 199 of PBP. (Severity: 5) "return" statement with explicit "undef" at line 7527, column 4. See page 199 of PBP. (Severity: 5) "return" statement with explicit "undef" at line 7599, column 4. See page 199 of PBP. (Severity: 5) "return" statement with explicit "undef" at line 7602, column 4. See page 199 of PBP. (Severity: 5) Expression form of "eval" at line 7784, column 4. See page 161 of PBP. (Severity: 5) Expression form of "eval" at line 7806, column 4. See page 161 of PBP. (Severity: 5) Glob written as <...> at line 8016, column 25. See page 167 of PBP. (Severity: 5) "return" statement followed by "sort" at line 9195, column 60. Behavior is undefined if called in scalar context. (Severity: 5) Expression form of "eval" at line 9846, column 10. See page 161 of PBP. (Severity: 5) --- debian/additions/innotop/innotop | 35 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) mode change 100644 => 100755 debian/additions/innotop/innotop diff --git a/debian/additions/innotop/innotop b/debian/additions/innotop/innotop old mode 100644 new mode 100755 index 2bc090917fe..8e5a41768eb --- a/debian/additions/innotop/innotop +++ b/debian/additions/innotop/innotop @@ -20,6 +20,9 @@ # Street, Fifth Floor, Boston, MA 02110-1335 USA use strict; +use warnings; +use utf8; +use feature ':5.16'; use warnings FATAL => 'all'; our $VERSION = '1.11.4'; @@ -265,7 +268,7 @@ sub get_dbh { $dbh->do($sql); MKDEBUG && _d('Enabling charset for STDOUT'); if ( $charset eq 'utf8' ) { - binmode(STDOUT, ':utf8') + binmode(STDOUT, ':encoding(UTF-8)') or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR"; } else { @@ -612,6 +615,9 @@ sub ts_to_string { sub parse_innodb_timestamp { my $text = shift; + if ( ! defined $text ) { + return (0, 0, 0, 0, 0, 0); + } my ( $y, $m, $d, $h, $i, $s ) = $text =~ m/^(\d\d)(\d\d)(\d\d) +(\d+):(\d+):(\d+)$/; die("Can't get timestamp from $text\n") unless $y; @@ -803,7 +809,8 @@ sub parse_fk_transaction_error { # TODO: write some tests for this sub parse_innodb_record_dump { my ( $dump, $complete, $debug ) = @_; - return undef unless $dump; + # Use bare return as recommend in page 199 of PBP + return unless $dump; my $result = {}; @@ -6769,6 +6776,9 @@ sub set_precision { my ( $num, $precision ) = @_; $num = 0 unless defined $num; $precision = $config{num_digits}->{val} if !defined $precision; + if ( $num eq "" ) { + $num = int(0); + } sprintf("%.${precision}f", $num); } @@ -6777,6 +6787,9 @@ sub set_precision { sub percent { my ( $num ) = @_; $num = 0 unless defined $num; + if ( $num eq "" ) { + $num = int(0); + } my $digits = $config{num_digits}->{val}; return sprintf("%.${digits}f", $num * 100) . ($config{show_percent}->{val} ? '%' : ''); @@ -6841,7 +6854,7 @@ sub make_color_func { push @criteria, "( defined \$set->{$spec->{col}} && \$set->{$spec->{col}} $spec->{op} $val ) { return '$spec->{color}'; }"; } - return undef unless @criteria; + return unless @criteria; my $sub = eval 'sub { my ( $set ) = @_; if ' . join(" elsif ", @criteria) . '}'; die if $EVAL_ERROR; return $sub; @@ -7521,10 +7534,10 @@ sub choose_connections { sub do_stmt { my ( $cxn, $stmt_name, @args ) = @_; - return undef if $file; + return if $file; # Test if the cxn should not even be tried - return undef if $dbhs{$cxn} + return if $dbhs{$cxn} && $dbhs{$cxn}->{failed} && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} ); @@ -7596,10 +7609,10 @@ sub handle_cxn_error { sub do_query { my ( $cxn, $query ) = @_; - return undef if $file; + return if $file; # Test if the cxn should not even be tried - return undef if $dbhs{$cxn} + return if $dbhs{$cxn} && $dbhs{$cxn}->{failed} && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} ); @@ -7781,7 +7794,7 @@ sub compile_select_stmt { sub compile_filter { my ( $text ) = @_; my ( $sub, $err ); - eval "\$sub = sub { my \$set = shift; $text }"; + eval { $sub = sub { my $set = shift; $text } }; if ( $EVAL_ERROR ) { $EVAL_ERROR =~ s/at \(eval.*$//; $sub = sub { return $EVAL_ERROR }; @@ -8013,7 +8026,7 @@ sub load_config_plugins { # First, find a list of all plugins that exist on disk, and get information about them. my $dir = $config{plugin_dir}->{val}; - foreach my $p_file ( <$dir/*.pm> ) { + foreach my $p_file (glob($dir."/*.pm")) { my ($package, $desc); eval { open my $p_in, "<", $p_file or die $OS_ERROR; @@ -9192,7 +9205,7 @@ sub switch_var_set { # edit_stmt_sleep_times {{{3 sub edit_stmt_sleep_times { $clear_screen_sub->(); - my $stmt = prompt_list('Specify a statement', '', sub { return sort keys %stmt_maker_for }); + my $stmt = prompt_list('Specify a statement', '', sub { my @tmparray = sort keys %stmt_maker_for; return @tmparray }); return unless $stmt && exists $stmt_maker_for{$stmt}; $clear_screen_sub->(); my $curr_val = $stmt_sleep_time_for{$stmt} || 0; @@ -9843,7 +9856,7 @@ sub get_slave_status { sub is_func { my ( $word ) = @_; return defined(&$word) - || eval "my \$x= sub { $word }; 1" + || eval { my $x = sub { $word }; 1 } || $EVAL_ERROR !~ m/^Bareword/; } From caeff1357939daa708f7e68d51ab5ded2a929b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Mon, 15 May 2023 23:32:30 -0700 Subject: [PATCH 4/6] Remove CODEOWNERS as obsolete The CODEOWNERS was added almost 3 years ago but never saw any adoption. Only one person used it (me) to mark what files I maintain and for which I wish to review commits. No other maintainers or code paths were added, so clean it away for clarity. --- .github/CODEOWNERS | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 538007ed62d..00000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,2 +0,0 @@ -/debian @ottok - From e0084b9d315f10e3ceb578b65e144d751b208bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 May 2023 12:19:26 +0300 Subject: [PATCH 5/6] MDEV-31234 InnoDB does not free UNDO after the fix of MDEV-30671 trx_purge_truncate_history(): Only call trx_purge_truncate_rseg_history() if the rollback segment is safe to process. This will avoid leaking undo log pages that are not yet ready to be processed. This fixes a regression that was introduced in commit 0de3be8cfdfc26f5c236eaefe12d03c7b4af22c8 (MDEV-30671). trx_sys_t::any_active_transactions(): Separately count XA PREPARE transactions. srv_purge_should_exit(): Terminate slow shutdown if the history size does not change and XA PREPARE transactions exist in the system. This will avoid a hang of the test innodb.recovery_shutdown. Tested by: Matthias Leich --- storage/innobase/include/trx0sys.h | 2 +- storage/innobase/srv/srv0srv.cc | 41 ++++++++++++++++++------------ storage/innobase/trx/trx0purge.cc | 10 +++----- storage/innobase/trx/trx0sys.cc | 24 +++++++++++++---- 4 files changed, 48 insertions(+), 29 deletions(-) diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index e033a3e1fe4..016ac0b1363 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -1055,7 +1055,7 @@ public: void close(); /** @return total number of active (non-prepared) transactions */ - ulint any_active_transactions(); + size_t any_active_transactions(size_t *prepared= nullptr); /** diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 57aa4bef9fe..50569f810ea 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1697,7 +1697,7 @@ void srv_master_callback(void*) } /** @return whether purge should exit due to shutdown */ -static bool srv_purge_should_exit() +static bool srv_purge_should_exit(size_t old_history_size) { ut_ad(srv_shutdown_state <= SRV_SHUTDOWN_CLEANUP); @@ -1708,7 +1708,12 @@ static bool srv_purge_should_exit() return true; /* Slow shutdown was requested. */ - if (const size_t history_size= trx_sys.rseg_history_len) + size_t prepared, active= trx_sys.any_active_transactions(&prepared); + const size_t history_size= trx_sys.rseg_history_len; + + if (!history_size); + else if (!active && history_size == old_history_size && prepared); + else { static time_t progress_time; time_t now= time(NULL); @@ -1725,7 +1730,7 @@ static bool srv_purge_should_exit() return false; } - return !trx_sys.any_active_transactions(); + return !active; } /*********************************************************************//** @@ -1845,7 +1850,7 @@ static size_t srv_do_purge(ulint* n_total_purged) *n_total_purged += n_pages_purged; } while (n_pages_purged > 0 && !purge_sys.paused() - && !srv_purge_should_exit()); + && !srv_purge_should_exit(rseg_history_len)); return(rseg_history_len); } @@ -1960,7 +1965,7 @@ static void purge_coordinator_callback_low() } } while ((purge_sys.enabled() && !purge_sys.paused()) || - !srv_purge_should_exit()); + !srv_purge_should_exit(trx_sys.rseg_history_len)); } static void purge_coordinator_callback(void*) @@ -2031,15 +2036,19 @@ ulint srv_get_task_queue_length() /** Shut down the purge threads. */ void srv_purge_shutdown() { - if (purge_sys.enabled()) { - if (!srv_fast_shutdown && !opt_bootstrap) - srv_update_purge_thread_count(innodb_purge_threads_MAX); - while(!srv_purge_should_exit()) { - ut_a(!purge_sys.paused()); - srv_wake_purge_thread_if_not_active(); - purge_coordinator_task.wait(); - } - purge_sys.coordinator_shutdown(); - srv_shutdown_purge_tasks(); - } + if (purge_sys.enabled()) + { + if (!srv_fast_shutdown && !opt_bootstrap) + srv_update_purge_thread_count(innodb_purge_threads_MAX); + size_t history_size= trx_sys.rseg_history_len; + while (!srv_purge_should_exit(history_size)) + { + history_size= trx_sys.rseg_history_len; + ut_a(!purge_sys.paused()); + srv_wake_purge_thread_if_not_active(); + purge_coordinator_task.wait(); + } + purge_sys.coordinator_shutdown(); + srv_shutdown_purge_tasks(); + } } diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index b22a85f4646..97979a3fefe 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -448,12 +448,7 @@ func_exit: prev_hdr_addr.boffset = static_cast(prev_hdr_addr.boffset - TRX_UNDO_HISTORY_NODE); - if (!rseg.trx_ref_count - && rseg.needs_purge <= (purge_sys.head.trx_no - ? purge_sys.head.trx_no - : purge_sys.tail.trx_no) - && mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_STATE - + block->frame) + if (mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_STATE + block->frame) == TRX_UNDO_TO_PURGE && !mach_read_from_2(block->frame + hdr_addr.boffset + TRX_UNDO_NEXT_LOG)) { @@ -544,7 +539,8 @@ static void trx_purge_truncate_history() ut_ad(rseg->id == i); ut_ad(rseg->is_persistent()); mutex_enter(&rseg->mutex); - trx_purge_truncate_rseg_history(*rseg, head); + if (!rseg->trx_ref_count && rseg->needs_purge <= head.trx_no) + trx_purge_truncate_rseg_history(*rseg, head); mutex_exit(&rseg->mutex); } } diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index bcde969eb41..ab3de55db64 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -325,15 +325,29 @@ trx_sys_t::close() } /** @return total number of active (non-prepared) transactions */ -ulint trx_sys_t::any_active_transactions() +size_t trx_sys_t::any_active_transactions(size_t *prepared) { - uint32_t total_trx= 0; + size_t total_trx= 0, prepared_trx= 0; - trx_sys.trx_list.for_each([&total_trx](const trx_t &trx) { - if (trx.state == TRX_STATE_COMMITTED_IN_MEMORY || - (trx.state == TRX_STATE_ACTIVE && trx.id)) + trx_sys.trx_list.for_each([&](const trx_t &trx) { + switch (trx.state) { + case TRX_STATE_NOT_STARTED: + break; + case TRX_STATE_ACTIVE: + if (!trx.id) + break; + /* fall through */ + case TRX_STATE_COMMITTED_IN_MEMORY: total_trx++; + break; + case TRX_STATE_PREPARED: + case TRX_STATE_PREPARED_RECOVERED: + prepared_trx++; + } }); + if (prepared) + *prepared= prepared_trx; + return total_trx; } From e5933b99d5dd25acceecafe5bdfefe016176f68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 May 2023 12:25:30 +0300 Subject: [PATCH 6/6] MDEV-31234 related cleanup trx_purge_free_segment(), trx_purge_truncate_rseg_history(): Replace some unreachable code with debug assertions. A buffer-fix does prevent pages from being evicted from the buffer pool; see buf_page_t::can_relocate(). Tested by: Matthias Leich --- storage/innobase/trx/trx0purge.cc | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 19504110c21..6541ede447e 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -378,7 +378,7 @@ static void trx_purge_free_segment(buf_block_t *block, mtr_t &mtr) block->page.frame, &mtr)) { block->fix(); - const page_id_t id{block->page.id()}; + ut_d(const page_id_t id{block->page.id()}); mtr.commit(); /* NOTE: If the server is killed after the log that was produced up to this point was written, and before the log from the mtr.commit() @@ -390,16 +390,8 @@ static void trx_purge_free_segment(buf_block_t *block, mtr_t &mtr) log_free_check(); mtr.start(); block->page.lock.x_lock(); - if (UNIV_UNLIKELY(block->page.id() != id)) - { - block->unfix(); - block->page.lock.x_unlock(); - block= buf_page_get_gen(id, 0, RW_X_LATCH, nullptr, BUF_GET, &mtr); - if (!block) - return; - } - else - mtr.memo_push(block, MTR_MEMO_PAGE_X_MODIFY); + ut_ad(block->page.id() == id); + mtr.memo_push(block, MTR_MEMO_PAGE_X_MODIFY); } while (!fseg_free_step(TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER + @@ -421,7 +413,6 @@ trx_purge_truncate_rseg_history(trx_rseg_t& rseg, mtr.start(); dberr_t err; -reget: buf_block_t *rseg_hdr= rseg.get(&mtr, &err); if (!rseg_hdr) { @@ -520,12 +511,7 @@ loop: log_free_check(); mtr.start(); rseg_hdr->page.lock.x_lock(); - if (UNIV_UNLIKELY(rseg_hdr->page.id() != rseg.page_id())) - { - rseg_hdr->unfix(); - rseg_hdr->page.lock.x_unlock(); - goto reget; - } + ut_ad(rseg_hdr->page.id() == rseg.page_id()); mtr.memo_push(rseg_hdr, MTR_MEMO_PAGE_X_MODIFY); goto loop;