summaryrefslogtreecommitdiff
path: root/sql/log.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.3 into 10.4st-10.4Marko Mäkelä2021-04-221-0/+19
|\
| * Merge 10.2 into 10.3Marko Mäkelä2021-04-221-0/+19
| |\
| | * MDEV-24526 binlog rotate via FLUSH LOGS may obsolate binlog file for ↵Andrei Elkin2021-04-211-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | recovery too eary There was race between a committing transaction and the following in binlog order FLUSH LOGS that could create a 2nd Binlog checkpoint (BCP) event in the new file *before* the first logged-in-old-binlog transaction gets committed in Innodb. That would cause the transaction loss at recovery, should the server stop right after the BCP. The race is tackled by enforcing the necessary set of mutexes to be acquired by FLUSH-LOGS handler in the correct order (of the group commit leader pattern). Note, there remain two cases where a similar race is still possible: - the above race as it is when the server is run with ("unlikely") non-default `--binlog-optimize-thread-scheduling=0` (MDEV-24530), and - at unlikely event of bin-logging of Incident event (MDEV-24531) that also triggers binlog rotation, in both cases though with lesser chances after the current fixes.
| * | Merge branch '10.2' into 10.3Sujatha2020-11-121-1/+3
| |\ \ | | |/
| | * MDEV-4633: multi_source.simple test fails sporadicallySujatha2020-11-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: ======== Writes to 'rli->log_space_total' needs to be synchronized, otherwise both SQL_THREAD and IO_THREAD can try to modify the variable simultaneously resulting in incorrect rli->log_space_total. In the current test scenario SQL_THREAD is trying to decrement 'rli->log_space_total' in 'purge_first_log' and IO_THREAD is trying to increment the 'rli->log_space_total' in 'queue_event' simultaneously. Hence test occasionally fails with result mismatch. Fix: === Convert 'rli->log_space_total' variable to atomic type.
* | | MDEV-24954 : 10.5.9 crashes on int wsrep::client_state::ordered_commit(): ↵bb-10.4-MDEV-24954Jan Lindström2021-03-251-17/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assertion `owning_thread_id_ == wsrep::this_thread::get_id()' failed. Binlog group commit could lead to a situation where group commit leader accesses participant thd's wsrep client state concurrently with the thread executing the participant thd. This is because of race condition in MYSQL_BIN_LOG::write_transaction_to_binlog_events(), and was fixed by moving wsrep_ordered_commit() to happen in MYSQL_BIN_LOG::queue_for_group_commit() under protection of LOCK_prepare_ordered mutex.
* | | MDEV-23843 Assertions in Diagnostics_area upon table operations under FTWRLMonty2021-02-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2 different problems: - MYSQL_BIN_LOG::write() did not check if mdl_context.acquire_lock() failed - Sql_cmd_optimize_table::execute() and Sql_cmd_repair_table::execute() called write_bin_log(), which could fail if sql_admin() had already called my_eof() Fixed by adding check for aquire_lock() return status and protect write_bin_log() in the above two functions with set_overwrite_status().
* | | Merge 10.3 into 10.4Marko Mäkelä2020-10-221-3/+6
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2020-10-221-3/+6
| |\ \ | | |/
| | * Merge 10.1 into 10.2Marko Mäkelä2020-10-211-2/+4
| | |\
| | | * MDEV-4851: BUG#11763447: 'YOU CANNOT 'ALTER' A LOG TABLE IF LOGGING IS ENABLED'Nisha Gopalakrishnan2020-10-081-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EVEN IF I LOG TO FILE. Analysis: ---------- MYSQL_UPGRADE of the master breaks the replication when the query logging is enabled with FILE/NONE 'log-output' option on the slave. mysql_upgrade modifies the 'general_log' and 'slow_log' tables after the logging is disabled as below: SET @old_log_state = @@global.general_log; SET GLOBAL general_log = 'OFF'; ALTER TABLE general_log MODIFY event_time TIMESTAMP NOT NULL, ( .... ); SET GLOBAL general_log = @old_log_state; and SET @old_log_state = @@global.slow_query_log; SET GLOBAL slow_query_log = 'OFF'; ALTER TABLE slow_log MODIFY start_time TIMESTAMP NOT NULL, ( .... ); SET GLOBAL slow_query_log = @old_log_state; In the binary log, only the ALTER statements are logged but not the SET statements which turns ON/OFF the logging. So when the slave replays the binary log,the ALTER of LOG tables throws an error since the logging is enabled. Also the 'log-output' option is not checked to determine whether to allow/disallow the ALTER operation. Fix: ---- The 'log-output' option is included in the check while determining whether the query logging happens using the log tables. Picked from mysql respository at 0daaf8aecd8f84ff1fb400029139222ea1f0d812
| | * | MDEV-23894 UBSAN: several call to function show_binlog_vars(THD*, ↵Eugene Kosov2020-10-061-1/+2
| | | | | | | | | | | | | | | | st_mysql_show_var*, char*) through pointer to incorrect function type 'int (*)(THD *, st_mysql_show_var *, void *, system_status_var *, enum_var_type) errors
* | | | MDEV-23586 Mariabackup: GTID saved for replication in 10.4.14 is wrongMonty2020-09-251-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-21953 deadlock between BACKUP STAGE BLOCK_COMMIT and parallel replication Fixed by partly reverting MDEV-21953 to put back MDL_BACKUP_COMMIT locking before log_and_order. The original problem for MDEV-21953 was that while a thread was waiting in for another threads to commit in 'log_and_order', it had the MDL_BACKUP_COMMIT lock. The backup thread was waiting to get the MDL_BACKUP_WAIT_COMMIT lock, which blocks all new MDL_BACKUP_COMMIT locks. This causes a deadlock as the waited-for thread can never get past the MDL_BACKUP_COMMIT lock in ha_commit_trans. The main part of the bug fix is to release the MDL_BACKUP_COMMIT lock while a thread is waiting for other 'previous' threads to commit. This ensures that no transactional thread keeps MDL_BACKUP_COMMIT while waiting, which ensures that there are no deadlocks anymore.
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-9/+9
|\ \ \ \ | |/ / /
| * | | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-08-031-9/+9
| |\ \ \ | | |/ /
| | * | Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-021-9/+9
| | |\ \ | | | |/
| | | * Code comment spellfixesIan Gilfillan2020-07-221-10/+10
| | | |
* | | | Merge 10.3 into 10.4Marko Mäkelä2020-06-131-2/+2
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2020-06-131-2/+2
| |\ \ \ | | |/ /
| | * | Merge branch '10.1' into 10.2Vicențiu Ciorbaru2020-06-111-2/+2
| | |\ \ | | | |/
| | | * MDEV-22717: Conditional jump or move depends on uninitialised value(s) in ↵Sujatha2020-06-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | find_uniq_filename(char*, unsigned long) Fix: === Initialize 'number' variable to '0'.
* | | | MDEV-22451: SIGSEGV in __memmove_avx_unaligned_erms/memcpy from _my_b_write ↵Sujatha2020-05-201-1/+3
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | on CREATE after RESET MASTER Merge branch '10.3' into 10.4
| * | | MDEV-22451: SIGSEGV in __memmove_avx_unaligned_erms/memcpy from _my_b_write ↵Sujatha2020-05-201-1/+3
| |\ \ \ | | |/ / | | | | | | | | | | | | | | | | on CREATE after RESET MASTER Merge branch '10.2' into 10.3
| | * | MDEV-22451: SIGSEGV in __memmove_avx_unaligned_erms/memcpy from _my_b_write ↵Sujatha2020-05-201-1/+3
| | |\ \ | | | |/ | | | | | | | | | | | | | | | | on CREATE after RESET MASTER Merge branch '10.1' into 10.2
| | | * MDEV-22451: SIGSEGV in __memmove_avx_unaligned_erms/memcpy from _my_b_write ↵Sujatha2020-05-201-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on CREATE after RESET MASTER Analysis: ======== RESET MASTER TO # command deletes all binary log files listed in the index file, resets the binary log index file to be empty, and creates a new binary log with number #. When the user provided binary log number is greater than the max allowed value '2147483647' server fails to generate a new binary log. The RESET MASTER statement marks the binlog closure status as 'LOG_CLOSE_TO_BE_OPENED' and exits. Statements which follow RESET MASTER try to write to binary log they find the log_state != LOG_CLOSED and proceed to write to binary log cache and it results in crash. Fix: === During MYSQL_BIN_LOG open, if generation of new binary log name fails then the "log_state" needs to be marked as "LOG_CLOSED". With this further statements will find binary log as closed and they will skip writing to the binary log.
| * | | Merge 10.2 into 10.3Marko Mäkelä2020-04-271-4/+5
| |\ \ \ | | |/ /
| | * | Merge 10.1 into 10.2Marko Mäkelä2020-04-271-4/+5
| | |\ \ | | | |/
| | | * MDEV-22203: WSREP_ON is unnecessarily expensive to evaluateMarko Mäkelä2020-04-271-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a backport of the applicable part of commit 93475aff8de80a0ef53cbee924bcb70de6e86f2c and commit 2c39f69d34e64a5cf94720e82e78c0ee91bd4649 from 10.4. Before 10.4 and Galera 4, WSREP_ON is a macro that points to a global Boolean variable, so it is not that expensive to evaluate, but we will add an unlikely() hint around it. WSREP_ON_NEW: Remove. This macro was introduced in commit c863159c320008676aff978a7cdde5732678f975 when reverting WSREP_ON to its previous definition. We replace some use of WSREP_ON with WSREP(thd), like it was done in 93475aff8de80a0ef53cbee924bcb70de6e86f2c. Note: the macro WSREP() in 10.1 is equivalent to WSREP_NNULL() in 10.4. Item_func_rand::seed_random(): Avoid invoking current_thd when WSREP is not enabled.
| * | | Merge 10.2 into 10.3Marko Mäkelä2020-04-151-6/+0
| |\ \ \ | | |/ /
| | * | MDEV-22021: Galera database could get inconsistent with rollback to savepointmkaruza2020-03-311-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | When binlog is disabled, WSREP will not behave correctly when SAVEPOINT ROLLBACK is executed since we don't register handlers for such case. Fixed by registering WSREP handlerton for SAVEPOINT related commands.
* | | | MDEV-22203: WSREP_ON is unnecessarily expensive to evaluateJan Lindström2020-04-241-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | Replaced WSREP_ON macro by single global variable WSREP_ON that is then updated at server statup and on wsrep_on and wsrep_provider update functions.
* | | | MDEV-22021: Galera database could get inconsistent with rollback to savepointDaniele Sciascia2020-03-311-11/+7
| | | | | | | | | | | | | | | | | | | | When binlog is disabled, WSREP will not behave correctly when SAVEPOINT ROLLBACK is executed and we will not rollback transaction.
* | | | MDEV-21675: Data inconsistency after multirow insert rollback (#1474)Daniele Sciascia2020-03-211-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove dead code * MDEV-21675 Data inconsistency after multirow insert rollback This patch fixes data inconsistencies that happen after rollback of multirow inserts, with binlog disabled. For example, statements such as `INSERT INTO t1 VALUES (1,'a'),(1,'b')` that fail with duplicate key error. In such cases the whole statement is rolled back. However, with wsrep_emulate_binlog in effect, the IO_CACHE would not be truncated, and the pending rows events would be replicated to the rest of the cluster. In the above example, it would result in row (1,'a') being replicated, whereas locally the statement is rolled back entirely. Making the cluster inconsistent. The patch changes the code so that prior to statement rollback, pending rows event are removed and the stmt cache reset. That patch also introduces MTR tests that excercise multirow insert statements for regular, and streaming replication.
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-02-111-20/+14
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2020-01-311-20/+14
| |\ \ \ | | |/ /
| | * | Merge 10.1 into 10.2Marko Mäkelä2020-01-311-18/+12
| | |\ \ | | | |/
| | | * MDEV-20923:UBSAN: member access within address … which does not point to ↵Sujatha2020-01-291-16/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | an object of type 'xid_count_per_binlog' Problem: ------- Accessing a member within 'xid_count_per_binlog' structure results in following error when 'UBSAN' is enabled. member access within address 0xXXX which does not point to an object of type 'xid_count_per_binlog' Analysis: --------- The problem appears to be that no constructor for 'xid_count_per_binlog' is being called, and thus the vtable will not be initialized. Fix: --- Defined a parameterized constructor for 'xid_count_per_binlog' class.
| | | * imporve clang buildEugene Kosov2019-06-251-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug Maintainer mode makes all warnings errors. This patch fix warnings. Mostly about deprecated `register` keyword. Too much warnings came from Mroonga and I gave up on it.
* | | | Merge 10.3 into 10.4Marko Mäkelä2020-01-201-1/+2
|\ \ \ \ | |/ / / | | | | | | | | | | | | The MDEV-17062 fix in commit c4195305b2a8431f39a4c75cc1c66ba43685f7a0 was omitted.
| * | | Merge branch '10.2' into 10.3Sergei Petrunia2020-01-171-1/+2
| |\ \ \ | | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # mysql-test/suite/galera/r/MW-388.result # mysql-test/suite/galera/t/MW-388.test # mysql-test/suite/innodb/r/truncate_inject.result # mysql-test/suite/innodb/t/truncate_inject.test # mysql-test/suite/rpl/r/rpl_stop_slave.result # mysql-test/suite/rpl/t/rpl_stop_slave.test # sql/sp_head.cc # sql/sp_head.h # sql/sql_lex.cc # sql/sql_yacc.yy # storage/xtradb/buf/buf0dblwr.cc
| | * | MDEV-18514: Assertion `!writer.checksum_len || writer.remains == 0' failedSujatha2020-01-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: ======== 'max_binlog_cache_size' is configured and a huge transaction is executed. When the transaction specific events size exceeds 'max_binlog_cache_size' the event cannot be written to the binary log cache and cache write error is raised. Upon cache write error the statement is rolled back and the transaction cache should be truncated to a previous statement specific position. The truncate operation should reset the cache to earlier valid positions and flush the new changes. Even though the flush is successful the cache write error is still in marked state. The truncate code interprets the cache write error as cache flush failure and returns abruptly without modifying the write cache parameters. Hence cache is in a invalid state. When a COMMIT statement is executed in this session it tries to flush the contents of transaction cache to binary log. Since cache has partial events the cache write operation will report 'writer.remains' assert. Fix: === Binlog truncate function resets the cache to a specified size. As a first step of truncation, clear the cache write error flag that was raised during earlier execution. With this new errors that surface during cache truncation can be clearly identified.
* | | | MDEV-20707: Missing memory barrier in parallel replication error handler in ↵Sujatha2019-11-141-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wait_for_prior_commit() revision-id: 673e253724979fd9fe43a4a22bd7e1b2c3a5269e Author: Kristian Nielsen Fix missing memory barrier in wait_for_commit. The function wait_for_commit::wait_for_prior_commit() has a fast path where it checks without locks if wakeup_subsequent_commits() has already been called. This check was missing a memory barrier. The waitee thread does two writes to variables `waitee' and `wakeup_error', and if the waiting thread sees the first write it _must_ also see the second or incorrect behavior will occur. This requires memory barriers between both the writes (release semantics) and the reads (acquire semantics) of those two variables. Other accesses to these variables are done under lock or where only one thread will be accessing them, and can be done without barriers (relaxed semantics).
* | | | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-3/+2
|\ \ \ \ | |/ / /
| * | | Remove \n from DBUG_PRINT statementsMichael Widenius2019-10-211-1/+1
| | | |
| * | | Fixes for binary logging --read-only modeMonty2019-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Any temporary tables created under read-only mode will never be logged to binary log. Any usage of these tables to update normal tables, even after read-only has been disabled, will use row base logging (as the temporary table will not be on the slave). - Analyze, check and repair table will not be logged in read-only mode. Other things: - Removed not used varaibles in MYSQL_BIN_LOG::flush_and_set_pending_rows_event. - Set table_share->table_creation_was_logged for all normal tables. - THD::binlog_query() now returns -1 if statement was not logged., This is used to update table_share->table_creation_was_logged. - Don't log admin statements in opt_readonly is set. - Table's that doesn't have table_creation_was_logged will set binlog format to row logging. - Removed not needed/wrong setting of table->s->table_creation_was_logged in create_table_from_items()
* | | | MDEV-17099 Preliminary changes for Galera XA support (#1404)Daniele Sciascia2019-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | Redo changes reverted in commit 8f46e3833c7acb3ec3e4c7b389ae8cdd98eff1ce, this time without build issues in wsrep-lib.
* | | | Revert MDEV-17099 Preliminary changes for Galera XA support (#1401)Marko Mäkelä2019-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | This reverts commit 2b5f4b3ed68585b310b7ebede474928ff90d9aa2 due to build failures.
* | | | MDEV-17099 Preliminary changes for Galera XA support (#1401)Daniele Sciascia2019-10-241-2/+2
| | | | | | | | | | | | Update wsrep-lib, and adapt to wsrep-lib interface changes.
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-7/+7
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ | | |/ /