mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
572560f38c
This allows us to avoid calculating variables (including those involving mutex) that doesn't match the given wildcard in SHOW STATUS LIKE '...' Removed all references to active_mi that could cause problems for multi-source replication. Added START|STOP ALL SLAVES Added SHOW ALL SLAVES STATUS include/mysql/plugin.h: Added SHOW_SIMPLE_FUNC include/mysql/plugin_audit.h.pp: Updated .pp file include/mysql/plugin_auth.h.pp: Updated .pp file include/mysql/plugin_ftparser.h.pp: Updated .pp file mysql-test/suite/multi_source/info_logs.result: New columns in SHOW ALL SLAVES STATUS mysql-test/suite/multi_source/info_logs.test: Test new syntax mysql-test/suite/multi_source/simple.result: New columns in SHOW ALL SLAVES STATUS mysql-test/suite/multi_source/simple.test: test new syntax mysql-test/suite/multi_source/syntax.result: Updated result mysql-test/suite/multi_source/syntax.test: Test new syntax mysql-test/suite/rpl/r/rpl_skip_replication.result: Updated result plugin/semisync/semisync_master_plugin.cc: SHOW_FUNC -> SHOW_SIMPLE_FUNC sql/item_create.cc: Simplify code sql/lex.h: Added SLAVES keyword sql/log.cc: Constant -> define sql/log_event.cc: Added comment sql/mysqld.cc: SHOW_FUNC -> SHOW_SIMPLE_FUNC Made slave_retried_trans, slave_received_heartbeats and heartbeat_period multi-source safe Clear variable denied_connections and slave_retried_transactions on startup sql/mysqld.h: Added slave_retried_transactions sql/rpl_mi.cc: create_signed_file_name -> create_logfile_name_with_suffix Added start_all_slaves() and stop_all_slaves() sql/rpl_mi.h: Added prototypes sql/rpl_rli.cc: create_signed_file_name -> create_logfile_name_with_suffix added executed_entries sql/rpl_rli.h: Added executed_entries sql/share/errmsg-utf8.txt: More and better error messages sql/slave.cc: Added more fields to SHOW ALL SLAVES STATUS Added slave_retried_transactions Changed constants -> defines sql/sql_class.h: Added comment sql/sql_insert.cc: active_mi.rli -> thd->rli_slave sql/sql_lex.h: Added SQLCOM_SLAVE_ALL_START & SQLCOM_SLAVE_ALL_STOP sql/sql_load.cc: active_mi.rli -> thd->rli_slave sql/sql_parse.cc: Added START|STOP ALL SLAVES sql/sql_prepare.cc: Added SQLCOM_SLAVE_ALL_START & SQLCOM_SLAVE_ALL_STOP sql/sql_reload.cc: Made REFRESH RELAY LOG multi-source safe sql/sql_repl.cc: create_signed_file_name -> create_logfile_name_with_suffix Don't send my_ok() from start_slave() or stop_slave() so that we can call it for all master connections sql/sql_show.cc: Compare wild cards early for all variables sql/sql_yacc.yy: Added START|STOP ALL SLAVES Added SHOW ALL SLAVES STATUS sql/sys_vars.cc: Made replicate_events_marked_for_skip,slave_net_timeout and rpl_filter multi-source safe. sql/sys_vars.h: Simplify Sys_var_rpl_filter
184 lines
6.1 KiB
C++
184 lines
6.1 KiB
C++
/* Copyright (c) 2006, 2012, Oracle and/or its affiliates.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
|
|
|
#ifndef RPL_MI_H
|
|
#define RPL_MI_H
|
|
|
|
#ifdef HAVE_REPLICATION
|
|
|
|
#include "rpl_rli.h"
|
|
#include "rpl_reporting.h"
|
|
#include "my_sys.h"
|
|
|
|
typedef struct st_mysql MYSQL;
|
|
|
|
/*****************************************************************************
|
|
Replication IO Thread
|
|
|
|
Master_info contains:
|
|
- information about how to connect to a master
|
|
- current master log name
|
|
- current master log offset
|
|
- misc control variables
|
|
|
|
Master_info is initialized once from the master.info file if such
|
|
exists. Otherwise, data members corresponding to master.info fields
|
|
are initialized with defaults specified by master-* options. The
|
|
initialization is done through init_master_info() call.
|
|
|
|
The format of master.info file:
|
|
|
|
log_name
|
|
log_pos
|
|
master_host
|
|
master_user
|
|
master_pass
|
|
master_port
|
|
master_connect_retry
|
|
|
|
To write out the contents of master.info file to disk ( needed every
|
|
time we read and queue data from the master ), a call to
|
|
flush_master_info() is required.
|
|
|
|
To clean up, call end_master_info()
|
|
|
|
*****************************************************************************/
|
|
|
|
class Master_info : public Slave_reporting_capability
|
|
{
|
|
public:
|
|
Master_info(LEX_STRING *connection_name, bool is_slave_recovery);
|
|
~Master_info();
|
|
bool shall_ignore_server_id(ulong s_id);
|
|
void clear_in_memory_info(bool all);
|
|
bool error()
|
|
{
|
|
/* If malloc() in initialization failed */
|
|
return connection_name.str == 0;
|
|
}
|
|
|
|
/* the variables below are needed because we can change masters on the fly */
|
|
char master_log_name[FN_REFLEN+6]; /* Room for multi-*/
|
|
char host[HOSTNAME_LENGTH+1];
|
|
char user[USERNAME_LENGTH+1];
|
|
char password[MAX_PASSWORD_LENGTH+1];
|
|
LEX_STRING connection_name; /* User supplied connection name */
|
|
LEX_STRING cmp_connection_name; /* Connection name in lower case */
|
|
bool ssl; // enables use of SSL connection if true
|
|
char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
|
|
char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
|
|
bool ssl_verify_server_cert;
|
|
|
|
my_off_t master_log_pos;
|
|
File fd; // we keep the file open, so we need to remember the file pointer
|
|
IO_CACHE file;
|
|
|
|
mysql_mutex_t data_lock, run_lock, sleep_lock;
|
|
mysql_cond_t data_cond, start_cond, stop_cond, sleep_cond;
|
|
THD *io_thd;
|
|
MYSQL* mysql;
|
|
uint32 file_id; /* for 3.23 load data infile */
|
|
Relay_log_info rli;
|
|
uint port;
|
|
/*
|
|
to hold checksum alg in use until IO thread has received FD.
|
|
Initialized to novalue, then set to the queried from master
|
|
@@global.binlog_checksum and deactivated once FD has been received.
|
|
*/
|
|
uint8 checksum_alg_before_fd;
|
|
uint connect_retry;
|
|
#ifndef DBUG_OFF
|
|
int events_till_disconnect;
|
|
#endif
|
|
bool inited;
|
|
volatile bool abort_slave;
|
|
volatile uint slave_running;
|
|
volatile ulong slave_run_id;
|
|
/*
|
|
The difference in seconds between the clock of the master and the clock of
|
|
the slave (second - first). It must be signed as it may be <0 or >0.
|
|
clock_diff_with_master is computed when the I/O thread starts; for this the
|
|
I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
|
|
"how late the slave is compared to the master" is computed like this:
|
|
clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master
|
|
|
|
*/
|
|
long clock_diff_with_master;
|
|
/*
|
|
Keeps track of the number of events before fsyncing.
|
|
The option --sync-master-info determines how many
|
|
events should happen before fsyncing.
|
|
*/
|
|
uint sync_counter;
|
|
float heartbeat_period; // interface with CHANGE MASTER or master.info
|
|
ulonglong received_heartbeats; // counter of received heartbeat events
|
|
DYNAMIC_ARRAY ignore_server_ids;
|
|
ulong master_id;
|
|
};
|
|
int init_master_info(Master_info* mi, const char* master_info_fname,
|
|
const char* slave_info_fname,
|
|
bool abort_if_no_master_info_file,
|
|
int thread_mask);
|
|
void end_master_info(Master_info* mi);
|
|
int flush_master_info(Master_info* mi,
|
|
bool flush_relay_log_cache,
|
|
bool need_lock_relay_log);
|
|
int change_master_server_id_cmp(ulong *id1, ulong *id2);
|
|
|
|
/*
|
|
Multi master are handled trough this struct.
|
|
Changes to this needs to be protected by LOCK_active_mi;
|
|
*/
|
|
|
|
class Master_info_index
|
|
{
|
|
private:
|
|
IO_CACHE index_file;
|
|
char index_file_name[FN_REFLEN];
|
|
|
|
public:
|
|
Master_info_index();
|
|
~Master_info_index();
|
|
|
|
HASH master_info_hash;
|
|
|
|
bool init_all_master_info();
|
|
bool write_master_name_to_index_file(LEX_STRING *connection_name,
|
|
bool do_sync);
|
|
|
|
bool check_duplicate_master_info(LEX_STRING *connection_name,
|
|
const char *host, uint port);
|
|
bool add_master_info(Master_info *mi, bool write_to_file);
|
|
bool remove_master_info(LEX_STRING *connection_name);
|
|
Master_info *get_master_info(LEX_STRING *connection_name,
|
|
MYSQL_ERROR::enum_warning_level warning);
|
|
bool give_error_if_slave_running();
|
|
bool start_all_slaves(THD *thd);
|
|
bool stop_all_slaves(THD *thd);
|
|
};
|
|
|
|
bool check_master_connection_name(LEX_STRING *name);
|
|
void create_logfile_name_with_suffix(char *res_file_name, uint length,
|
|
const char *info_file,
|
|
bool append,
|
|
LEX_STRING *suffix);
|
|
|
|
uchar *get_key_master_info(Master_info *mi, size_t *length,
|
|
my_bool not_used __attribute__((unused)));
|
|
void free_key_master_info(Master_info *mi);
|
|
|
|
|
|
#endif /* HAVE_REPLICATION */
|
|
#endif /* RPL_MI_H */
|