Skip to content

Commit 9c47beb

Browse files
committed
MDEV-11027 InnoDB log recovery is too noisy
Provide more useful progress reporting of crash recovery. recv_sys_t::progress_time: The time of the last report. recv_scan_print_counter: Remove. log_group_read_log_seg(): After after each I/O request, report progress if needed. recv_apply_hashed_log_recs(): At the start of each batch, if there are pages to be recovered, issue a message.
1 parent 1fd3cc8 commit 9c47beb

File tree

6 files changed

+90
-156
lines changed

6 files changed

+90
-156
lines changed

storage/innobase/include/log0recv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -428,6 +429,8 @@ struct recv_sys_struct{
428429
scan find a corrupt log block, or a corrupt
429430
log record, or there is a log parsing
430431
buffer overflow */
432+
/** the time when progress was last reported */
433+
ib_time_t progress_time;
431434
#ifdef UNIV_LOG_ARCHIVE
432435
log_group_t* archive_group;
433436
/*!< in archive recovery: the log group whose

storage/innobase/log/log0log.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2009, Google Inc.
5+
Copyright (c) 2017, MariaDB Corporation.
56
67
Portions of this file contain modifications contributed and copyrighted by
78
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -2303,6 +2304,7 @@ log_group_read_log_seg(
23032304
ulint len;
23042305
ulint source_offset;
23052306
ibool sync;
2307+
ib_time_t time;
23062308

23072309
ut_ad(mutex_own(&(log_sys->mutex)));
23082310

@@ -2335,6 +2337,15 @@ log_group_read_log_seg(
23352337
start_lsn += len;
23362338
buf += len;
23372339

2340+
time = ut_time();
2341+
2342+
if (recv_sys->progress_time - time >= 15) {
2343+
recv_sys->progress_time = time;
2344+
ut_print_timestamp(stderr);
2345+
fprintf(stderr, " InnoDB: Read redo log up to LSN=%llu\n",
2346+
start_lsn);
2347+
}
2348+
23382349
if (start_lsn != end_lsn) {
23392350

23402351
goto loop;

storage/innobase/log/log0recv.c

Lines changed: 29 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -65,7 +66,7 @@ this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
6566
#define RECV_READ_AHEAD_AREA 32
6667

6768
/** The recovery system */
68-
UNIV_INTERN recv_sys_t* recv_sys = NULL;
69+
UNIV_INTERN recv_sys_t* recv_sys;
6970
/** TRUE when applying redo log records during crash recovery; FALSE
7071
otherwise. Note that this is FALSE while a background thread is
7172
rolling back incomplete transactions. */
@@ -121,9 +122,6 @@ UNIV_INTERN ibool recv_is_making_a_backup = FALSE;
121122
UNIV_INTERN ibool recv_is_from_backup = FALSE;
122123
# define buf_pool_get_curr_size() (5 * 1024 * 1024)
123124
#endif /* !UNIV_HOTBACKUP */
124-
/** The following counter is used to decide when to print info on
125-
log scan */
126-
static ulint recv_scan_print_counter;
127125

128126
/** The type of the previous parsed redo log record */
129127
static ulint recv_previous_parsed_rec_type;
@@ -275,8 +273,6 @@ recv_sys_var_init(void)
275273

276274
recv_no_ibuf_operations = FALSE;
277275

278-
recv_scan_print_counter = 0;
279-
280276
recv_previous_parsed_rec_type = 999999;
281277

282278
recv_previous_parsed_rec_offset = 0;
@@ -342,6 +338,7 @@ recv_sys_init(
342338
recv_sys->last_block = ut_align(recv_sys->last_block_buf_start,
343339
OS_FILE_LOG_BLOCK_SIZE);
344340
recv_sys->found_corrupt_log = FALSE;
341+
recv_sys->progress_time = ut_time();
345342

346343
recv_max_page_lsn = 0;
347344

@@ -1490,6 +1487,7 @@ recv_recover_page_func(
14901487
ibool success;
14911488
#endif /* !UNIV_HOTBACKUP */
14921489
mtr_t mtr;
1490+
ib_time_t time;
14931491

14941492
mutex_enter(&(recv_sys->mutex));
14951493

@@ -1669,6 +1667,8 @@ recv_recover_page_func(
16691667

16701668
mtr_commit(&mtr);
16711669

1670+
time = ut_time();
1671+
16721672
mutex_enter(&(recv_sys->mutex));
16731673

16741674
if (recv_max_page_lsn < page_lsn) {
@@ -1677,11 +1677,16 @@ recv_recover_page_func(
16771677

16781678
recv_addr->state = RECV_PROCESSED;
16791679

1680-
ut_a(recv_sys->n_addrs);
1681-
recv_sys->n_addrs--;
1682-
1683-
mutex_exit(&(recv_sys->mutex));
1680+
ut_a(recv_sys->n_addrs > 0);
1681+
if (--recv_sys->n_addrs && recv_sys->progress_time - time >= 15) {
1682+
recv_sys->progress_time = time;
1683+
ut_print_timestamp(stderr);
1684+
fprintf(stderr,
1685+
" InnoDB: To recover: " ULINTPF " pages from log\n",
1686+
recv_sys->n_addrs);
1687+
}
16841688

1689+
mutex_exit(&recv_sys->mutex);
16851690
}
16861691

16871692
#ifndef UNIV_HOTBACKUP
@@ -1727,9 +1732,6 @@ recv_read_in_area(
17271732
}
17281733

17291734
buf_read_recv_pages(FALSE, space, zip_size, page_nos, n);
1730-
/*
1731-
fprintf(stderr, "Recv pages at %lu n %lu\n", page_nos[0], n);
1732-
*/
17331735
return(n);
17341736
}
17351737

@@ -1753,7 +1755,6 @@ recv_apply_hashed_log_recs(
17531755
recv_addr_t* recv_addr;
17541756
ulint i;
17551757
ulint n_pages;
1756-
ibool has_printed = FALSE;
17571758
mtr_t mtr;
17581759
loop:
17591760
mutex_enter(&(recv_sys->mutex));
@@ -1773,6 +1774,16 @@ recv_apply_hashed_log_recs(
17731774
recv_no_ibuf_operations = TRUE;
17741775
}
17751776

1777+
if (recv_sys->n_addrs) {
1778+
ut_print_timestamp(stderr);
1779+
fprintf(stderr,
1780+
" InnoDB: %s" ULINTPF " pages from redo log\n",
1781+
allow_ibuf
1782+
? "Starting final batch to recover "
1783+
: "Starting a batch to recover ",
1784+
recv_sys->n_addrs);
1785+
}
1786+
17761787
recv_sys->apply_log_recs = TRUE;
17771788
recv_sys->apply_batch_on = TRUE;
17781789

@@ -1786,16 +1797,6 @@ recv_apply_hashed_log_recs(
17861797
ulint page_no = recv_addr->page_no;
17871798

17881799
if (recv_addr->state == RECV_NOT_PROCESSED) {
1789-
if (!has_printed) {
1790-
ut_print_timestamp(stderr);
1791-
fputs(" InnoDB: Starting an"
1792-
" apply batch of log records"
1793-
" to the database...\n"
1794-
"InnoDB: Progress in percents: ",
1795-
stderr);
1796-
has_printed = TRUE;
1797-
}
1798-
17991800
mutex_exit(&(recv_sys->mutex));
18001801

18011802
if (buf_page_peek(space, page_no)) {
@@ -1821,16 +1822,6 @@ recv_apply_hashed_log_recs(
18211822

18221823
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
18231824
}
1824-
1825-
if (has_printed
1826-
&& (i * 100) / hash_get_n_cells(recv_sys->addr_hash)
1827-
!= ((i + 1) * 100)
1828-
/ hash_get_n_cells(recv_sys->addr_hash)) {
1829-
1830-
fprintf(stderr, "%lu ", (ulong)
1831-
((i * 100)
1832-
/ hash_get_n_cells(recv_sys->addr_hash)));
1833-
}
18341825
}
18351826

18361827
/* Wait until all the pages have been processed */
@@ -1844,11 +1835,6 @@ recv_apply_hashed_log_recs(
18441835
mutex_enter(&(recv_sys->mutex));
18451836
}
18461837

1847-
if (has_printed) {
1848-
1849-
fprintf(stderr, "\n");
1850-
}
1851-
18521838
if (!allow_ibuf) {
18531839
/* Flush all the file pages to disk and invalidate them in
18541840
the buffer pool */
@@ -1876,10 +1862,6 @@ recv_apply_hashed_log_recs(
18761862

18771863
recv_sys_empty_hash();
18781864

1879-
if (has_printed) {
1880-
fprintf(stderr, "InnoDB: Apply batch completed\n");
1881-
}
1882-
18831865
mutex_exit(&(recv_sys->mutex));
18841866
}
18851867
#else /* !UNIV_HOTBACKUP */
@@ -1903,10 +1885,6 @@ recv_apply_log_recs_for_backup(void)
19031885

19041886
block = back_block1;
19051887

1906-
fputs("InnoDB: Starting an apply batch of log records"
1907-
" to the database...\n"
1908-
"InnoDB: Progress in percents: ", stderr);
1909-
19101888
n_hash_cells = hash_get_n_cells(recv_sys->addr_hash);
19111889

19121890
for (i = 0; i < n_hash_cells; i++) {
@@ -2697,10 +2675,10 @@ recv_scan_log_recs(
26972675
#ifndef UNIV_HOTBACKUP
26982676
if (recv_log_scan_is_startup_type
26992677
&& !recv_needed_recovery) {
2700-
2678+
ut_print_timestamp(stderr);
27012679
fprintf(stderr,
2702-
"InnoDB: Log scan progressed"
2703-
" past the checkpoint lsn %llu\n",
2680+
" InnoDB: Starting crash recovery"
2681+
" from checkpoint LSN=%llu\n",
27042682
recv_sys->scanned_lsn);
27052683
recv_init_crash_recovery();
27062684
}
@@ -2751,19 +2729,6 @@ recv_scan_log_recs(
27512729

27522730
*group_scanned_lsn = scanned_lsn;
27532731

2754-
if (recv_needed_recovery
2755-
|| (recv_is_from_backup && !recv_is_making_a_backup)) {
2756-
recv_scan_print_counter++;
2757-
2758-
if (finished || (recv_scan_print_counter % 80 == 0)) {
2759-
2760-
fprintf(stderr,
2761-
"InnoDB: Doing recovery: scanned up to"
2762-
" log sequence number %llu\n",
2763-
*group_scanned_lsn);
2764-
}
2765-
}
2766-
27672732
if (more_data && !recv_sys->found_corrupt_log) {
27682733
/* Try to parse more log records */
27692734

@@ -2854,17 +2819,6 @@ recv_init_crash_recovery(void)
28542819

28552820
recv_needed_recovery = TRUE;
28562821

2857-
ut_print_timestamp(stderr);
2858-
2859-
fprintf(stderr,
2860-
" InnoDB: Database was not"
2861-
" shut down normally!\n"
2862-
"InnoDB: Starting crash recovery.\n");
2863-
2864-
fprintf(stderr,
2865-
"InnoDB: Reading tablespace information"
2866-
" from the .ibd files...\n");
2867-
28682822
fil_load_single_table_tablespaces();
28692823

28702824
/* If we are using the doublewrite method, we will
@@ -2877,8 +2831,7 @@ recv_init_crash_recovery(void)
28772831
fprintf(stderr,
28782832
"InnoDB: Restoring possible"
28792833
" half-written data pages from"
2880-
" the doublewrite\n"
2881-
"InnoDB: buffer...\n");
2834+
" the doublewrite buffer...\n");
28822835
trx_sys_doublewrite_init_or_restore_pages(TRUE);
28832836
}
28842837
}

storage/xtradb/include/log0recv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -465,6 +466,8 @@ struct recv_sys_struct{
465466
scan find a corrupt log block, or a corrupt
466467
log record, or there is a log parsing
467468
buffer overflow */
469+
/** the time when progress was last reported */
470+
ib_time_t progress_time;
468471
#ifdef UNIV_LOG_ARCHIVE
469472
log_group_t* archive_group;
470473
/*!< in archive recovery: the log group whose

storage/xtradb/log/log0log.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2009, Google Inc.
5+
Copyright (c) 2017, MariaDB Corporation.
56
67
Portions of this file contain modifications contributed and copyrighted by
78
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -2502,6 +2503,7 @@ log_group_read_log_seg(
25022503
ulint len;
25032504
ulint source_offset;
25042505
ibool sync;
2506+
ib_time_t time;
25052507

25062508
ut_ad(mutex_own(&(log_sys->mutex)));
25072509

@@ -2538,6 +2540,15 @@ log_group_read_log_seg(
25382540
start_lsn += len;
25392541
buf += len;
25402542

2543+
time = ut_time();
2544+
2545+
if (recv_sys->progress_time - time >= 15) {
2546+
recv_sys->progress_time = time;
2547+
ut_print_timestamp(stderr);
2548+
fprintf(stderr, " InnoDB: Read redo log up to LSN=%llu\n",
2549+
start_lsn);
2550+
}
2551+
25412552
if (start_lsn != end_lsn) {
25422553

25432554
if (release_mutex) {

0 commit comments

Comments
 (0)