Skip to content

Commit 8440e8f

Browse files
committed
MDEV-11455: create status variable innodb_buffer_pool_load_incomplete
This status variable indicates that an innodb buffer pool load never completed and dumping at shutdown would result in an incomplete dump file. This status variable is set to 1 once a buffer pool loads. Upon a successful load this status variable returns to 0. With this status variable set, the system variable innodb_buffer_pool_dump_at_shutdown==1 will have no effect as dumping after an incomplete load will generate a less complete dump file than the current one. If a user aborts a buffer pool load by changing the system variable innodb_buffer_pool_load_abort=1 will cause the the status variable innodb_buffer_pool_load_incomplete to remain set to 1. A shutdown that occurs while innodb is loading the buffer pool will not save the buffer pool on shutdown. A user may indirectly set innodb_buffer_pool_load_incomplete to 0 by: * Forcing a load, by setting innodb_buffer_pool_load_now=ON, or * Forcing a dump, by setting innodb_buffer_pool_dump_now=ON This will enable the next dump on shutdown to complete. Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
1 parent afc56a5 commit 8440e8f

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

storage/innobase/buf/buf0dump.cc

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ buf_dump(
413413

414414
buf_dump_status(STATUS_INFO,
415415
"Buffer pool(s) dump completed at %s", now);
416+
417+
/* Though dumping doesn't related to an incomplete load,
418+
we reset this to 0 here to indicate that a shutdown can also perform
419+
a dump */
420+
export_vars.innodb_buffer_pool_load_incomplete = 0;
416421
}
417422

418423
/*****************************************************************//**
@@ -576,6 +581,8 @@ buf_load()
576581

577582
rewind(f);
578583

584+
export_vars.innodb_buffer_pool_load_incomplete = 1;
585+
579586
for (i = 0; i < dump_n && !SHUTTING_DOWN(); i++) {
580587
fscanf_ret = fscanf(f, ULINTPF "," ULINTPF,
581588
&space_id, &page_no);
@@ -723,8 +730,23 @@ buf_load()
723730

724731
ut_sprintf_timestamp(now);
725732

726-
buf_load_status(STATUS_INFO,
733+
if (i == dump_n) {
734+
buf_load_status(STATUS_INFO,
727735
"Buffer pool(s) load completed at %s", now);
736+
export_vars.innodb_buffer_pool_load_incomplete = 0;
737+
} else if (!buf_load_abort_flag) {
738+
buf_load_status(STATUS_INFO,
739+
"Buffer pool(s) load aborted due to user instigated abort at %s",
740+
now);
741+
/* intentionally don't reset innodb_buffer_pool_load_incomplete
742+
as we don't want a shutdown to save the buffer pool */
743+
} else {
744+
buf_load_status(STATUS_INFO,
745+
"Buffer pool(s) load aborted due to shutdown at %s",
746+
now);
747+
/* intentionally don't reset innodb_buffer_pool_load_incomplete
748+
as we want to abort without saving the buffer pool */
749+
}
728750

729751
/* Make sure that estimated = completed when we end. */
730752
/* mysql_stage_set_work_completed(pfs_stage_progress, dump_n); */
@@ -793,15 +815,16 @@ DECLARE_THREAD(buf_dump_thread)(void*)
793815
}
794816

795817
if (srv_buffer_pool_dump_at_shutdown && srv_fast_shutdown != 2) {
818+
if (export_vars.innodb_buffer_pool_load_incomplete) {
819+
buf_dump_status(STATUS_INFO,
820+
"Dumping of buffer pool not started"
821+
" as load was incomplete");
796822
#ifdef WITH_WSREP
797-
if (!wsrep_recovery) {
823+
} else if (wsrep_recovery) {
798824
#endif /* WITH_WSREP */
799-
800-
buf_dump(FALSE /* ignore shutdown down flag,
801-
keep going even if we are in a shutdown state */);
802-
#ifdef WITH_WSREP
825+
} else {
826+
buf_dump(FALSE/* do complete dump at shutdown */);
803827
}
804-
#endif /* WITH_WSREP */
805828
}
806829

807830
srv_buf_dump_thread_active = false;

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,8 @@ static SHOW_VAR innodb_status_variables[]= {
931931
(char*) &export_vars.innodb_buffer_pool_load_status, SHOW_CHAR},
932932
{"buffer_pool_resize_status",
933933
(char*) &export_vars.innodb_buffer_pool_resize_status, SHOW_CHAR},
934+
{"buffer_pool_load_incomplete",
935+
&export_vars.innodb_buffer_pool_load_incomplete, SHOW_BOOL},
934936
{"buffer_pool_pages_data",
935937
(char*) &export_vars.innodb_buffer_pool_pages_data, SHOW_LONG},
936938
{"buffer_pool_bytes_data",

storage/innobase/include/srv0srv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@ struct export_var_t{
946946
char innodb_buffer_pool_dump_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool dump status */
947947
char innodb_buffer_pool_load_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool load status */
948948
char innodb_buffer_pool_resize_status[512];/*!< Buf pool resize status */
949+
my_bool innodb_buffer_pool_load_incomplete;/*!< Buf pool load incomplete */
949950
ulint innodb_buffer_pool_pages_total; /*!< Buffer pool size */
950951
ulint innodb_buffer_pool_pages_data; /*!< Data pages */
951952
ulint innodb_buffer_pool_bytes_data; /*!< File bytes used */

0 commit comments

Comments
 (0)