mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
BUG#46364 MyISAM transbuffer problems (NTM problem)
It is well-known that due to concurrency issues, a slave can become inconsistent when a transaction contains updates to both transaction and non-transactional tables. In a nutshell, the current code-base tries to preserve causality among the statements by writing non-transactional statements to the txn-cache which is flushed upon commit. However, modifications done to non-transactional tables on behalf of a transaction become immediately visible to other connections but may not immediately get into the binary log and therefore consistency may be broken. In general, it is impossible to automatically detect causality/dependency among statements by just analyzing the statements sent to the server. This happen because dependency may be hidden in the application code and it is necessary to know a priori all the statements processed in the context of a transaction such as in a procedure. Moreover, even for the few cases that we could automatically address in the server, the computation effort required could make the approach infeasible. So, in this patch we introduce the option - "--binlog-direct-non-transactional-updates" that can be used to bypass the current behavior in order to write directly to binary log statements that change non-transactional tables. Besides, it is used to enable the WL#2687 which is disabled by default.
This commit is contained in:
@ -299,6 +299,48 @@ static Sys_var_enum Sys_binlog_format(
|
||||
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_format_check),
|
||||
ON_UPDATE(fix_binlog_format_after_update));
|
||||
|
||||
static bool binlog_direct_check(sys_var *self, THD *thd, set_var *var)
|
||||
{
|
||||
/*
|
||||
Makes the session variable 'binlog_direct_non_transactional_updates'
|
||||
read-only inside a transaction.
|
||||
*/
|
||||
if (thd->active_transaction() && (var->type == OPT_SESSION))
|
||||
{
|
||||
my_error(ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT, MYF(0));
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
Makes the session variable 'binlog_direct_non_transactional_updates'
|
||||
read-only if within a procedure, trigger or function.
|
||||
*/
|
||||
if (thd->in_sub_stmt)
|
||||
{
|
||||
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT, MYF(0));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (check_has_super(self, thd, var))
|
||||
return true;
|
||||
if (var->type == OPT_GLOBAL ||
|
||||
(thd->variables.binlog_direct_non_trans_update ==
|
||||
var->save_result.ulonglong_value))
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static Sys_var_mybool Sys_binlog_direct(
|
||||
"binlog_direct_non_transactional_updates",
|
||||
"Causes updates to non-transactional engines using statement format to "
|
||||
"be written directly to binary log. Before using this option make sure "
|
||||
"that there are no dependencies between transactional and "
|
||||
"non-transactional tables such as in the statement INSERT INTO t_myisam "
|
||||
"SELECT * FROM t_innodb; otherwise, slaves may diverge from the master.",
|
||||
SESSION_VAR(binlog_direct_non_trans_update),
|
||||
CMD_LINE(OPT_ARG), DEFAULT(FALSE),
|
||||
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_direct_check));
|
||||
|
||||
static Sys_var_ulong Sys_bulk_insert_buff_size(
|
||||
"bulk_insert_buffer_size", "Size of tree cache used in bulk "
|
||||
"insert optimisation. Note that this is a limit per thread!",
|
||||
|
Reference in New Issue
Block a user