1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-05 12:42:17 +03:00

BUG#39934: Slave stops for engine that only support row-based logging

This is a post-push fix addressing review requests and
problems with extra warnings.

Problem 1: The sub-statement where an unsafe warning was detected was
printed as part of the warning. This was ok for statements that
were unsafe due to, e.g., calls to UUID(), but did not make
sense for statements that were unsafe because there was more than
one autoincrement column (unsafeness in this case comes from the
combination of several sub-statements).
Fix 1: Instead of printing the sub-statement, print an explanation
of why the statement is unsafe.

Problem 2:
When a recursive construct (i.e., stored proceure, stored
function, trigger, view, prepared statement) contained several
sub-statements, and at least one of them was unsafe, there would be
one unsafeness warning per sub-statement - even for safe
sub-statements.
Fix 2:
Ensure that each type of warning is printed at most once, by
remembering throughout the execution of the statement which types
of warnings have been printed.


mysql-test/extra/rpl_tests/create_recursive_construct.inc:
  - Clarified comment per review request.
  - Added checks for the number of warnings in each invocation.
mysql-test/extra/rpl_tests/rpl_insert_delayed.test:
  Per review request, replaced @@session.binlog_format by
  @@global.binlog_format, since INSERT DELAYED reads the global
  variable. (In this test case, the two variables have the same
  value, so the change is cosmetic.)
mysql-test/r/sp_trans.result:
  updated result file
mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result:
  updated result file
mysql-test/suite/binlog/r/binlog_stm_ps.result:
  updated result file
mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
  updated result file
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Updated result file. Note that duplicate warnings are now gone.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  - Added tests for: (1) a statement that is unsafe in many ways;
    (2) a statement that is unsafe in the same way several times.
  - Use -- style to invoke mysqltest commands.
mysql-test/suite/rpl/r/rpl_stm_found_rows.result:
  updated result file
mysql-test/suite/rpl/r/rpl_stm_loadfile.result:
  updated result file
mysql-test/suite/rpl/t/rpl_mix_found_rows.test:
  Per review request, added comment explaining what the test case
  does (copied from rpl_stm_found_rows.test)
mysql-test/suite/rpl/t/rpl_stm_found_rows.test:
  Clarified grammar in comment.
mysql-test/suite/rpl_ndb/r/rpl_ndb_binlog_format_errors.result:
  Updated result file.
sql/item_create.cc:
  Made set_stmt_unsafe take one parameter, describing the
  type of unsafeness.
sql/sp_head.cc:
  Added unsafe_flags field and made it hold all the unsafe flags.
sql/sp_head.h:
  - Removed the BINLOG_ROW_BASED_IF_MIXED flag from m_flags.
    Instead, we use the new unsafe_flags field to hold the
    unsafeness state of the sp.
  - Made propagate_attributes() copy all unsafe flags.
sql/sql_base.cc:
  - Made LEX::set_stmt_unsafe() take an extra argument.
  - Made binlog_unsafe_warning_flags store the type of unsafeness.
  - Per review requests, clarified comments
  - Added DBUG printouts
sql/sql_class.cc:
  - Made warnings be generated in issue_warnings() and call that from
    binlog_query(). Wrote issue_warnings(), which prints zero or more
    warnings, avoiding to print warnings more than once per statement.
  - Per review request, added @todo so that we remember to assert
    correct behavior in binlog_query.
sql/sql_class.h:
  - Removed BINLOG_WARNING_PRINTED 
  - Use [set|clear]_current_stmt_binlog_row_based() instead of
    modifying the flag directly.
  - added issue_unsafe_warnings() (only called from binlog_unsafe)
  - Per review request, improved some documentation.
sql/sql_insert.cc:
  Added extra argument to LEX::set_stmt_unsafe()
sql/sql_lex.h:
  - Added enum_binlog_stmt_unsafe, listing all types of unsafe
    statements.
  - Per review requests, improved many comments for member
    functions.
  - Added [get|set]_stmt_unsafe_flags(), which return/set all the
    unsafe flags for a statement.
sql/sql_parse.cc:
  - Renamed binlog_warning_flags to binlog_unsafe_warning_flags.
  - Per review requests, improved comment.
sql/sql_view.cc:
  Made views propagate all the new unsafe flags.
sql/sql_yacc.yy:
  Added parameter to set_stmt_unsafe().
storage/innobase/handler/ha_innodb.cc:
  Per review requests, replaced DBUG_EXECUTE_IF() by DBUG_EVALUATE_IF().
This commit is contained in:
Sven Sandberg
2009-07-22 18:16:17 +02:00
parent 6f8f024aaf
commit f404c96e82
25 changed files with 1674 additions and 968 deletions

View File

@ -15,12 +15,15 @@
# - With SQL_LOG_BIN = 1 and binlog_format = MIXED, to verify that it
# writes row events to the binlog.
#
# - If the recursive construct can be invoked so that it has no
# side-effects but it returns a value that may be nondeterministic,
# then it is invoked in such a way that the return value is
# discarded, with SQL_LOG_BIN = 1 and binlog_format = STATEMENT.
# In this case, no warning should be given and nothing should be
# written to the binlog.
# - In some cases, the recursive construct can be invoked so that it
# has no side-effects but returns a value that may be
# nondeterministic. An example is a function that returns UUID().
# The function does not have side effects but its a return value
# that may differ on slave. Such statements are invoked so that
# the return value is discarded (e.g., SELECT func()), with
# SQL_LOG_BIN = 1 and binlog_format = STATEMENT. In this case, no
# warning should be given and nothing should be written to the
# binlog.
#
# This is an auxiliary file particularly targeted to being used by the
# test binlog_unsafe. In this context, the purpose is to check how
@ -289,8 +292,15 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`) {
--eval $CRC_create
}
--echo * binlog_format = STATEMENT: expect warning.
--echo * binlog_format = STATEMENT: expect $CRC_ARG_expected_number_of_warnings warnings.
--eval $CRC_RET_stmt_sidef
--let $n_warnings= `SHOW COUNT(*) WARNINGS`
if (`SELECT '$n_warnings' != '$CRC_ARG_expected_number_of_warnings'`) {
--echo Failure! Expected $CRC_ARG_expected_number_of_warnings warnings, got $n_warnings warnings.
SHOW WARNINGS;
SHOW BINLOG EVENTS;
--exit
}
# These queries are run without query log, to make result file more
# readable. Debug info is only printed if something abnormal
@ -301,19 +311,33 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`) {
SET SQL_LOG_BIN = 0;
RESET MASTER;
--eval $CRC_RET_stmt_sidef
--let $n_warnings= `SHOW COUNT(*) WARNINGS`
if (`SELECT '$n_warnings' != '0'`) {
--echo Failure! Expected 0 warnings, got $n_warnings warnings.
SHOW WARNINGS;
SHOW BINLOG EVENTS;
--exit
}
--let $binlog_event= query_get_value(SHOW BINLOG EVENTS, Event_type, 2)
if (`SELECT '$binlog_event' != 'No such row'`) {
--enable_query_log
--echo Failure! Something was written to the binlog despite SQL_LOG_BIN=0:
SHOW BINLOG EVENTS;
--die
--exit
}
SET SQL_LOG_BIN = 1;
--echo * binlog_format = MIXED: expect row events in binlog and no warning.
SET binlog_format = MIXED;
RESET MASTER;
--eval $CRC_RET_stmt_sidef
--eval $CRC_RET_stmt_sidef
--let $n_warnings= `SHOW COUNT(*) WARNINGS`
if (`SELECT '$n_warnings' != '0'`) {
--echo Failure! Expected 0 warnings, got $n_warnings warnings.
SHOW WARNINGS;
SHOW BINLOG EVENTS;
--exit
}
# The first event is format_description, the second is
# Query_event('BEGIN'), and the third should be our Table_map.
--let $event_type= query_get_value(SHOW BINLOG EVENTS, Event_type, 3)
@ -328,7 +352,7 @@ if (`SELECT '$CRC_RET_stmt_sidef' != ''`) {
# we should instead execute:
#--enable_query_log
#SHOW BINLOG EVENTS;
#--die
#--exit
# Here, we should really source
# include/show_binlog_events.inc. But due to BUG#41913, that
@ -352,6 +376,18 @@ if (`SELECT '$CRC_RET_sel_retval' != ''`) {
--disable_result_log
--eval $CRC_RET_sel_retval
--enable_result_log
# Currently, due to a bug, we do get warnings here, so we don't
# fail. When the bug is fixed, we should execute the following.
#--let $n_warnings= `SHOW COUNT(*) WARNINGS`
#if (`SELECT '$n_warnings' != '0'`) {
# --enable_query_log
# --echo Failure! Expected 0 warnings, got $n_warnings warnings.
# SHOW WARNINGS;
# SHOW BINLOG EVENTS;
# --exit
#}
}
#--echo debug: <<<<EXIT create_recursive_construct