summaryrefslogtreecommitdiff
path: root/plugin/semisync/semisync_master.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.5' into 10.0Vicențiu Ciorbaru2017-07-251-3/+3
|\
| * MDEV-12646: Apply fixes found by Coverity static analysis toolDaniel Black2017-07-181-3/+3
| | | | | | | | Inspired by: https://github.com/devexp-db/mariadb/blob/f27/mariadb-covscan-stroverflow.patch
* | Merge branch '5.5' into 10.0Sergei Golubchik2016-02-151-2/+2
|\ \ | |/
| * Merge branch 'mysql/5.5' into 5.5Sergei Golubchik2016-02-091-2/+2
| |\ | | | | | | | | | | | | reverted about half of commits as either not applicable or outright wrong
| | * Bug#21770366 backport bug#21657078 to 5.5 and 5.6Ajo Robert2016-01-071-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem Statement ========= Fix various issues when building MySQL with Visual Studio 2015. Fix: ======= - Visual Studio 2015 adds support for timespec. Add check and related code to use this and only use our replacement if timespec is not defined. - Rename lfind/lsearch to my* to avoid redefinition problems. - Set default value for TMPDIR to "" on Windows as P_tmpdir no longer exists. - using VS definition of snprintf if available - tzname are now renamed to _tzname.
| | * BUG#17460821: ASSERTION ERROR WHEN STOPPING SLAVE AFTER SEMI-SYNC ON MASTER ↵Luis Soares2013-10-171-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IS DISABLED The assertion happens when: (i) the master and slave are configured to use the semisync plugin; (ii) the DBA disables semisync on the master; (iii) and he also unsets the option to wait for slaves ACK even if the semisync slave count reaches 0 during the waiting period. This combination of factors makes the server run into an assertion as soon as the last semisync slave disconnects and its dump thread exits. The root of the problem is the fact that when the dump thread disconnects and calls the observer hook transmit_stop, which ends up calling ReplSemiSyncMaster::remove_slave, there is no check whether the master has already disabled semisync or not. If it has, the then a second call to the switch_off member function must be avoided. The quick fix is to avoid calling switch_off if the DBA has disabled the semisync plugin interactively on the master. Also, the switch_off member function should only be called if the plugin has not been switched off already. This is basically the pattern throughout the rest of the semisync plugin and no other calls seem vulnerable to similar crashes/assertions. (This a backport of the patch to 5.5, which is also vulnerable.)
| | * BUG#17508351: REDUNDANT CODE IN REPLSEMISYNCMASTER::UPDATESYNCHEADERLuis Soares2013-10-081-8/+2
| | | | | | | | | | | | | | | | | | ReplSemiSyncMaster::updateSyncHeader contains redundant assignments to the local variable sync. This patch removes them.
| | * Bug#17327454:SEMI-SYNC REPLICATION MASTER CRASH WHEN SETSujatha Sivakumar2013-09-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RPL_SEMI_SYNC_MASTER_ENABLED OFF. Problem: ======= If master is waiting for a reply from slave, at this time set global rpl_semi_sync_master_enabled=OFF, the master server will crash. Analysis: ======== When master is waiting for a reply from slave, at this time if semi sync is switched off on master, during switch off if active transactions are present the transactions will be cleared and "active_tranxs_" variable will be set to NULL. When the waiting master connection finds that semi sync is switched of it tries to access "active_tranxs_" without checking if the transaction list exists or not. Accessing NULL transaction list causes the crash. Fix: === A check has been added to see a valid list exists before accessing the "active_tranxs_".
| | * BUG#12818224: 61921: WRITETRAXINBINLOG SHOULD BE WRITETRANXINBINLOG Luis Soares2011-09-081-9/+9
| | | | | | | | | | | | | | | | | | | | | IN SEMISYNC_MASTER.CC Fixing typo: writeTraxInBinlog() => writeTranxInBinlog() . Additionally, fixed identation.
| | * Updated/added copyright headersKent Boortz2011-06-301-1/+2
| | |
| | * Auto merge from 5.1-rep-semisyncHe Zhenxing2010-06-021-1/+2
| | |\
| | | * Post fix for bug#52748He Zhenxing2010-06-021-1/+2
| | | |
| | * | BUG#52748 Semi-Sync ACK packet isn't check for lengthHe Zhenxing2010-06-011-4/+14
| | |\ \ | | | |/ | | | | Check the length and use strncpy to make the code safer.
| | | * BUG#52748 Semi-Sync ACK packet isn't check for lengthHe Zhenxing2010-06-011-4/+14
| | | | | | | | | | | | Check the length and use strncpy to make the code safer.
| | * | Auto merge from 5.1-rep-semisyncHe Zhenxing2010-03-111-126/+84
| | |\ \ | | | |/
| | | * Post fix for Bug#49557He Zhenxing2010-03-101-1/+2
| | | |
| | | * Bug#49557 "semisync" plugin test fails on WindowsHe Zhenxing2010-02-231-126/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was because the gettimeofday function was incorrect implemented for Windows, and so the semisync master did not wait for slave reply properly on Windows. Fixed by removing the gettimeofday function for Windows, and using set_timespec function to get current time for all platforms.
| | * | Manual Merge for bug#501572010-01-311-21/+4
| | |\ \ | | | |/
| | | * BUG#50157 Assertion !active_tranxs_->is_tranx_end_pos(..) in ↵2010-01-311-21/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ReplSemiSyncMaster::commitTrx The root cause of the crash is that a TranxNode is freed before it is used. A TranxNode is allocated and inserted into the active list each time a log event is written and flushed into the binlog file. The memory for TranxNode is allocated with thd_alloc and will be freed at the end of the statement. The after_commit/after_rollback callback was supposed to be called before the end of each statement and remove the node from the active list. However this assumption is not correct in all cases(e.g. call 'CREATE TEMPORARY TABLE myisam_t SELECT * FROM innodb_t' in a transaction and delete all temporary tables automatically when a session closed), and can cause the memory allocated for TranxNode be freed before it was removed from the active list. So The TranxNode pointer in the active list would become a wild pointer and cause the crash. After this patch, We have a class called a TranxNodeAllocate which manages the memory for allocating and freeing TranxNode. It uses my_malloc to allocate memory.
| | * | Merge mysql-next-mr (revno 2936) --> mysql-next-mr-marcMarc Alff2009-12-111-64/+23
| | |\ \ | | | |/
| | | * Post fix for previous patch of Bug#49020He Zhenxing2009-12-041-2/+3
| | | | | | | | | | | | | | | | | | | | Added back n_frees, use 'clear' instead of 'free' since memory is not freed here.
| | | * Bug#49020 Semi-sync master crashed with free_pool == NULL, assertion ↵He Zhenxing2009-12-041-63/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `free_pool_' Before this patch, semisync assumed transactions running in parallel can not be larger than max_connections, but this is not true when the event scheduler is executing events, and cause semisync run out of preallocated transaction nodes. Fix the problem by allocating transaction nodes dynamically. This patch also fixed a possible deadlock when running UNINSTALL PLUGIN rpl_semi_sync_master and updating in parallel. Fixed by releasing the internal Delegate lock before unlock the plugins.
| | * | WL#2360 Performance schemaMarc Alff2009-12-091-11/+13
| | |/ | | | | | | | | | Part III: mysys instrumentation
| | * Add semi-sync support for WindowsHe Zhenxing2009-10-231-0/+18
| | |
| | * Backport BUG#47298 Semisync: always wait until timeout if no semi-sync slave ↵He Zhenxing2009-10-121-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | available Add an option to control whether the master should keep waiting until timeout when it detected that there is no semi-sync slave available. The bool option 'rpl_semi_sync_master_wait_no_slave' is 1 by defalt, and will keep waiting until timeout. When set to 0, the master will switch to asynchronous replication immediately when no semi-sync slave is available.
| | * BUG#45674 FLUSH STATUS does not reset semisynchronous countersHe Zhenxing2009-10-121-58/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Semi-sync status were not reset by FLUSH STATUS, this was because all semi-sync status variables are defined as SHOW_FUNC and FLUSH STATUS could only reset SHOW_LONG type variables. This problem is fixed by change all status variables that should be reset by FLUSH STATUS from SHOW_FUNC to SHOW_LONG. After the fix, the following status variables will be reset by FLUSH STATUS: Rpl_semi_sync_master_yes_tx Rpl_semi_sync_master_no_tx Note: normally, FLUSH STATUS itself will be written into binlog and be replicated, so after FLUSH STATS, one of Rpl_semi_sync_master_yes_tx Rpl_semi_sync_master_no_tx can be 1 dependent on the semi-sync status. So it's recommended to use FLUSH NO_WRITE_TO_BINLOG STATUS to avoid this.
| | * Backport BUG#45848 Semisynchronous replication internals are visible in SHOW ↵He Zhenxing2009-10-121-28/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PROCESSLIST and logs Semi-sync uses an extra connection from slave to master to send replies, this is a normal client connection, and used a normal SET query to set the reply information on master, which is visible to user and may cause some confusion and complaining. This problem is fixed by using the method of sending reply by using the same connection that is used by master dump thread to send binlog to slave. Since now the semi-sync plugins are integrated with the server code, it is not a problem to use the internal net interfaces to do this. The master dump thread will mark the event requires a reply and wait for the reply when the event just sent is the last event of a transaction and semi-sync status is ON; And the slave will send a reply to master when it received such an event that requires a reply.
| | * Fix semisync master/slave status always showed as OFF on sparcHe Zhenxing2009-10-031-1/+1
| | | | | | | | | | | | | | | On sparc, semisync master/slave status is always showed as OFF, this is fixed by change rpl_semisync_master/slave_status variables from long to char.
| | * Backporting WL#4398 WL#1720He Zhenxing2009-09-261-0/+1199
| | | | | | | | Backporting BUG#44058 BUG#42244 BUG#45672 BUG#45673 Backporting BUG#45819 BUG#45973 BUG#39012
* | MDEV-8066 Crash on unloading semisync_master pluginMonty2015-11-141-1/+4
| | | | | | | | | | | | Bug was that ReplSemiSyncMaster::commitTrx() was waiting on a condition for state to change, but didn't take into account that one could have disabled semi-sync during the wait.
* | 10.0-base mergeSergei Golubchik2014-02-031-15/+13
|\ \
| * \ 5.5 mergeSergei Golubchik2014-02-011-15/+13
| |\ \ | | |/
| | * MySQL-5.5.35 mergeSergei Golubchik2014-01-221-15/+13
| | |\
| | | * BUG#17460821: ASSERTION ERROR WHEN STOPPING SLAVE AFTER SEMI-SYNC ON MASTER ↵Luis Soares2013-10-171-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IS DISABLED The assertion happens when: (i) the master and slave are configured to use the semisync plugin; (ii) the DBA disables semisync on the master; (iii) and he also unsets the option to wait for slaves ACK even if the semisync slave count reaches 0 during the waiting period. This combination of factors makes the server run into an assertion as soon as the last semisync slave disconnects and its dump thread exits. The root of the problem is the fact that when the dump thread disconnects and calls the observer hook transmit_stop, which ends up calling ReplSemiSyncMaster::remove_slave, there is no check whether the master has already disabled semisync or not. If it has, the then a second call to the switch_off member function must be avoided. The quick fix is to avoid calling switch_off if the DBA has disabled the semisync plugin interactively on the master. Also, the switch_off member function should only be called if the plugin has not been switched off already. This is basically the pattern throughout the rest of the semisync plugin and no other calls seem vulnerable to similar crashes/assertions. (This a backport of the patch to 5.5, which is also vulnerable.)
| | | * BUG#17508351: REDUNDANT CODE IN REPLSEMISYNCMASTER::UPDATESYNCHEADERLuis Soares2013-10-081-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ReplSemiSyncMaster::updateSyncHeader contains redundant assignments to the local variable sync. This patch removes them.
| | | * Bug#17327454:SEMI-SYNC REPLICATION MASTER CRASH WHEN SETSujatha Sivakumar2013-09-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RPL_SEMI_SYNC_MASTER_ENABLED OFF. Problem: ======= If master is waiting for a reply from slave, at this time set global rpl_semi_sync_master_enabled=OFF, the master server will crash. Analysis: ======== When master is waiting for a reply from slave, at this time if semi sync is switched off on master, during switch off if active transactions are present the transactions will be cleared and "active_tranxs_" variable will be set to NULL. When the waiting master connection finds that semi sync is switched of it tries to access "active_tranxs_" without checking if the transaction list exists or not. Accessing NULL transaction list causes the crash. Fix: === A check has been added to see a valid list exists before accessing the "active_tranxs_". plugin/semisync/semisync_master.cc: Added check for the existence of valid 'active_transx_'.
* | | | MDEV-201 - Assertion `!thd->spcont' failed in net_send_error on server shutdownSergei Golubchik2013-11-101-2/+3
| | | | | | | | | | | | | | | | | | | | restore sergii@pisem.net-20120327141644-xue6r05x1giswwsm that was lost in a merge
* | | | 10.0-base merge.Sergei Golubchik2013-09-211-9/+5
|\ \ \ \ | |/ / / | | | | | | | | | | | | Partitioning/InnoDB changes are *not* merged (they'll come from 5.6) TokuDB does not compile (not updated to 10.0 SE API)
| * | | 5.5 merge and fixes for compiler/test errorsSergei Golubchik2013-09-181-9/+5
| |\ \ \ | | |/ /
| | * | MDEV-4926: Remove division-using-subtraction implementation from semi-sync ↵Vladislav Vaintroub2013-09-031-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | plugin If rpl_semi_sync_master_timeout is large, calculation of absolute waiting time in semi-sync plugin is inefficient. This error is specific to systems with 64 bit long values (all 64 bit Unixes) In rpl_semi_sync_master_timeout has maximal value (= MAX_ULONGLONG), calculating abstime may require ~ 18 billion subtract operations. The fix is to use division instead of subtraction-in-a-loop. Also fixed an integer overflow bug.
* | | | 10.0-base mergeSergei Golubchik2013-04-151-1/+2
|\ \ \ \ | |/ / /
| * | | MDEV-4254 Semisync plugins to link statically into MariaDBSergei Golubchik2013-04-091-1/+2
| | | | | | | | | | | | | | | | fix semisync plugins and tests to work with both with static and dynamic linking
* | | | 10.0-base -> 10.0-montySergei Golubchik2012-10-191-1/+2
|\ \ \ \ | |/ / /
| * | | Automatic merge with 5.5Michael Widenius2012-09-011-1/+2
| |\ \ \ | | |/ /
| | * | Fixed compiler warnings (A few of these was bugs)Michael Widenius2012-08-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | client/mysqldump.c: Slave needs to be initialized with 0 dbug/dbug.c: Removed not existing function plugin/semisync/semisync_master.cc: Fixed compiler warning sql/opt_range.cc: thd needs to be set early as it's used in some error conditions. sql/sql_table.cc: Changed to use uchar* to make array indexing portable storage/innobase/handler/ha_innodb.cc: Removed not used variable storage/maria/ma_delete.c: Fixed compiler warning storage/maria/ma_write.c: Fixed compiler warning
* | | | win fixes in semisync pluginSergei Golubchik2012-10-011-9/+0
| | | |
* | | | fixes for test failuresSergei Golubchik2012-09-271-9/+17
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and small collateral changes mysql-test/lib/My/Test.pm: somehow with "print" we get truncated writes sometimes mysql-test/suite/perfschema/r/digest_table_full.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/dml_handler.result: host table is not ported over yet mysql-test/suite/perfschema/r/information_schema.result: host table is not ported over yet mysql-test/suite/perfschema/r/nesting.result: this differs, because we don't rewrite general log queries, and multi-statement packets are logged as a one entry. this result file is identical to what mysql-5.6.5 produces with the --log-raw option. mysql-test/suite/perfschema/r/relaylog.result: MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB. mysql-test/suite/perfschema/r/server_init.result: MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup. mysql-test/suite/perfschema/r/stage_mdl_global.result: this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not do that, and this causes useless mutex locks and waits. mysql-test/suite/perfschema/r/statement_digest.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/statement_digest_consumers.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/statement_digest_long_query.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result: will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result: will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
* | | automatic merge with 5.5Michael Widenius2012-06-271-1/+3
|\ \ \ | |/ /
| * | MDEV-359: Fix another case where switch-off semisync could cause a race that ↵unknown2012-06-211-0/+1
| | | | | | | | | | | | | | | | | | ended with server crash. This one was when the code releases and reaquires the lock with pthread_cond_wait() - and semisync is switched off meanwhile.
| * | MDEV-359: Server crash when SET GLOBAL rpl_semi_sync_master_enabled = OFFunknown2012-06-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The semisync code does a fast-but-unsafe check for enabled or not without lock, followed by a slow-but-safe check under lock. However, if the slow check failed, the code still referenced not valid data (in an assert() expression), causing a crash. Fixed by not running the incorrect assert when semisync is disabled.