From b7ff2f1b59c42171ff50fc682e8f723f0713d688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 23 Jun 2015 14:36:24 +0300 Subject: [PATCH] MDEV-7472: Implementation of user statements for handling the xtradb changed page bitmaps Introduce a new dummy INFORMATION_SCHEMA.CHANGED_PAGE_BITMAPS table to XtraDB with reset_table callback to allow FLUSH NO_WRITE_TO_BINLOG CHANGED_PAGE_BITMAPS to be called from innobackupex. --- mysql-test/r/mysqld--help.result | 4 + .../innodb-flush-changed-page-bitmaps.result | 4 + .../t/innodb-flush-changed-page-bitmaps.opt | 2 + .../t/innodb-flush-changed-page-bitmaps.test | 5 + storage/xtradb/handler/ha_innodb.cc | 4 +- storage/xtradb/handler/i_s.cc | 125 ++++++++++++++++++ storage/xtradb/handler/i_s.h | 1 + 7 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb-flush-changed-page-bitmaps.result create mode 100644 mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.opt create mode 100644 mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.test diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index 8abda849494..5dfa73b5647 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -96,6 +96,9 @@ The following options may be given as the first argument: --bulk-insert-buffer-size=# Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread! + --changed-page-bitmaps[=name] + Enable or disable CHANGED_PAGE_BITMAPS plugin. One of: + ON, OFF, FORCE (don't start if the plugin fails to load). --character-set-client-handshake Don't ignore client side character set value sent during handshake. @@ -1126,6 +1129,7 @@ binlog-optimize-thread-scheduling TRUE binlog-row-event-max-size 1024 binlog-stmt-cache-size 32768 bulk-insert-buffer-size 8388608 +changed-page-bitmaps ON character-set-client-handshake TRUE character-set-filesystem binary character-set-server latin1 diff --git a/mysql-test/suite/innodb/r/innodb-flush-changed-page-bitmaps.result b/mysql-test/suite/innodb/r/innodb-flush-changed-page-bitmaps.result new file mode 100644 index 00000000000..5f098b8ecbf --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-flush-changed-page-bitmaps.result @@ -0,0 +1,4 @@ +FLUSH NO_WRITE_TO_BINLOG changed_page_bitmaps; +select * from information_schema.changed_page_bitmaps; +dummy +0 diff --git a/mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.opt b/mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.opt new file mode 100644 index 00000000000..afa6311a74b --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.opt @@ -0,0 +1,2 @@ +--changed-page-bitmaps +--innodb-track-changed-pages diff --git a/mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.test b/mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.test new file mode 100644 index 00000000000..662bbbaacaf --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-flush-changed-page-bitmaps.test @@ -0,0 +1,5 @@ +-- source include/have_xtradb.inc +-- source include/not_embedded.inc + +FLUSH NO_WRITE_TO_BINLOG changed_page_bitmaps; +select * from information_schema.changed_page_bitmaps; diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 6f053afc1ca..df883fb25e0 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -4240,7 +4240,6 @@ innobase_flush_logs( Synchronously read and parse the redo log up to the last checkpoint to write the changed page bitmap. @return 0 to indicate success. Current implementation cannot fail. */ -static my_bool innobase_flush_changed_page_bitmaps() /*=================================*/ @@ -20791,7 +20790,8 @@ i_s_innodb_changed_pages, i_s_innodb_mutexes, i_s_innodb_sys_semaphore_waits, i_s_innodb_tablespaces_encryption, -i_s_innodb_tablespaces_scrubbing +i_s_innodb_tablespaces_scrubbing, +i_s_innodb_changed_page_bitmaps maria_declare_plugin_end; /** @brief Initialize the default value of innodb_commit_concurrency. diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc index edc9e0a4f8f..d0561efb8ad 100644 --- a/storage/xtradb/handler/i_s.cc +++ b/storage/xtradb/handler/i_s.cc @@ -9459,3 +9459,128 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_semaphore_waits = STRUCT_FLD(version_info, INNODB_VERSION_STR), STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_BETA), }; + +static ST_FIELD_INFO innodb_changed_page_bitmaps_fields_info[] = +{ + {STRUCT_FLD(field_name, "dummy"), + STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), + STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), + STRUCT_FLD(old_name, ""), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + END_OF_ST_FIELD_INFO +}; + +/*******************************************************************//** +Function to populate INFORMATION_SCHEMA.CHANGED_PAGE_BITMAPS +@return 0 on success */ +static +int +fill_changed_page_bitmaps_table( +/*============================*/ + THD* thd, /*!< in: thread */ + TABLE_LIST* tables, /*!< in/out: tables to fill */ + Item* ) /*!< in: condition (not used) */ +{ + Field** fields = tables->table->field; + DBUG_ENTER("fill_changed_page_bitmaps"); + RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); + + /* deny access to user without PROCESS_ACL privilege */ + if (check_global_access(thd, PROCESS_ACL)) { + DBUG_RETURN(0); + } + OK(field_store_ulint(fields[0], 0)); + OK(schema_table_store_record(thd, tables->table)); + + DBUG_RETURN(0); +} + +/*******************************************************************//** +Flush support for changed_page_bitmaps table. +@return 0 on success */ +static +int +flush_changed_page_bitmaps() +/*========================*/ +{ + DBUG_ENTER("flush_changed_page_bitmaps"); + if (srv_track_changed_pages) { + os_event_reset(srv_checkpoint_completed_event); + log_online_follow_redo_log(); + } + DBUG_RETURN(0); +} + +/*******************************************************************//** +Bind the dynamic table INFORMATION_SCHEMA.CHANGED_PAGE_BITMAP +@return 0 on success */ +static +int +innodb_changed_page_bitmaps_init( +/*=============================*/ + void* p) /*!< in/out: table schema object */ +{ + ST_SCHEMA_TABLE* schema; + + DBUG_ENTER("innodb_changed_page_bitmaps_init"); + + schema = (ST_SCHEMA_TABLE*) p; + + schema->fields_info = innodb_changed_page_bitmaps_fields_info; + schema->fill_table = fill_changed_page_bitmaps_table; + schema->reset_table= flush_changed_page_bitmaps; + + DBUG_RETURN(0); +} + +UNIV_INTERN struct st_mysql_plugin i_s_innodb_changed_page_bitmaps = +{ + /* the plugin type (a MYSQL_XXX_PLUGIN value) */ + /* int */ + STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), + + /* pointer to type-specific plugin descriptor */ + /* void* */ + STRUCT_FLD(info, &i_s_info), + + /* plugin name */ + /* const char* */ + STRUCT_FLD(name, "CHANGED_PAGE_BITMAPS"), + + /* plugin author (for SHOW PLUGINS) */ + /* const char* */ + STRUCT_FLD(author, maria_plugin_author), + + /* general descriptive text (for SHOW PLUGINS) */ + /* const char* */ + STRUCT_FLD(descr, "XtraDB dummy changed_page_bitmaps table"), + + /* the plugin license (PLUGIN_LICENSE_XXX) */ + /* int */ + STRUCT_FLD(license, PLUGIN_LICENSE_GPL), + + /* the function to invoke when plugin is loaded */ + /* int (*)(void*); */ + STRUCT_FLD(init, innodb_changed_page_bitmaps_init), + + /* the function to invoke when plugin is unloaded */ + /* int (*)(void*); */ + STRUCT_FLD(deinit, i_s_common_deinit), + + /* plugin version (for SHOW PLUGINS) */ + /* unsigned int */ + STRUCT_FLD(version, INNODB_VERSION_SHORT), + + /* struct st_mysql_show_var* */ + STRUCT_FLD(status_vars, NULL), + + /* struct st_mysql_sys_var** */ + STRUCT_FLD(system_vars, NULL), + + /* Maria extension */ + STRUCT_FLD(version_info, INNODB_VERSION_STR), + STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_BETA), +}; + diff --git a/storage/xtradb/handler/i_s.h b/storage/xtradb/handler/i_s.h index e6e342e4357..55ef6e7ea42 100644 --- a/storage/xtradb/handler/i_s.h +++ b/storage/xtradb/handler/i_s.h @@ -67,6 +67,7 @@ extern struct st_mysql_plugin i_s_innodb_mutexes; extern struct st_maria_plugin i_s_innodb_tablespaces_encryption; extern struct st_maria_plugin i_s_innodb_tablespaces_scrubbing; extern struct st_mysql_plugin i_s_innodb_sys_semaphore_waits; +extern struct st_mysql_plugin i_s_innodb_changed_page_bitmaps; /** maximum number of buffer page info we would cache. */ #define MAX_BUF_INFO_CACHED 10000