From ca3aa679644e16f5283e1082d395a530c1803765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 3 Jun 2020 12:14:11 +0300 Subject: MDEV-22577 innodb_fast_shutdown=0 fails to report purge progress srv_purge_should_exit(): Report progress on slow shutdown not only to systemd, but also to the error log. --- storage/innobase/srv/srv0srv.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'storage/innobase/srv/srv0srv.cc') diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 6eb67a1b2d4..9818b20ba6c 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -2516,18 +2516,20 @@ srv_purge_should_exit(ulint n_purged) return(true); } /* Slow shutdown was requested. */ - if (n_purged) { -#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY + if (ulint history_size = n_purged ? trx_sys->rseg_history_len : 0) { static time_t progress_time; time_t now = time(NULL); if (now - progress_time >= 15) { progress_time = now; +#if defined HAVE_SYSTEMD && !defined EMBEDDED_LIBRARY service_manager_extend_timeout( INNODB_EXTEND_TIMEOUT_INTERVAL, "InnoDB: to purge " ULINTPF " transactions", - trx_sys->rseg_history_len); - } + history_size); #endif + ib::info() << "to purge " << history_size + << " transactions"; + } /* The previous round still did some work. */ return(false); } -- cgit v1.2.1 From ad2bf1129cfa85c00072b46e0355fe14bf69ee54 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 27 May 2020 13:03:06 +0530 Subject: MDEV-22646 Assertion `table2->cached' failed in dict_table_t::add_to_cache Problem: ======== During buffer pool resizing, InnoDB recreates the dictionary hash tables. Dictionary hash table reuses the heap of AHI hash tables. It leads to memory corruption. Fix: ==== - While disabling AHI, free the heap and AHI hash tables. Recreate the AHI hash tables and assign new heap when AHI is enabled. - btr_blob_free() access invalid page if page was reallocated during buffer poolresizing. So btr_blob_free() should get the page from buf_pool instead of using existing block. - btr_search_enabled and block->index should be checked after acquiring the btr_search_sys latch - Moved the buffer_pool_scan debug sync to earlier before accessing the btr_search_sys latches to avoid the hang of truncate_purge_debug test case - srv_printf_innodb_monitor() should acquire btr_search_sys latches before AHI hash tables. --- storage/innobase/srv/srv0srv.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'storage/innobase/srv/srv0srv.cc') diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 9818b20ba6c..19d4c7fb7d7 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1333,7 +1333,8 @@ srv_printf_innodb_monitor( ibuf_print(file); #ifdef BTR_CUR_HASH_ADAPT - for (ulint i = 0; i < btr_ahi_parts; ++i) { + btr_search_x_lock_all(); + for (ulint i = 0; i < btr_ahi_parts && btr_search_enabled; ++i) { const hash_table_t* table = btr_search_sys->hash_tables[i]; ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -1357,6 +1358,7 @@ srv_printf_innodb_monitor( ", node heap has " ULINTPF " buffer(s)\n", table->n_cells, heap->base.count - !heap->free_block); } + btr_search_x_unlock_all(); fprintf(file, "%.2f hash searches/s, %.2f non-hash searches/s\n", -- cgit v1.2.1 From efc70da5fd0459ff44153529d13651741cc32bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 5 Jun 2020 14:59:33 +0300 Subject: MDEV-22769 Shutdown hang or crash due to XA breaking locks The background drop table queue in InnoDB is a work-around for cases where the SQL layer is requesting DDL on tables on which transactional locks exist. One such case are XA transactions. Our test case exploits the fact that the recovery of XA PREPARE transactions will only resurrect InnoDB table locks, but not MDL that should block any concurrent DDL. srv_shutdown_t: Introduce the srv_shutdown_state=SRV_SHUTDOWN_INITIATED for the initial part of shutdown, to wait for the background drop table queue to be emptied. srv_shutdown_bg_undo_sources(): Assign srv_shutdown_state=SRV_SHUTDOWN_INITIATED before waiting for the background drop table queue to be emptied. row_drop_tables_for_mysql_in_background(): On slow shutdown, if no active transactions exist (excluding ones that are in XA PREPARE state), skip any tables on which locks exist. row_drop_table_for_mysql(): Do not unnecessarily attempt to drop InnoDB persistent statistics for tables that have already been added to the background drop table queue. row_mysql_close(): Relax an assertion, and free all memory even if innodb_force_recovery=2 would prevent the background drop table queue from being emptied. --- storage/innobase/srv/srv0srv.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'storage/innobase/srv/srv0srv.cc') diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 19d4c7fb7d7..cc85416aac7 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1802,7 +1802,7 @@ loop: srv_refresh_innodb_monitor_stats(); - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { goto exit_func; } @@ -1914,7 +1914,7 @@ loop: os_event_wait_time_low(srv_error_event, 1000000, sig_count); - if (srv_shutdown_state == SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) { goto loop; } @@ -1964,7 +1964,7 @@ srv_get_active_thread_type(void) srv_sys_mutex_exit(); - if (ret == SRV_NONE && srv_shutdown_state != SRV_SHUTDOWN_NONE + if (ret == SRV_NONE && srv_shutdown_state > SRV_SHUTDOWN_INITIATED && purge_sys != NULL) { /* Check only on shutdown. */ switch (trx_purge_state()) { @@ -2219,7 +2219,7 @@ srv_master_do_active_tasks(void) ut_d(srv_master_do_disabled_loop()); - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return; } @@ -2244,7 +2244,7 @@ srv_master_do_active_tasks(void) /* Now see if various tasks that are performed at defined intervals need to be performed. */ - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return; } @@ -2269,7 +2269,7 @@ srv_master_do_active_tasks(void) early and often to avoid those situations. */ DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", return;); - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return; } @@ -2312,7 +2312,7 @@ srv_master_do_idle_tasks(void) ut_d(srv_master_do_disabled_loop()); - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return; } @@ -2328,7 +2328,7 @@ srv_master_do_idle_tasks(void) MONITOR_INC_TIME_IN_MICRO_SECS( MONITOR_SRV_IBUF_MERGE_MICROSECOND, counter_time); - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return; } @@ -2356,7 +2356,7 @@ srv_master_do_idle_tasks(void) early and often to avoid those situations. */ DBUG_EXECUTE_IF("ib_log_checkpoint_avoid", return;); - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { return; } @@ -2454,8 +2454,7 @@ DECLARE_THREAD(srv_master_thread)( ut_a(slot == srv_sys.sys_threads); loop: - while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { - + while (srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) { srv_master_sleep(); MONITOR_INC(MONITOR_MASTER_THREAD_SLEEP); @@ -2470,6 +2469,7 @@ loop: switch (srv_shutdown_state) { case SRV_SHUTDOWN_NONE: + case SRV_SHUTDOWN_INITIATED: break; case SRV_SHUTDOWN_FLUSH_PHASE: case SRV_SHUTDOWN_LAST_PHASE: @@ -2508,8 +2508,7 @@ static bool srv_purge_should_exit(ulint n_purged) { - ut_ad(srv_shutdown_state == SRV_SHUTDOWN_NONE - || srv_shutdown_state == SRV_SHUTDOWN_CLEANUP); + ut_ad(srv_shutdown_state <= SRV_SHUTDOWN_CLEANUP); if (srv_undo_sources) { return(false); -- cgit v1.2.1