3617 Mats Kindahl 2012-02-20
WL#5223: Binary Log Group Commit
There were an error because when a statement was logged using
THD::binlog_query inside a stored function, it was allocated
space in the binary log, hence also queued for commit. This
committed the transaction, causing the subsequent top-level
commit to trigger an assertion inside InnoDB.
This patch solves the problem by not forcing a flush (and commit)
of the statement cache inside THD::binlog_query if called while
inside the execution of a stored function (or other stored routine).
This accumulates all the logged queries, which are then flushed to
the binary when the top-level statement commits.
modified:
sql/binlog.cc
3616 Nuno Carvalho 2012-02-20
WL#5223: Binary Log Group Commit
Had dummy structures, used to declare PSI_statement_locker_state and
PSI_idle_locker_state when no instrumentation is available.
Only made invocations to PSI_server when instrumentation is available.
modified:
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v0.h.pp
sql/binlog.cc
=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc 2012-02-20 16:54:30 +0000
+++ b/sql/binlog.cc 2012-02-20 20:57:36 +0000
@@ -4433,9 +4433,12 @@ err:
statement will be committed in the handlertons when being
reaped inside wait_and_reap().
*/
- if (thd->is_error())
- ha_rollback_htons(thd, false);
- error |= force_flush_stmt_cache(thd, Log_event::EVENT_IMMEDIATE_LOGGING);
+ if (!thd->in_sub_stmt)
+ {
+ if (thd->is_error())
+ ha_rollback_htons(thd, false);
+ error |= force_flush_stmt_cache(thd, Log_event::EVENT_IMMEDIATE_LOGGING);
+ }
DBUG_PRINT("debug", ("stmt_cache: %lu bytes, trx_cache: %lu bytes",
(ulong) cache_mngr->stmt_cache.bytes_to_reserve(),
(ulong) cache_mngr->trx_cache.bytes_to_reserve()));
@@ -7204,6 +7207,13 @@ void THD::issue_unsafe_warnings()
}
+static const char *ltm_name[] = {
+ "LTM_NONE",
+ "LTM_LOCK_TABLES",
+ "LTM_PRELOCKED",
+ "LTM_PRELOCKED_UNDER_LOCK_TABLES",
+};
+
/**
Log the current query.
@@ -7234,8 +7244,9 @@ int THD::binlog_query(THD::enum_binlog_q
bool suppress_use, int errcode)
{
DBUG_ENTER("THD::binlog_query");
- DBUG_PRINT("enter", ("qtype: %s query: '%s'",
- show_query_type(qtype), query_arg));
+ DBUG_PRINT("enter", ("qtype: %s query: '%s', locked_tables_mode: %s",
+ show_query_type(qtype), query_arg,
+ ltm_name[locked_tables_mode]));
DBUG_ASSERT(query_arg && mysql_bin_log.is_open());
/*
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (mats.kindahl:3616 to 3617) WL#5223 | Mats Kindahl | 21 Feb |