Skip to content

Commit e190624

Browse files
Logging and related changed based on review comments
1 parent 3d33c4d commit e190624

File tree

8 files changed

+73
-74
lines changed

8 files changed

+73
-74
lines changed

mysql-test/mariadb-test-run.pl

+1
Original file line numberDiff line numberDiff line change
@@ -4464,6 +4464,7 @@ ($$)
44644464
qr/InnoDB: innodb_open_files .* should not be greater than/,
44654465
qr/InnoDB: Trying to delete tablespace.*but there are.*pending/,
44664466
qr/InnoDB: Tablespace 1[0-9]* was not found at .*, and innodb_force_recovery was set/,
4467+
qr/InnoDB: Long wait \([0-9]+ seconds\) for double-write buffer flush/,
44674468
qr/Slave: Unknown table 't1' .* 1051/,
44684469
qr/Slave SQL:.*(Internal MariaDB error code: [[:digit:]]+|Query:.*)/,
44694470
qr/slave SQL thread aborted/,

storage/innobase/buf/buf0dblwr.cc

+20-24
Original file line numberDiff line numberDiff line change
@@ -602,24 +602,20 @@ static void buf_dblwr_check_block(const buf_page_t *bpage) noexcept
602602
}
603603
#endif /* UNIV_DEBUG */
604604

605-
void buf_dblwr_t::print_info(FILE* file)
605+
ATTRIBUTE_COLD void buf_dblwr_t::print_info() const noexcept
606606
{
607607
mysql_mutex_assert_owner(&mutex);
608-
slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
609-
std::ostringstream log_strm;
610-
611-
log_strm
612-
<< "--------------------\n"
613-
<< "Innodb: Double Write\n"
614-
<< "--------------------\n"
615-
<< "Batch running : " << std::boolalpha << batch_running << "\n"
616-
<< "Active Slot- "
617-
<< "first_free: " << active_slot->first_free
618-
<< " reserved: " << active_slot->reserved << "\n"
619-
<< "Flush Slot - "
620-
<< "first_free: " << flush_slot->first_free
621-
<< " reserved: " << flush_slot->reserved << "\n";
622-
fputs(log_strm.str().c_str(), file);
608+
const slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
609+
610+
sql_print_information("Innodb: Double Write State\n"
611+
"-------------------\n"
612+
"Batch running : %s\n"
613+
"Active Slot - first_free: %lu reserved: %lu\n"
614+
"Flush Slot - first_free: %lu reserved: %lu\n"
615+
"-------------------",
616+
(batch_running ? "true" : "false"),
617+
active_slot->first_free, active_slot->reserved,
618+
flush_slot->first_free, flush_slot->reserved);
623619
}
624620

625621
bool buf_dblwr_t::flush_buffered_writes(const ulint size) noexcept
@@ -644,17 +640,17 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) noexcept
644640

645641
if (++count < first_log_count && !(count % 5))
646642
{
647-
ib::info() << "Long wait (" << count
648-
<< " seconds) for double-write buffer flush.";
649-
print_flush_info(stderr);
650-
print_info(stderr);
643+
sql_print_information(
644+
"Long wait (%d seconds) for double-write buffer flush.", count);
645+
buf_pool.print_flush_info();
646+
print_info();
651647
}
652648
else if (!(count % log_count))
653649
{
654-
ib::warn() << "Long wait (" << count
655-
<< " seconds) for double-write buffer flush.";
656-
print_flush_info(stderr);
657-
print_info(stderr);
650+
sql_print_warning(
651+
"Long wait (%d seconds) for double-write buffer flush.", count);
652+
buf_pool.print_flush_info();
653+
print_info();
658654
log_count= log_count >= max_count ? max_count : log_count * 2;
659655
}
660656
}

storage/innobase/buf/buf0flu.cc

+45-41
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ The database buffer buf_pool flush algorithm
2525
Created 11/11/1995 Heikki Tuuri
2626
*******************************************************/
2727

28-
#include <iomanip>
2928
#include "univ.i"
3029
#include <my_service_manager.h>
3130
#include <mysql/service_thd_wait.h>
@@ -1375,9 +1374,10 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n) noexcept
13751374
break;
13761375
}
13771376

1378-
bool reached_half= UT_LIST_GET_LEN(buf_pool.free) >= free_limit / 2;
1379-
1380-
if (reached_half && neighbors && space->is_rotational())
1377+
if (neighbors && space->is_rotational() &&
1378+
/* Skip neighbourhood flush from LRU list if we haven't yet reached
1379+
half of the free page target. */
1380+
UT_LIST_GET_LEN(buf_pool.free) * 2 >= free_limit)
13811381
n->flushed+= buf_flush_try_neighbors(space, page_id, bpage,
13821382
neighbors == 1,
13831383
n->flushed, max);
@@ -2343,9 +2343,9 @@ static void buf_flush_page_cleaner() noexcept
23432343
{
23442344
std::this_thread::sleep_for(std::chrono::seconds(1));
23452345
/* Cover the logging code in debug mode. */
2346-
print_flush_info(stderr);
2346+
buf_pool.print_flush_info();
23472347
buf_dblwr.lock();
2348-
buf_dblwr.print_info(stderr);
2348+
buf_dblwr.print_info();
23492349
buf_dblwr.unlock();
23502350
});
23512351
lsn_limit= buf_flush_sync_lsn;
@@ -2553,7 +2553,8 @@ static void buf_flush_page_cleaner() noexcept
25532553
n= n >= n_flushed ? n - n_flushed : 0;
25542554
/* It is critical to generate free pages to keep the system alive. Make
25552555
sure we are not hindered by dirty pages in LRU tail. */
2556-
n= std::max(n, std::min(srv_max_io_capacity, buf_pool.LRU_scan_depth));
2556+
n= std::max<ulint>(n, std::min<ulint>(srv_max_io_capacity,
2557+
buf_pool.LRU_scan_depth));
25572558
goto LRU_flush;
25582559
}
25592560

@@ -2595,7 +2596,7 @@ ATTRIBUTE_COLD void buf_pool_t::LRU_warn() noexcept
25952596
{
25962597
sql_print_warning("InnoDB: Could not free any blocks in the buffer pool!"
25972598
" Consider increasing innodb_buffer_pool_size.");
2598-
print_flush_info(stderr);
2599+
buf_pool.print_flush_info();
25992600
}
26002601
}
26012602

@@ -2676,48 +2677,51 @@ void buf_flush_sync() noexcept
26762677
thd_wait_end(nullptr);
26772678
}
26782679

2679-
void print_flush_info(FILE* file)
2680+
ATTRIBUTE_COLD void buf_pool_t::print_flush_info() const noexcept
26802681
{
26812682
/* We do dirty read of UT_LIST count variable. */
2682-
ulint lru_size= UT_LIST_GET_LEN(buf_pool.LRU);
2683-
ulint dirty_size= UT_LIST_GET_LEN(buf_pool.flush_list);
2684-
ulint free_size= UT_LIST_GET_LEN(buf_pool.free);
2683+
ulint lru_size= UT_LIST_GET_LEN(LRU);
2684+
ulint dirty_size= UT_LIST_GET_LEN(flush_list);
2685+
ulint free_size= UT_LIST_GET_LEN(free);
26852686
ulint dirty_pct= lru_size ? dirty_size * 100 / (lru_size + free_size) : 0;
2687+
sql_print_information("Innodb: Buffer Pool pages \n"
2688+
"-------------------\n"
2689+
"LRU Pages: %lu\n"
2690+
"Free Pages: %lu\n"
2691+
"Dirty Pages: %lu : %lu%%\n"
2692+
"-------------------",
2693+
lru_size, free_size, dirty_size, dirty_pct);
26862694

26872695
lsn_t lsn= log_sys.get_lsn();
26882696
lsn_t clsn= log_sys.last_checkpoint_lsn;
2697+
sql_print_information("Innodb: LSN flush parameters\n"
2698+
"-------------------\n"
2699+
"System LSN : %" PRIu64 "\n"
2700+
"Checkpoint LSN: %" PRIu64 "\n"
2701+
"Flush ASync LSN: %" PRIu64 "\n"
2702+
"Flush Sync LSN: %" PRIu64 "\n"
2703+
"-------------------",
2704+
lsn, clsn, buf_flush_async_lsn, buf_flush_sync_lsn);
2705+
26892706
lsn_t age= lsn - clsn;
26902707
lsn_t age_pct= log_sys.max_checkpoint_age
26912708
? age * 100 / log_sys.max_checkpoint_age : 0;
2692-
2693-
std::ostringstream log_strm;
2694-
log_strm
2695-
<< "-------------------\n"
2696-
<< "Innodb: Buffer Pool\n"
2697-
<< "-------------------\n"
2698-
<< "LRU Pages : " << lru_size << "\n"
2699-
<< "Free Pages: " << free_size << "\n"
2700-
<< "DirtyPages: " << dirty_size << " : " << dirty_pct << "%\n"
2701-
<< "----------------------------\n"
2702-
<< "Innodb: Flush LSN Parameter \n"
2703-
<< "----------------------------\n"
2704-
<< "System LSN : " << lsn << "\n"
2705-
<< "Checkpoint LSN : " << clsn << "\n"
2706-
<< "Flush ASync LSN: " << buf_flush_async_lsn << "\n"
2707-
<< "Flush Sync LSN : " << buf_flush_sync_lsn << "\n"
2708-
<< "--------------------------\n"
2709-
<< "Innodb: LSN Age Parameters\n"
2710-
<< "--------------------------\n"
2711-
<< "Current Age : " << age << " : " << age_pct << "%\n"
2712-
<< "Max Age(Async): " << log_sys.max_modified_age_async << "\n"
2713-
<< "Max Age(Sync) : " << log_sys.max_checkpoint_age << "\n"
2714-
<< "Capacity : " << log_sys.log_capacity << "\n"
2715-
<< "--------------------------\n"
2716-
<< "Innodb: Pending IO count \n"
2717-
<< "-------------------------\n"
2718-
<< "Pending Read: " << os_aio_pending_reads_approx() << "\n"
2719-
<< "Pending Write: " << os_aio_pending_writes_approx() << "\n";
2720-
fputs(log_strm.str().c_str(), file);
2709+
sql_print_information("Innodb: LSN age parameters\n"
2710+
"-------------------\n"
2711+
"Current Age : %" PRIu64 " : %" PRIu64 "%%\n"
2712+
"Max Age(Async): %" PRIu64 "\n"
2713+
"Max Age(Sync) : %" PRIu64 "\n"
2714+
"Capacity : %" PRIu64 "\n"
2715+
"-------------------",
2716+
age, age_pct, log_sys.max_modified_age_async, log_sys.max_checkpoint_age,
2717+
log_sys.log_capacity);
2718+
2719+
sql_print_information("Innodb: Pending IO count\n"
2720+
"-------------------\n"
2721+
"Pending Read: %zu\n"
2722+
"Pending Write: %zu\n"
2723+
"-------------------",
2724+
os_aio_pending_reads_approx(), os_aio_pending_writes_approx());
27212725
}
27222726

27232727
#ifdef UNIV_DEBUG

storage/innobase/dict/dict0dict.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) noexc
10141014

10151015
if (waited >= threshold)
10161016
{
1017-
print_flush_info(stderr);
1017+
buf_pool.print_flush_info();
10181018
ib::fatal() << fatal_msg;
10191019
}
10201020

storage/innobase/include/buf0buf.h

+3
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,9 @@ class buf_pool_t
19511951
/** Issue a warning that we could not free up buffer pool pages. */
19521952
ATTRIBUTE_COLD void LRU_warn() noexcept;
19531953

1954+
/** Print buffer pool flush state information. */
1955+
ATTRIBUTE_COLD void print_flush_info() const noexcept;
1956+
19541957
private:
19551958
/** Temporary memory for page_compressed and encrypted I/O */
19561959
struct io_buf_t

storage/innobase/include/buf0dblwr.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ class buf_dblwr_t
160160
mysql_mutex_unlock(&mutex);
161161
}
162162

163-
/** Print double write state information.
164-
@param file log file for write */
165-
void print_info(FILE* file);
163+
/** Print double write state information. */
164+
ATTRIBUTE_COLD void print_info() const noexcept;
166165
};
167166

168167
/** The doublewrite buffer */

storage/innobase/include/buf0flu.h

-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,3 @@ void buf_flush_sync_batch(lsn_t lsn) noexcept;
135135
/** Synchronously flush dirty blocks.
136136
NOTE: The calling thread is not allowed to hold any buffer page latches! */
137137
void buf_flush_sync() noexcept;
138-
139-
/** Print buffer pool flush state information.
140-
@param file log file for write */
141-
void print_flush_info(FILE* file);

storage/innobase/srv/srv0srv.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ void srv_monitor_task(void*)
12201220
now -= start;
12211221
ulong waited = static_cast<ulong>(now / 1000000);
12221222
if (waited >= threshold) {
1223-
print_flush_info(stderr);
1223+
buf_pool.print_flush_info();
12241224
ib::fatal() << dict_sys.fatal_msg;
12251225
}
12261226

0 commit comments

Comments
 (0)