mariadb/sql/rpl_mi.cc

442 lines
14 KiB
C++
Raw Normal View History

/* Copyright (C) 2000-2003 MySQL AB
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
Many files: Changed header to GPL version 2 only client/mysqlslap.c: Changed header to GPL version 2 only include/atomic/nolock.h: Changed header to GPL version 2 only include/atomic/rwlock.h: Changed header to GPL version 2 only include/atomic/x86-gcc.h: Changed header to GPL version 2 only include/atomic/x86-msvc.h: Changed header to GPL version 2 only include/my_atomic.h: Changed header to GPL version 2 only include/my_trie.h: Changed header to GPL version 2 only include/my_vle.h: Changed header to GPL version 2 only include/mysql/plugin.h: Changed header to GPL version 2 only mysys/my_atomic.c: Changed header to GPL version 2 only mysys/my_getncpus.c: Changed header to GPL version 2 only mysys/my_memmem.c: Changed header to GPL version 2 only mysys/my_vle.c: Changed header to GPL version 2 only mysys/trie.c: Changed header to GPL version 2 only plugin/Makefile.am: Changed header to GPL version 2 only server-tools/instance-manager/IMService.h: Changed header to GPL version 2 only server-tools/instance-manager/WindowsService.h: Changed header to GPL version 2 only server-tools/instance-manager/exit_codes.h: Changed header to GPL version 2 only server-tools/instance-manager/user_management_commands.h: Changed header to GPL version 2 only sql/authors.h: Changed header to GPL version 2 only sql/contributors.h: Changed header to GPL version 2 only sql/event_data_objects.cc: Changed header to GPL version 2 only sql/event_data_objects.h: Changed header to GPL version 2 only sql/event_db_repository.cc: Changed header to GPL version 2 only sql/event_db_repository.h: Changed header to GPL version 2 only sql/event_queue.cc: Changed header to GPL version 2 only sql/event_queue.h: Changed header to GPL version 2 only sql/event_scheduler.cc: Changed header to GPL version 2 only sql/event_scheduler.h: Changed header to GPL version 2 only sql/events.cc: Changed header to GPL version 2 only sql/events.h: Changed header to GPL version 2 only sql/ha_ndbcluster_binlog.cc: Changed header to GPL version 2 only sql/ha_ndbcluster_binlog.h: Changed header to GPL version 2 only sql/ha_ndbcluster_tables.h: Changed header to GPL version 2 only sql/ha_partition.cc: Changed header to GPL version 2 only sql/ha_partition.h: Changed header to GPL version 2 only sql/item_xmlfunc.cc: Changed header to GPL version 2 only sql/item_xmlfunc.h: Changed header to GPL version 2 only sql/log.h: Changed header to GPL version 2 only sql/partition_element.h: Changed header to GPL version 2 only sql/partition_info.cc: Changed header to GPL version 2 only sql/partition_info.h: Changed header to GPL version 2 only sql/rpl_filter.cc: Changed header to GPL version 2 only sql/rpl_filter.h: Changed header to GPL version 2 only sql/rpl_injector.cc: Changed header to GPL version 2 only sql/rpl_injector.h: Changed header to GPL version 2 only sql/rpl_mi.cc: Changed header to GPL version 2 only sql/rpl_mi.h: Changed header to GPL version 2 only sql/rpl_rli.cc: Changed header to GPL version 2 only sql/rpl_rli.h: Changed header to GPL version 2 only sql/rpl_tblmap.cc: Changed header to GPL version 2 only sql/rpl_tblmap.h: Changed header to GPL version 2 only sql/rpl_utility.cc: Changed header to GPL version 2 only sql/rpl_utility.h: Changed header to GPL version 2 only sql/sql_binlog.cc: Changed header to GPL version 2 only sql/sql_partition.cc: Changed header to GPL version 2 only sql/sql_partition.h: Changed header to GPL version 2 only sql/sql_plugin.cc: Changed header to GPL version 2 only sql/sql_plugin.h: Changed header to GPL version 2 only sql/sql_servers.cc: Changed header to GPL version 2 only sql/sql_servers.h: Changed header to GPL version 2 only sql/sql_tablespace.cc: Changed header to GPL version 2 only sql/sql_yacc.yy.bak: Changed header to GPL version 2 only storage/Makefile.am: Changed header to GPL version 2 only storage/archive/Makefile.am: Changed header to GPL version 2 only storage/blackhole/Makefile.am: Changed header to GPL version 2 only storage/csv/Makefile.am: Changed header to GPL version 2 only storage/example/Makefile.am: Changed header to GPL version 2 only storage/federated/Makefile.am: Changed header to GPL version 2 only storage/innobase/handler/Makefile.am: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/AllocNodeId.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/CreateObj.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/DictObjOp.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/DihFragCount.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/DropFilegroup.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/DropObj.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/Extent.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/RestoreImpl.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/RouteOrd.hpp: Changed header to GPL version 2 only storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp: Changed header to GPL version 2 only storage/ndb/include/ndbapi/NdbIndexStat.hpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp: Changed header to GPL version 2 only storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/diskpage.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/lgman.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/lgman.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/pgman.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/pgman.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/print_file.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/record_types.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/restore.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/restore.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/tsman.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/blocks/tsman.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/DLCFifoList.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/DLCHashTable.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/DynArr256.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/DynArr256.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/KeyTable2Ref.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/LinearPool.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/NdbdSuperPool.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/NdbdSuperPool.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/Pool.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/Pool.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/RWPool.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/RWPool.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/Rope.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/SLFifoList.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/WOPool.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/WOPool.hpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/bench_pool.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp: Changed header to GPL version 2 only storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp: Changed header to GPL version 2 only storage/ndb/src/mgmsrv/ParamInfo.cpp: Changed header to GPL version 2 only storage/ndb/src/ndbapi/NdbIndexStat.cpp: Changed header to GPL version 2 only storage/ndb/test/ndbapi/testIndexStat.cpp: Changed header to GPL version 2 only storage/ndb/test/tools/listen.cpp: Changed header to GPL version 2 only storage/ndb/tools/restore/ndb_nodegroup_map.h: Changed header to GPL version 2 only strings/my_strchr.c: Changed header to GPL version 2 only unittest/mysys/base64-t.c: Changed header to GPL version 2 only unittest/mysys/bitmap-t.c: Changed header to GPL version 2 only unittest/mysys/my_atomic-t.c: Changed header to GPL version 2 only unittest/mytap/tap.c: Changed header to GPL version 2 only unittest/mytap/tap.h: Changed header to GPL version 2 only win/Makefile.am: Changed header to GPL version 2 only
2006-12-27 02:23:51 +01:00
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_global.h> // For HAVE_REPLICATION
#include "mysql_priv.h"
#include <my_dir.h>
#include "rpl_mi.h"
#ifdef HAVE_REPLICATION
Master_info::Master_info()
BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached): Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively. Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and Last_SQL_Errno respectively. Fields are added last to output of SHOW SLAVE STATUS to allow old applications to use the same positional arguments into the row, while allowing new application to benefit from the added information. In addition, some new error codes are added (especially for the I/O thread) to be able to provide sensible error message. mysql-test/extra/rpl_tests/rpl_max_relay_size.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/r/binlog_row_mix_innodb_myisam.result: Result change mysql-test/r/rpl_000015.result: Result change mysql-test/r/rpl_change_master.result: Result change mysql-test/r/rpl_deadlock_innodb.result: Result change mysql-test/r/rpl_empty_master_crash.result: Result change mysql-test/r/rpl_extraCol_innodb.result: Result change --- Result change. mysql-test/r/rpl_extraCol_myisam.result: Result change --- Result change. mysql-test/r/rpl_flushlog_loop.result: Result change mysql-test/r/rpl_loaddata.result: Result change mysql-test/r/rpl_log_pos.result: Result change mysql-test/r/rpl_ndb_basic.result: Result change mysql-test/r/rpl_ndb_extraCol.result: Result change --- Result change. mysql-test/r/rpl_ndb_idempotent.result: Result change mysql-test/r/rpl_ndb_log.result: Result change mysql-test/r/rpl_openssl.result: Result change mysql-test/r/rpl_rbr_to_sbr.result: Result change mysql-test/r/rpl_redirect.result: Result change mysql-test/r/rpl_replicate_do.result: Result change mysql-test/r/rpl_rotate_logs.result: Result change mysql-test/r/rpl_row_inexist_tbl.result: Result change mysql-test/r/rpl_row_log.result: Result change mysql-test/r/rpl_row_log_innodb.result: Result change mysql-test/r/rpl_row_max_relay_size.result: Result change mysql-test/r/rpl_row_reset_slave.result: Result change mysql-test/r/rpl_row_tabledefs_2myisam.result: Result change --- Result change. mysql-test/r/rpl_row_tabledefs_3innodb.result: Result change --- Result change. mysql-test/r/rpl_row_until.result: Result change mysql-test/r/rpl_server_id1.result: Result change mysql-test/r/rpl_server_id2.result: Result change mysql-test/r/rpl_slave_status.result: Result change mysql-test/r/rpl_stm_log.result: Result change mysql-test/r/rpl_stm_max_relay_size.result: Result change --- Result change. mysql-test/r/rpl_stm_reset_slave.result: Result change mysql-test/r/rpl_stm_until.result: Result change mysql-test/t/binlog_row_mix_innodb_myisam.test: Test fixed. mysql-test/t/rpl_000015.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_change_master.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_empty_master_crash.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_flushlog_loop.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_log_pos.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_bank.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_basic.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_idempotent.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_sync.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_openssl.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_rbr_to_sbr.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_redirect.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_replicate_do.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_rotate_logs.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_row_inexist_tbl.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_row_until.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_server_id1.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_server_id2.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_slave_status.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_stm_until.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno sql/Makefile.am: Adding new files sql/log_event.cc: Changes to use Slave_reporting_capability for reporting errors. Adding debug variable to stop slave with an out-of-memory error or with a fatal error. The checks are put both in the new Execute_load_query_ log_event and in the old Load_log_event which is used for Execute_load_ log_event. Adding code to generate fatal error message. Eliminating redundant arguments when printing ER_NO_DEFAULT_FOR_FIELD message. sql/rpl_mi.cc: Using Slave_reporting_capability for error reporting. sql/rpl_mi.h: Using Slave_reporting_capability to handle I/O thread errors and other messages. sql/rpl_rli.cc: Using Slave_reporting_capability to handle SQL thread errors and other messages. sql/rpl_rli.h: Changes to use Slave_reporting_capability for reporting SQL thread error and other messages. sql/rpl_utility.cc: Changes to use Slave_reporting_capability for reporting errors. sql/slave.cc: Changes to use Slave_reporting_capability for reporting errors. sql/slave.h: Removing slave_print_msg() sql/share/errmsg.txt: New error messages. Making message for ER_NO_DEFAULT_FOR_FIELD consistent over languages (actually restoring old message). Adding argument to ER_SLAVE_FATAL_ERROR message. sql/sql_repl.cc: Using new names for thread masks. mysql-test/t/rpl_loaddata_fatal-slave.opt: New BitKeeper file ``mysql-test/t/rpl_loaddata_fatal-slave.opt'' sql/rpl_reporting.cc: New BitKeeper file ``sql/rpl_reporting.cc'' sql/rpl_reporting.h: New BitKeeper file ``sql/rpl_reporting.h'' mysql-test/include/show_slave_status.inc: New BitKeeper file ``mysql-test/include/show_slave_status.inc'' mysql-test/r/rpl_loaddata_fatal.result: New BitKeeper file ``mysql-test/r/rpl_loaddata_fatal.result'' mysql-test/t/rpl_loaddata_fatal.test: New BitKeeper file ``mysql-test/t/rpl_loaddata_fatal.test''
2007-06-09 07:19:37 +02:00
:Slave_reporting_capability("I/O"),
ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), inited(0),
abort_slave(0),slave_running(0),
slave_run_id(0)
{
host[0] = 0; user[0] = 0; password[0] = 0;
ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
ssl_cipher[0]= 0; ssl_key[0]= 0;
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
bzero((char*) &file, sizeof(file));
WL#3262 add mutex lock order checking to safemutex (also called safe_mutex_deadlock_detector) This writes a warning on stderr if one uses mutex in different order, like if one in one case would lock mutex in the order A,B and in another case would lock mutex in the order B,A This is inspired by and loosely based on the LOCKDEP patch by Jonas Wrong mutex order is either fixed or mutex are marked with MYF_NO_DEADLOCK_DETECTION if used inconsistently (need to be fixed by server team) KNOWN_BUGS.txt: Added information that one need to dump and restore Maria tables include/hash.h: Added prototype function for walking over all elements in a hash include/my_pthread.h: Added my_pthread_mutex_init() and my_pthread_mutex_lock(); These should be used if one wants to disable mutex order checking. Changed names of the nonposix mutex_init functions to not conflict with my_phread_mutex_init() Added and extended structures for mutex deadlock detection. New arguments to sage_mutex_init() and safe_mutex_lock() to allow one to disable mutex order checking. Added variable 'safe_mutex_deadlock_detector' to enable/disable deadlock detection for all pthread_mutex_init() mysys/Makefile.am: Added cleaning of test files Added test_thr_mutex mysys/hash.c: Added hash_iterate() to iterate over all elements in a hash More comments mysys/my_init.c: Added calls to destory all mutex uses by mysys() Added waiting for threads to end before calling TERMINATE() to list not freed memory mysys/my_pthread.c: Changed names to free my_pthread_mutex_init() for mutex-lock-order-checking mysys/my_sleep.c: Fixed too long wait if using 1000000L as argument mysys/my_thr_init.c: Mark THR_LOCK_threads and THR_LOCK_malloc to not have mutex deadlock detection. (We can't have it enabled for this as these are internal mutex used by the detector Call my_thread_init() early as we need thread specific variables enabled for the following pthread_mutex_init() Move code to wait for threads to end to my_wait_for_other_threads_to_die() Don't destroy mutex and conditions unless all threads have died Added my_thread_destroy_mutex() to destroy all mutex used by the mysys thread system Name the thread specific mutex as "mysys_var->mutex" Added my_thread_var_mutex_in_use() to return pointer to mutex in use or 0 if thread variables are not initialized mysys/mysys_priv.h: Added prototypes for functions used internally with mutex-wrong-usage detection mysys/thr_mutex.c: Added runtime detection of mutex used in conflicting order See WL#3262 or test_thr_mutex.c for examples The base idea is for each mutex have two hashes: - mutex->locked_mutex points to all mutex used after this one - mutex->used_mutex points to all mutex which has this mutex in it's mutex->locked_mutex There is a wrong mutex order if any mutex currently locked before this mutex is in the mutex->locked_mutex hash sql/event_queue.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/event_scheduler.cc: Declare the right order to take the mutex sql/events.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/ha_ndbcluster_binlog.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/log.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/mysqld.cc: Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex. Added call to free sp cache. Add destruction of LOCK_server_started and COND_server_started. Added register_mutex_order() function to register in which order mutex should be taken (to initiailize mutex_deadlock_detector). Added option to turn off safe_mutex_deadlock_detector sql/protocol.cc: Fixed wrong argument to DBUG_PRINT (found by valgrind) sql/rpl_mi.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/set_var.cc: Remove wrong locking of LOCK_global_system_variables when reading and setting log variables (would cause inconsistent mutex order). Update global variables outside of logger.unlock() as LOCK_global_system_variables has to be taken before logger locks Reviewed by gluh sql/sp_cache.cc: Added function to destroy mutex used by sp cache sql/sp_cache.h: Added function to destroy mutex used by sp cache sql/sql_class.cc: Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex. Register order in which LOCK_delete and mysys_var->mutex is taken sql/sql_insert.cc: Give a name for Delayed_insert::mutex Mark mutex used inconsistently (need to be fixed by server team) Move closing of tables outside of di->mutex (to avoid wrong mutex order) sql/sql_show.cc: Don't keep LOCK_global_system_variables locked over value->show_type() as this leads to wrong mutex order storage/innobase/handler/ha_innodb.cc: Disable safe_muted_deadlock_detector for innobase intern mutex (to speed up page cache initialization) storage/maria/ha_maria.cc: Added flag to ha_maria::info() to signal if we need to lock table share or not. This is needed to avoid locking mutex in wrong order storage/maria/ha_maria.h: Added flag to ha_maria::info() to signal if we need to lock table share or not. storage/maria/ma_close.c: Destroy key_del_lock Simplify freeing ftparser_param storage/maria/ma_key.c: Better comment storage/maria/ma_loghandler.c: Mark mutex used inconsistently (need to be fixed by sanja) storage/maria/ma_state.c: More comments storage/maria/ma_test1.c: Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety) storage/maria/ma_test2.c: Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety)
2008-12-02 23:02:52 +01:00
/*
We have to use MYF_NO_DEADLOCK_DETECTION because mysqld doesn't
lock run_lock and data_lock consistently.
Should be fixed as this can easily lead to deadlocks
*/
my_pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST,
"Master_info::run_lock", MYF_NO_DEADLOCK_DETECTION);
my_pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST,
"Master_info::data_lock", MYF_NO_DEADLOCK_DETECTION);
pthread_cond_init(&data_cond, NULL);
pthread_cond_init(&start_cond, NULL);
pthread_cond_init(&stop_cond, NULL);
WL#3262 add mutex lock order checking to safemutex (also called safe_mutex_deadlock_detector) This writes a warning on stderr if one uses mutex in different order, like if one in one case would lock mutex in the order A,B and in another case would lock mutex in the order B,A This is inspired by and loosely based on the LOCKDEP patch by Jonas Wrong mutex order is either fixed or mutex are marked with MYF_NO_DEADLOCK_DETECTION if used inconsistently (need to be fixed by server team) KNOWN_BUGS.txt: Added information that one need to dump and restore Maria tables include/hash.h: Added prototype function for walking over all elements in a hash include/my_pthread.h: Added my_pthread_mutex_init() and my_pthread_mutex_lock(); These should be used if one wants to disable mutex order checking. Changed names of the nonposix mutex_init functions to not conflict with my_phread_mutex_init() Added and extended structures for mutex deadlock detection. New arguments to sage_mutex_init() and safe_mutex_lock() to allow one to disable mutex order checking. Added variable 'safe_mutex_deadlock_detector' to enable/disable deadlock detection for all pthread_mutex_init() mysys/Makefile.am: Added cleaning of test files Added test_thr_mutex mysys/hash.c: Added hash_iterate() to iterate over all elements in a hash More comments mysys/my_init.c: Added calls to destory all mutex uses by mysys() Added waiting for threads to end before calling TERMINATE() to list not freed memory mysys/my_pthread.c: Changed names to free my_pthread_mutex_init() for mutex-lock-order-checking mysys/my_sleep.c: Fixed too long wait if using 1000000L as argument mysys/my_thr_init.c: Mark THR_LOCK_threads and THR_LOCK_malloc to not have mutex deadlock detection. (We can't have it enabled for this as these are internal mutex used by the detector Call my_thread_init() early as we need thread specific variables enabled for the following pthread_mutex_init() Move code to wait for threads to end to my_wait_for_other_threads_to_die() Don't destroy mutex and conditions unless all threads have died Added my_thread_destroy_mutex() to destroy all mutex used by the mysys thread system Name the thread specific mutex as "mysys_var->mutex" Added my_thread_var_mutex_in_use() to return pointer to mutex in use or 0 if thread variables are not initialized mysys/mysys_priv.h: Added prototypes for functions used internally with mutex-wrong-usage detection mysys/thr_mutex.c: Added runtime detection of mutex used in conflicting order See WL#3262 or test_thr_mutex.c for examples The base idea is for each mutex have two hashes: - mutex->locked_mutex points to all mutex used after this one - mutex->used_mutex points to all mutex which has this mutex in it's mutex->locked_mutex There is a wrong mutex order if any mutex currently locked before this mutex is in the mutex->locked_mutex hash sql/event_queue.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/event_scheduler.cc: Declare the right order to take the mutex sql/events.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/ha_ndbcluster_binlog.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/log.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/mysqld.cc: Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex. Added call to free sp cache. Add destruction of LOCK_server_started and COND_server_started. Added register_mutex_order() function to register in which order mutex should be taken (to initiailize mutex_deadlock_detector). Added option to turn off safe_mutex_deadlock_detector sql/protocol.cc: Fixed wrong argument to DBUG_PRINT (found by valgrind) sql/rpl_mi.cc: Mark mutex used inconsistently (need to be fixed by server team) sql/set_var.cc: Remove wrong locking of LOCK_global_system_variables when reading and setting log variables (would cause inconsistent mutex order). Update global variables outside of logger.unlock() as LOCK_global_system_variables has to be taken before logger locks Reviewed by gluh sql/sp_cache.cc: Added function to destroy mutex used by sp cache sql/sp_cache.h: Added function to destroy mutex used by sp cache sql/sql_class.cc: Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex. Register order in which LOCK_delete and mysys_var->mutex is taken sql/sql_insert.cc: Give a name for Delayed_insert::mutex Mark mutex used inconsistently (need to be fixed by server team) Move closing of tables outside of di->mutex (to avoid wrong mutex order) sql/sql_show.cc: Don't keep LOCK_global_system_variables locked over value->show_type() as this leads to wrong mutex order storage/innobase/handler/ha_innodb.cc: Disable safe_muted_deadlock_detector for innobase intern mutex (to speed up page cache initialization) storage/maria/ha_maria.cc: Added flag to ha_maria::info() to signal if we need to lock table share or not. This is needed to avoid locking mutex in wrong order storage/maria/ha_maria.h: Added flag to ha_maria::info() to signal if we need to lock table share or not. storage/maria/ma_close.c: Destroy key_del_lock Simplify freeing ftparser_param storage/maria/ma_key.c: Better comment storage/maria/ma_loghandler.c: Mark mutex used inconsistently (need to be fixed by sanja) storage/maria/ma_state.c: More comments storage/maria/ma_test1.c: Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety) storage/maria/ma_test2.c: Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety)
2008-12-02 23:02:52 +01:00
#ifdef SAFE_MUTEX
/* Define mutex order for locks to find wrong lock usage */
pthread_mutex_lock(&data_lock);
pthread_mutex_lock(&run_lock);
pthread_mutex_unlock(&run_lock);
pthread_mutex_unlock(&data_lock);
#endif
}
Master_info::~Master_info()
{
pthread_mutex_destroy(&run_lock);
pthread_mutex_destroy(&data_lock);
pthread_cond_destroy(&data_cond);
pthread_cond_destroy(&start_cond);
pthread_cond_destroy(&stop_cond);
}
void init_master_info_with_options(Master_info* mi)
{
DBUG_ENTER("init_master_info_with_options");
mi->master_log_name[0] = 0;
mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number
if (master_host)
strmake(mi->host, master_host, sizeof(mi->host) - 1);
if (master_user)
strmake(mi->user, master_user, sizeof(mi->user) - 1);
if (master_password)
strmake(mi->password, master_password, MAX_PASSWORD_LENGTH);
mi->port = master_port;
mi->connect_retry = master_connect_retry;
mi->ssl= master_ssl;
if (master_ssl_ca)
strmake(mi->ssl_ca, master_ssl_ca, sizeof(mi->ssl_ca)-1);
if (master_ssl_capath)
strmake(mi->ssl_capath, master_ssl_capath, sizeof(mi->ssl_capath)-1);
if (master_ssl_cert)
strmake(mi->ssl_cert, master_ssl_cert, sizeof(mi->ssl_cert)-1);
if (master_ssl_cipher)
strmake(mi->ssl_cipher, master_ssl_cipher, sizeof(mi->ssl_cipher)-1);
if (master_ssl_key)
strmake(mi->ssl_key, master_ssl_key, sizeof(mi->ssl_key)-1);
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
/* Intentionally init ssl_verify_server_cert to 0, no option available */
mi->ssl_verify_server_cert= 0;
DBUG_VOID_RETURN;
}
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
enum {
LINES_IN_MASTER_INFO_WITH_SSL= 14,
/* 5.1.16 added value of master_ssl_verify_server_cert */
LINE_FOR_MASTER_SSL_VERIFY_SERVER_CERT= 15,
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
/* Number of lines currently used when saving master info file */
LINES_IN_MASTER_INFO= LINE_FOR_MASTER_SSL_VERIFY_SERVER_CERT
};
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)
{
int fd,error;
char fname[FN_REFLEN+128];
DBUG_ENTER("init_master_info");
if (mi->inited)
{
/*
We have to reset read position of relay-log-bin as we may have
already been reading from 'hotlog' when the slave was stopped
last time. If this case pos_in_file would be set and we would
get a crash when trying to read the signature for the binary
relay log.
We only rewind the read position if we are starting the SQL
thread. The handle_slave_sql thread assumes that the read
position is at the beginning of the file, and will read the
"signature" and then fast-forward to the last position read.
*/
if (thread_mask & SLAVE_SQL)
{
my_b_seek(mi->rli.cur_log, (my_off_t) 0);
}
DBUG_RETURN(0);
}
mi->mysql=0;
mi->file_id=1;
fn_format(fname, master_info_fname, mysql_data_home, "", 4+32);
/*
We need a mutex while we are changing master info parameters to
keep other threads from reading bogus info
*/
pthread_mutex_lock(&mi->data_lock);
fd = mi->fd;
/* does master.info exist ? */
if (access(fname,F_OK))
{
if (abort_if_no_master_info_file)
{
pthread_mutex_unlock(&mi->data_lock);
DBUG_RETURN(0);
}
/*
if someone removed the file from underneath our feet, just close
the old descriptor and re-create the old file
*/
if (fd >= 0)
my_close(fd, MYF(MY_WME));
if ((fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{
sql_print_error("Failed to create a new master info file (\
file '%s', errno %d)", fname, my_errno);
goto err;
}
if (init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,0,
MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on master info file (\
file '%s')", fname);
goto err;
}
mi->fd = fd;
init_master_info_with_options(mi);
}
else // file exists
{
if (fd >= 0)
reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0);
else
{
if ((fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{
sql_print_error("Failed to open the existing master info file (\
file '%s', errno %d)", fname, my_errno);
goto err;
}
if (init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,
0, MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on master info file (\
file '%s')", fname);
goto err;
}
}
mi->fd = fd;
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
int port, connect_retry, master_log_pos, lines;
int ssl= 0, ssl_verify_server_cert= 0;
char *first_non_digit;
/*
Starting from 4.1.x master.info has new format. Now its
first line contains number of lines in file. By reading this
number we will be always distinguish to which version our
master.info corresponds to. We can't simply count lines in
file since versions before 4.1.x could generate files with more
lines than needed.
If first line doesn't contain a number or contain number less than
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
LINES_IN_MASTER_INFO_WITH_SSL then such file is treated like file
from pre 4.1.1 version.
There is no ambiguity when reading an old master.info, as before
4.1.1, the first line contained the binlog's name, which is either
empty or has an extension (contains a '.'), so can't be confused
with an integer.
So we're just reading first line and trying to figure which version
is this.
*/
/*
The first row is temporarily stored in mi->master_log_name,
if it is line count and not binlog name (new format) it will be
overwritten by the second row later.
*/
if (init_strvar_from_file(mi->master_log_name,
sizeof(mi->master_log_name), &mi->file,
""))
goto errwithmsg;
lines= strtoul(mi->master_log_name, &first_non_digit, 10);
if (mi->master_log_name[0]!='\0' &&
*first_non_digit=='\0' && lines >= LINES_IN_MASTER_INFO_WITH_SSL)
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
{
/* Seems to be new format => read master log name from next line */
if (init_strvar_from_file(mi->master_log_name,
sizeof(mi->master_log_name), &mi->file, ""))
goto errwithmsg;
}
else
lines= 7;
if (init_intvar_from_file(&master_log_pos, &mi->file, 4) ||
init_strvar_from_file(mi->host, sizeof(mi->host), &mi->file,
master_host) ||
init_strvar_from_file(mi->user, sizeof(mi->user), &mi->file,
master_user) ||
init_strvar_from_file(mi->password, SCRAMBLED_PASSWORD_CHAR_LENGTH+1,
&mi->file, master_password) ||
init_intvar_from_file(&port, &mi->file, master_port) ||
init_intvar_from_file(&connect_retry, &mi->file,
master_connect_retry))
goto errwithmsg;
/*
If file has ssl part use it even if we have server without
SSL support. But these option will be ignored later when
slave will try connect to master, so in this case warning
is printed.
*/
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
if (lines >= LINES_IN_MASTER_INFO_WITH_SSL)
{
if (init_intvar_from_file(&ssl, &mi->file, master_ssl) ||
init_strvar_from_file(mi->ssl_ca, sizeof(mi->ssl_ca),
&mi->file, master_ssl_ca) ||
init_strvar_from_file(mi->ssl_capath, sizeof(mi->ssl_capath),
&mi->file, master_ssl_capath) ||
init_strvar_from_file(mi->ssl_cert, sizeof(mi->ssl_cert),
&mi->file, master_ssl_cert) ||
init_strvar_from_file(mi->ssl_cipher, sizeof(mi->ssl_cipher),
&mi->file, master_ssl_cipher) ||
init_strvar_from_file(mi->ssl_key, sizeof(mi->ssl_key),
&mi->file, master_ssl_key))
goto errwithmsg;
/*
Starting from 5.1.16 ssl_verify_server_cert might be
in the file
*/
if (lines >= LINE_FOR_MASTER_SSL_VERIFY_SERVER_CERT &&
init_intvar_from_file(&ssl_verify_server_cert, &mi->file, 0))
goto errwithmsg;
}
#ifndef HAVE_OPENSSL
if (ssl)
sql_print_warning("SSL information in the master info file "
"('%s') are ignored because this MySQL slave was compiled "
"without SSL support.", fname);
#endif /* HAVE_OPENSSL */
/*
This has to be handled here as init_intvar_from_file can't handle
my_off_t types
*/
mi->master_log_pos= (my_off_t) master_log_pos;
mi->port= (uint) port;
mi->connect_retry= (uint) connect_retry;
mi->ssl= (my_bool) ssl;
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
mi->ssl_verify_server_cert= ssl_verify_server_cert;
}
DBUG_PRINT("master_info",("log_file_name: %s position: %ld",
mi->master_log_name,
(ulong) mi->master_log_pos));
mi->rli.mi = mi;
if (init_relay_log_info(&mi->rli, slave_info_fname))
goto err;
mi->inited = 1;
// now change cache READ -> WRITE - must do this before flush_master_info
reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1);
if ((error=test(flush_master_info(mi, TRUE, TRUE))))
sql_print_error("Failed to flush master info file");
pthread_mutex_unlock(&mi->data_lock);
DBUG_RETURN(error);
errwithmsg:
sql_print_error("Error reading master configuration");
err:
if (fd >= 0)
{
my_close(fd, MYF(0));
end_io_cache(&mi->file);
}
mi->fd= -1;
pthread_mutex_unlock(&mi->data_lock);
DBUG_RETURN(1);
}
/*
RETURN
2 - flush relay log failed
1 - flush master info failed
0 - all ok
*/
int flush_master_info(Master_info* mi,
bool flush_relay_log_cache,
bool need_lock_relay_log)
{
IO_CACHE* file = &mi->file;
char lbuf[22];
int err= 0;
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
DBUG_ENTER("flush_master_info");
DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos));
/*
Flush the relay log to disk. If we don't do it, then the relay log while
have some part (its last kilobytes) in memory only, so if the slave server
dies now, with, say, from master's position 100 to 150 in memory only (not
on disk), and with position 150 in master.info, then when the slave
restarts, the I/O thread will fetch binlogs from 150, so in the relay log
we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the
SQL thread will jump from 100 to 150, and replication will silently break.
When we come to this place in code, relay log may or not be initialized;
the caller is responsible for setting 'flush_relay_log_cache' accordingly.
*/
if (flush_relay_log_cache)
{
pthread_mutex_t *log_lock= mi->rli.relay_log.get_log_lock();
IO_CACHE *log_file= mi->rli.relay_log.get_log_file();
if (need_lock_relay_log)
pthread_mutex_lock(log_lock);
safe_mutex_assert_owner(log_lock);
err= flush_io_cache(log_file);
if (need_lock_relay_log)
pthread_mutex_unlock(log_lock);
if (err)
DBUG_RETURN(2);
}
/*
We flushed the relay log BEFORE the master.info file, because if we crash
now, we will get a duplicate event in the relay log at restart. If we
flushed in the other order, we would get a hole in the relay log.
And duplicate is better than hole (with a duplicate, in later versions we
can add detection and scrap one event; with a hole there's nothing we can
do).
*/
/*
In certain cases this code may create master.info files that seems
corrupted, because of extra lines filled with garbage in the end
file (this happens if new contents take less space than previous
contents of file). But because of number of lines in the first line
of file we don't care about this garbage.
*/
my_b_seek(file, 0L);
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
my_b_printf(file,
"%u\n%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n%s\n%s\n%s\n%s\n%s\n%d\n",
LINES_IN_MASTER_INFO,
mi->master_log_name, llstr(mi->master_log_pos, lbuf),
mi->host, mi->user,
mi->password, mi->port, mi->connect_retry,
(int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert,
Bug#19991 CHANGE MASTER need option ssl-verify-server-cert - Add MASTER_SSL_VERIFY_SERVER_CERT option to CHANGE MASTER TO - Add Master_Ssl_Serify_Server_Cert to SHOW SLAVE STATUS - Save and restore ssl_verify_server_cert to master info file setting it to disabled as default. mysql-test/r/rpl_000015.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_change_master.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_empty_master_crash.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_flushlog_loop.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_loaddata.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_log_pos.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rbr_to_sbr.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_redirect.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_replicate_do.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_rotate_logs.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_row_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_server_id2.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_slave_status.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_ssl1.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_log.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_max_relay_size.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_reset_slave.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/r/rpl_stm_until.result: Update test result after adding new column to SHOW SLAVE STATUS mysql-test/t/rpl_ssl1.test: Change to "query_vertical show slave status" sql/lex.h: Add new token for MASTER_SSL_VERIFY_SERVER_CERT sql/repl_failsafe.cc: Turn on verification of master cert if so requested sql/rpl_mi.cc: Add new variable to MASTER_INFo and save/restore it from/to line 15 of master info file sql/rpl_mi.h: Add variable for ssl_verify_server_cert to MASTER_INFO sql/slave.cc: Turn on verification of master cert if so requested Add new column to SHOW SLAVE STATUS sql/sql_lex.h: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_repl.cc: Add ssl_verify_server_cert to "st_lex_master_info" struct - allow it to be UNCHANGED just like the ssl option. sql/sql_yacc.yy: Add MASTER_SSL_VERIFY_SERVER_CERT to CHANGE MASTER TO mysql-test/t/rpl_ssl_verify_server.test: New BitKeeper file ``mysql-test/t/rpl_ssl_verify_server.test'' mysql-test/r/rpl_ssl_verify_server.result: New BitKeeper file ``mysql-test/r/rpl_ssl_verify_server.result''
2007-03-29 15:09:57 +02:00
mi->ssl_cipher, mi->ssl_key, mi->ssl_verify_server_cert);
DBUG_RETURN(-flush_io_cache(file));
}
void end_master_info(Master_info* mi)
{
DBUG_ENTER("end_master_info");
if (!mi->inited)
DBUG_VOID_RETURN;
end_relay_log_info(&mi->rli);
if (mi->fd >= 0)
{
end_io_cache(&mi->file);
(void)my_close(mi->fd, MYF(MY_WME));
mi->fd = -1;
}
mi->inited = 0;
DBUG_VOID_RETURN;
}
#endif /* HAVE_REPLICATION */