Implement a Performance Schema (P_S) for the information returned by SHOW SLAVE STATUS. Benefits: - the information on slave status can be searched with ad hoc queries; - pieces of that info can be assigned to variables, and thus used in stored procedures; - easies testing to let SELECT item from P_S.slave_status; (related to WL#3657) Earlier implemented as I_S plugin https://launchpad.net/is-replication-status unfortunately does not fit to definition of I_S which is to contain the meta info not any kind of transient data. ------------- Status update, 2010-09-03 Need to investigate the possible overlap / integration with WL#2775 System tables for master.info, relay_log.info. More ideas for the data exported through the P_S plugin (2011-02-04): - http://www.facebook.com/notes/mysql-at-facebook/more-updates-to-the-facebook-patch-for-mysql/497840690932 - https://intranet.mysql.com/secure/forum/read.php?62,154412,154412#msg-154412 RELATED BUGS ============ | MySQL BUG# | Oracle BUG# | STATUS | |------------+--------------+----------| | BUG#50316 | BUG#11758151 | CLOSED | | BUG#56414 | BUG#11763673 | VERIFIED | | BUG#35994 | BUG#11748348 | VERIFIED | |------------+--------------+----------|
S0. The new table must follow all conventions of P_S database, incl.
the table definition is static and therefore to exists at bootstrap.
S1. The new table must have one record per connected master (currently one in
total because of the single master only implementation).
The record has so many attributes as many lines Show-Slave-Status displays.
The type of the attributes correspond to their internal representation in
the server.
S2. It must be not-updatable by the user.
S3. It must be upgradable e.g to let add a new attribute.
Considering that the static code implementation suffices multiple creteria
such as matches actually static implementation of binary logging and
replication, does not create any significant burden neither on memory nor cpu
usage etc
it is chosen for implementation.
1. The exact table definition
mysql> show create table performance_schema.SLAVE_STATUS\G
*************************** 1. row ***************************
Table: SLAVE_STATUS
Create Table: CREATE TABLE `SLAVE_STATUS` (
Slave_IO_State varchar (1024),
Master_Host varchar (60) CHARACTER SET utf8 COLLATE utf8_bin,
Master_User varchar (16) CHARACTER SET utf8 COLLATE utf8_bin,
Master_Port int,
Connect_Retry int,
Master_Log_File varchar (FN_REFLEN),
Read_Master_Log_Pos int,
Relay_Log_File varchar (FN_REFLEN),
Relay_Log_Pos int,
Relay_Master_Log_File varchar (FN_REFLEN),
Slave_IO_Running ENUM('Yes', 'No', 'Connecting'),
Slave_SQL_Running ENUM('Yes', 'No'),
Replicate_Do_DB text,
Replicate_Ignore_DB text,
Replicate_Do_Table text,
Replicate_Ignore_Table text,
Replicate_Wild_Do_Table text,
Replicate_Wild_Ignore_Table text,
Last_Errno int,
Last_Error varchar (MAX_SLAVE_ERRMSG) /* The size is chosen according to
replication specific buffer that exceeds main_da's MYSQL_ERRMSG_SIZE */,
Skip_Counter int,
Exec_Master_Log_Pos int,
Relay_Log_Space int,
Until_Condition ENUM('None', 'Master', 'Relay'),
Until_Log_File varchar (FN_REFLEN),
Until_Log_Pos int,
Master_SSL_Allowed ENUM('Yes', 'No', 'Ignored'),
Master_SSL_CA_File varchar (FN_REFLEN),
Master_SSL_CA_Path varchar (FN_REFLEN),
Master_SSL_Cert varchar (FN_REFLEN),
Master_SSL_Cipher varchar (FN_REFLEN),
Master_SSL_Key varchar (FN_REFLEN),
Seconds_Behind_Master int,
Master_SSL_Verify_Server_Cert ENUM('Yes', 'No'),
Last_IO_Errno int,
Last_IO_Error varchar (MAX_SLAVE_ERRMSG),
Last_SQL_Errno int,
Last_SQL_Error varchar (MAX_SLAVE_ERRMSG),
Replicate_Ignore_Server_Ids varchar (FN_REFLEN),
Master_Server_Id int,
Master_UUID char(255),
SQL_Delay int,
SQL_Remaining_Delay int,
Slave_SQL_Running_State ENUM('Yes', 'No'),
Master_Retry_Count int
) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
is added to mysql_system_table.sql bootstrap script.
Notice, the following attributes
Replicate_{Do,Ignore,Wild}-*,
Replicate_Ignore_Server_Ids
have internal server's representation of special types that do not
have SQL equivalent. As the classic Show-Slave-Status so the current
implementation regards them as strings.
2. There is no need for specific instrumentation tools. The table
is to be populated via executing similar to show_master_info() code
(or refactored version of the function to serve two callers)
at time SELECT on performance_schema.SLAVE_STATUS is invoked.
Population is done by filling all (40 atm) fields (that is
regardless of is being SELECT-ed) in table_slave_status::rnd_pos() (see
further stuct:s definitions).
3. To follow the P_S extendability convention a few new classes
are defined to provide populating and return to
handler::rnd_next() found data.
Here is the main class declaration:
/** Table PERFORMANCE_SCHEMA.SLAVE_STATUS. */
class table_slave_status : public PFS_engine_table
{
public:
/** Table share. */
static PFS_engine_table_share m_share;
static PFS_engine_table* create();
virtual int rnd_next();
virtual int rnd_pos(const void *pos);
virtual void reset_position(void);
protected:
virtual int read_row_values(TABLE *table,
unsigned char *buf,
Field **fields,
bool read_all);
protected:
table_slave_status();
public:
~table_slave_status();
private:
void fill_rows(Master_info *);
void drop_null(enum enum_field_names f_name);
void set_null(enum enum_field_names f_name);
void str_store(int index, const char* from);
void int_store(int index, long int val, int radix);
void longlong_store(int index, longlong val, int radix);
/** Table share lock. */
static THR_LOCK m_table_lock;
/** Fields definition. */
static TABLE_FIELD_DEF m_field_def;
/** Current row. It's the single master framework, hence one row */
row_slave_status m_row;
/** True is the table is filled up, no need to prepare it again */
bool m_filled;
/** Current position. */
PFS_simple_index m_pos;
/** Next position. */
PFS_simple_index m_next_pos;
};
Note:
-----
For comparison, the implementation of SHOW SLAVE STATUS
is located in sql/rpl_master.cc, show_master_info().
