Skip to content

Commit 2ec42f7

Browse files
committed
Merge 10.6 into 10.9
2 parents 3b34454 + 1fe830b commit 2ec42f7

File tree

9 files changed

+90
-82
lines changed

9 files changed

+90
-82
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
This file was deleted.

debian/additions/innotop/innotop

100644100755
Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# Street, Fifth Floor, Boston, MA 02110-1335 USA
2121

2222
use strict;
23+
use warnings;
24+
use utf8;
25+
use feature ':5.16';
2326
use warnings FATAL => 'all';
2427

2528
our $VERSION = '1.11.4';
@@ -265,7 +268,7 @@ sub get_dbh {
265268
$dbh->do($sql);
266269
MKDEBUG && _d('Enabling charset for STDOUT');
267270
if ( $charset eq 'utf8' ) {
268-
binmode(STDOUT, ':utf8')
271+
binmode(STDOUT, ':encoding(UTF-8)')
269272
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
270273
}
271274
else {
@@ -612,6 +615,9 @@ sub ts_to_string {
612615

613616
sub parse_innodb_timestamp {
614617
my $text = shift;
618+
if ( ! defined $text ) {
619+
return (0, 0, 0, 0, 0, 0);
620+
}
615621
my ( $y, $m, $d, $h, $i, $s )
616622
= $text =~ m/^(\d\d)(\d\d)(\d\d) +(\d+):(\d+):(\d+)$/;
617623
die("Can't get timestamp from $text\n") unless $y;
@@ -803,7 +809,8 @@ sub parse_fk_transaction_error {
803809
# TODO: write some tests for this
804810
sub parse_innodb_record_dump {
805811
my ( $dump, $complete, $debug ) = @_;
806-
return undef unless $dump;
812+
# Use bare return as recommend in page 199 of PBP
813+
return unless $dump;
807814

808815
my $result = {};
809816

@@ -6769,6 +6776,9 @@ sub set_precision {
67696776
my ( $num, $precision ) = @_;
67706777
$num = 0 unless defined $num;
67716778
$precision = $config{num_digits}->{val} if !defined $precision;
6779+
if ( $num eq "" ) {
6780+
$num = int(0);
6781+
}
67726782
sprintf("%.${precision}f", $num);
67736783
}
67746784

@@ -6777,6 +6787,9 @@ sub set_precision {
67776787
sub percent {
67786788
my ( $num ) = @_;
67796789
$num = 0 unless defined $num;
6790+
if ( $num eq "" ) {
6791+
$num = int(0);
6792+
}
67806793
my $digits = $config{num_digits}->{val};
67816794
return sprintf("%.${digits}f", $num * 100)
67826795
. ($config{show_percent}->{val} ? '%' : '');
@@ -6841,7 +6854,7 @@ sub make_color_func {
68416854
push @criteria,
68426855
"( defined \$set->{$spec->{col}} && \$set->{$spec->{col}} $spec->{op} $val ) { return '$spec->{color}'; }";
68436856
}
6844-
return undef unless @criteria;
6857+
return unless @criteria;
68456858
my $sub = eval 'sub { my ( $set ) = @_; if ' . join(" elsif ", @criteria) . '}';
68466859
die if $EVAL_ERROR;
68476860
return $sub;
@@ -7521,10 +7534,10 @@ sub choose_connections {
75217534
sub do_stmt {
75227535
my ( $cxn, $stmt_name, @args ) = @_;
75237536

7524-
return undef if $file;
7537+
return if $file;
75257538

75267539
# Test if the cxn should not even be tried
7527-
return undef if $dbhs{$cxn}
7540+
return if $dbhs{$cxn}
75287541
&& $dbhs{$cxn}->{failed}
75297542
&& ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} );
75307543

@@ -7596,10 +7609,10 @@ sub handle_cxn_error {
75967609
sub do_query {
75977610
my ( $cxn, $query ) = @_;
75987611

7599-
return undef if $file;
7612+
return if $file;
76007613

76017614
# Test if the cxn should not even be tried
7602-
return undef if $dbhs{$cxn}
7615+
return if $dbhs{$cxn}
76037616
&& $dbhs{$cxn}->{failed}
76047617
&& ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} );
76057618

@@ -7781,7 +7794,7 @@ sub compile_select_stmt {
77817794
sub compile_filter {
77827795
my ( $text ) = @_;
77837796
my ( $sub, $err );
7784-
eval "\$sub = sub { my \$set = shift; $text }";
7797+
eval { $sub = sub { my $set = shift; $text } };
77857798
if ( $EVAL_ERROR ) {
77867799
$EVAL_ERROR =~ s/at \(eval.*$//;
77877800
$sub = sub { return $EVAL_ERROR };
@@ -8013,7 +8026,7 @@ sub load_config_plugins {
80138026

80148027
# First, find a list of all plugins that exist on disk, and get information about them.
80158028
my $dir = $config{plugin_dir}->{val};
8016-
foreach my $p_file ( <$dir/*.pm> ) {
8029+
foreach my $p_file (glob($dir."/*.pm")) {
80178030
my ($package, $desc);
80188031
eval {
80198032
open my $p_in, "<", $p_file or die $OS_ERROR;
@@ -9192,7 +9205,7 @@ sub switch_var_set {
91929205
# edit_stmt_sleep_times {{{3
91939206
sub edit_stmt_sleep_times {
91949207
$clear_screen_sub->();
9195-
my $stmt = prompt_list('Specify a statement', '', sub { return sort keys %stmt_maker_for });
9208+
my $stmt = prompt_list('Specify a statement', '', sub { my @tmparray = sort keys %stmt_maker_for; return @tmparray });
91969209
return unless $stmt && exists $stmt_maker_for{$stmt};
91979210
$clear_screen_sub->();
91989211
my $curr_val = $stmt_sleep_time_for{$stmt} || 0;
@@ -9843,7 +9856,7 @@ sub get_slave_status {
98439856
sub is_func {
98449857
my ( $word ) = @_;
98459858
return defined(&$word)
9846-
|| eval "my \$x= sub { $word }; 1"
9859+
|| eval { my $x = sub { $word }; 1 }
98479860
|| $EVAL_ERROR !~ m/^Bareword/;
98489861
}
98499862

storage/innobase/buf/buf0flu.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,19 @@ uint32_t fil_space_t::flush_freed(bool writable)
966966
mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex);
967967
mysql_mutex_assert_not_owner(&buf_pool.mutex);
968968

969-
freed_range_mutex.lock();
970-
if (freed_ranges.empty() || log_sys.get_flushed_lsn() < get_last_freed_lsn())
969+
for (;;)
971970
{
971+
freed_range_mutex.lock();
972+
if (freed_ranges.empty())
973+
{
974+
freed_range_mutex.unlock();
975+
return 0;
976+
}
977+
const lsn_t flush_lsn= last_freed_lsn;
978+
if (log_sys.get_flushed_lsn() >= flush_lsn)
979+
break;
972980
freed_range_mutex.unlock();
973-
return 0;
981+
log_write_up_to(flush_lsn, true);
974982
}
975983

976984
const unsigned physical{physical_size()};

storage/innobase/buf/buf0rea.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,6 @@ buf_read_page_low(
265265
buf_page_t* bpage;
266266

267267
if (buf_dblwr.is_inside(page_id)) {
268-
ib::error() << "Trying to read doublewrite buffer page "
269-
<< page_id;
270-
ut_ad(0);
271268
space->release();
272269
return DB_PAGE_CORRUPTED;
273270
}

storage/innobase/include/fil0fil.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,6 @@ struct fil_space_t final
638638
/** Close all tablespace files at shutdown */
639639
static void close_all();
640640

641-
/** @return last_freed_lsn */
642-
lsn_t get_last_freed_lsn() { return last_freed_lsn; }
643641
/** Update last_freed_lsn */
644642
void update_last_freed_lsn(lsn_t lsn) { last_freed_lsn= lsn; }
645643

storage/innobase/include/trx0sys.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ class trx_sys_t
10531053
void close();
10541054

10551055
/** @return total number of active (non-prepared) transactions */
1056-
ulint any_active_transactions();
1056+
size_t any_active_transactions(size_t *prepared= nullptr);
10571057

10581058

10591059
/**

storage/innobase/srv/srv0srv.cc

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ void srv_master_callback(void*)
15141514
}
15151515

15161516
/** @return whether purge should exit due to shutdown */
1517-
static bool srv_purge_should_exit()
1517+
static bool srv_purge_should_exit(size_t old_history_size)
15181518
{
15191519
ut_ad(srv_shutdown_state <= SRV_SHUTDOWN_CLEANUP);
15201520

@@ -1525,8 +1525,12 @@ static bool srv_purge_should_exit()
15251525
return true;
15261526

15271527
/* Slow shutdown was requested. */
1528+
size_t prepared, active= trx_sys.any_active_transactions(&prepared);
15281529
const size_t history_size= trx_sys.history_size();
1529-
if (history_size)
1530+
1531+
if (!history_size);
1532+
else if (!active && history_size == old_history_size && prepared);
1533+
else
15301534
{
15311535
static time_t progress_time;
15321536
time_t now= time(NULL);
@@ -1543,7 +1547,7 @@ static bool srv_purge_should_exit()
15431547
return false;
15441548
}
15451549

1546-
return !trx_sys.any_active_transactions();
1550+
return !active;
15471551
}
15481552

15491553
/*********************************************************************//**
@@ -1686,7 +1690,7 @@ inline void purge_coordinator_state::do_purge()
16861690
break;
16871691
}
16881692

1689-
if (!srv_purge_should_exit())
1693+
if (!srv_purge_should_exit(history_size))
16901694
goto loop;
16911695
}
16921696

@@ -1882,15 +1886,19 @@ ulint srv_get_task_queue_length()
18821886
/** Shut down the purge threads. */
18831887
void srv_purge_shutdown()
18841888
{
1885-
if (purge_sys.enabled()) {
1886-
if (!srv_fast_shutdown && !opt_bootstrap)
1887-
srv_update_purge_thread_count(innodb_purge_threads_MAX);
1888-
while(!srv_purge_should_exit()) {
1889-
ut_a(!purge_sys.paused());
1890-
srv_wake_purge_thread_if_not_active();
1891-
purge_coordinator_task.wait();
1892-
}
1893-
purge_sys.coordinator_shutdown();
1894-
srv_shutdown_purge_tasks();
1895-
}
1889+
if (purge_sys.enabled())
1890+
{
1891+
if (!srv_fast_shutdown && !opt_bootstrap)
1892+
srv_update_purge_thread_count(innodb_purge_threads_MAX);
1893+
size_t history_size= trx_sys.history_size();
1894+
while (!srv_purge_should_exit(history_size))
1895+
{
1896+
history_size= trx_sys.history_size();
1897+
ut_a(!purge_sys.paused());
1898+
srv_wake_purge_thread_if_not_active();
1899+
purge_coordinator_task.wait();
1900+
}
1901+
purge_sys.coordinator_shutdown();
1902+
srv_shutdown_purge_tasks();
1903+
}
18961904
}

storage/innobase/trx/trx0purge.cc

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,6 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
369369
undo = NULL;
370370
}
371371

372-
MY_ATTRIBUTE((nonnull, warn_unused_result))
373-
/** Remove undo log header from the history list.
374-
@param[in,out] rseg rollback segment header page
375-
@param[in] log undo log segment header page
376-
@param[in] offset byte offset in the undo log segment header page
377-
@param[in,out] mtr mini-transaction */
378-
static dberr_t trx_purge_remove_log_hdr(buf_block_t *rseg, buf_block_t* log,
379-
uint16_t offset, mtr_t *mtr)
380-
{
381-
return flst_remove(rseg, TRX_RSEG + TRX_RSEG_HISTORY, log,
382-
uint16_t(offset + TRX_UNDO_HISTORY_NODE), mtr);
383-
}
384-
385372
/** Free an undo log segment.
386373
@param block rollback segment header page
387374
@param mtr mini-transaction */
@@ -391,7 +378,7 @@ static void trx_purge_free_segment(buf_block_t *block, mtr_t &mtr)
391378
block->page.frame, &mtr))
392379
{
393380
block->fix();
394-
const page_id_t id{block->page.id()};
381+
ut_d(const page_id_t id{block->page.id()});
395382
mtr.commit();
396383
/* NOTE: If the server is killed after the log that was produced
397384
up to this point was written, and before the log from the mtr.commit()
@@ -403,16 +390,8 @@ static void trx_purge_free_segment(buf_block_t *block, mtr_t &mtr)
403390
log_free_check();
404391
mtr.start();
405392
block->page.lock.x_lock();
406-
if (UNIV_UNLIKELY(block->page.id() != id))
407-
{
408-
block->unfix();
409-
block->page.lock.x_unlock();
410-
block= buf_page_get_gen(id, 0, RW_X_LATCH, nullptr, BUF_GET, &mtr);
411-
if (!block)
412-
return;
413-
}
414-
else
415-
mtr.memo_push(block, MTR_MEMO_PAGE_X_MODIFY);
393+
ut_ad(block->page.id() == id);
394+
mtr.memo_push(block, MTR_MEMO_PAGE_X_MODIFY);
416395
}
417396

418397
while (!fseg_free_step(TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER +
@@ -434,7 +413,6 @@ trx_purge_truncate_rseg_history(trx_rseg_t& rseg,
434413
mtr.start();
435414

436415
dberr_t err;
437-
reget:
438416
buf_block_t *rseg_hdr= rseg.get(&mtr, &err);
439417
if (!rseg_hdr)
440418
{
@@ -474,18 +452,16 @@ trx_purge_truncate_rseg_history(trx_rseg_t& rseg,
474452
TRX_UNDO_HISTORY_NODE);
475453
prev_hdr_addr.boffset= static_cast<uint16_t>(prev_hdr_addr.boffset -
476454
TRX_UNDO_HISTORY_NODE);
477-
err= trx_purge_remove_log_hdr(rseg_hdr, b, hdr_addr.boffset, &mtr);
455+
456+
err= flst_remove(rseg_hdr, TRX_RSEG + TRX_RSEG_HISTORY, b,
457+
uint16_t(hdr_addr.boffset + TRX_UNDO_HISTORY_NODE), &mtr);
478458
if (UNIV_UNLIKELY(err != DB_SUCCESS))
479459
goto func_exit;
480460

481461
rseg_hdr->fix();
482462

483-
if (mach_read_from_2(b->page.frame + hdr_addr.boffset + TRX_UNDO_NEXT_LOG) ||
484-
rseg.is_referenced() ||
485-
rseg.needs_purge > (purge_sys.head.trx_no
486-
? purge_sys.head.trx_no
487-
: purge_sys.tail.trx_no))
488-
/* We cannot free the entire undo page. */;
463+
if (mach_read_from_2(b->page.frame + hdr_addr.boffset + TRX_UNDO_NEXT_LOG))
464+
/* We cannot free the entire undo log segment. */;
489465
else
490466
{
491467
const uint32_t seg_size=
@@ -535,12 +511,7 @@ trx_purge_truncate_rseg_history(trx_rseg_t& rseg,
535511
log_free_check();
536512
mtr.start();
537513
rseg_hdr->page.lock.x_lock();
538-
if (UNIV_UNLIKELY(rseg_hdr->page.id() != rseg.page_id()))
539-
{
540-
rseg_hdr->unfix();
541-
rseg_hdr->page.lock.x_unlock();
542-
goto reget;
543-
}
514+
ut_ad(rseg_hdr->page.id() == rseg.page_id());
544515
mtr.memo_push(rseg_hdr, MTR_MEMO_PAGE_X_MODIFY);
545516

546517
goto loop;
@@ -613,8 +584,9 @@ TRANSACTIONAL_TARGET static void trx_purge_truncate_history()
613584
{
614585
ut_ad(rseg.is_persistent());
615586
rseg.latch.wr_lock(SRW_LOCK_CALL);
616-
if (dberr_t e= trx_purge_truncate_rseg_history(rseg, head))
617-
err= e;
587+
if (!rseg.is_referenced() && rseg.needs_purge <= head.trx_no)
588+
if (dberr_t e= trx_purge_truncate_rseg_history(rseg, head))
589+
err= e;
618590
rseg.latch.wr_unlock();
619591
}
620592

storage/innobase/trx/trx0sys.cc

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,29 @@ trx_sys_t::close()
343343
}
344344

345345
/** @return total number of active (non-prepared) transactions */
346-
ulint trx_sys_t::any_active_transactions()
346+
size_t trx_sys_t::any_active_transactions(size_t *prepared)
347347
{
348-
uint32_t total_trx= 0;
348+
size_t total_trx= 0, prepared_trx= 0;
349349

350-
trx_sys.trx_list.for_each([&total_trx](const trx_t &trx) {
351-
if (trx.state == TRX_STATE_COMMITTED_IN_MEMORY ||
352-
(trx.state == TRX_STATE_ACTIVE && trx.id))
350+
trx_sys.trx_list.for_each([&](const trx_t &trx) {
351+
switch (trx.state) {
352+
case TRX_STATE_NOT_STARTED:
353+
break;
354+
case TRX_STATE_ACTIVE:
355+
if (!trx.id)
356+
break;
357+
/* fall through */
358+
case TRX_STATE_COMMITTED_IN_MEMORY:
353359
total_trx++;
360+
break;
361+
case TRX_STATE_PREPARED:
362+
case TRX_STATE_PREPARED_RECOVERED:
363+
prepared_trx++;
364+
}
354365
});
355366

367+
if (prepared)
368+
*prepared= prepared_trx;
369+
356370
return total_trx;
357371
}

0 commit comments

Comments
 (0)