Commit 00c44fb1 authored by Nisha Gopalakrishnan's avatar Nisha Gopalakrishnan Committed by Daniel Black

MDEV-4851: BUG#11763447: 'YOU CANNOT 'ALTER' A LOG TABLE IF LOGGING IS ENABLED'

               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
parent 83bd8ebf
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates.
/* Copyright (c) 2000, 2012, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
......@@ -534,9 +534,11 @@ bool LOGGER::is_log_table_enabled(uint log_table_type)
{
switch (log_table_type) {
case QUERY_LOG_SLOW:
return (table_log_handler != NULL) && global_system_variables.sql_log_slow;
return (table_log_handler != NULL) && global_system_variables.sql_log_slow
&& (log_output_options & LOG_TABLE);
case QUERY_LOG_GENERAL:
return (table_log_handler != NULL) && opt_log ;
return (table_log_handler != NULL) && opt_log
&& (log_output_options & LOG_TABLE);
default:
DBUG_ASSERT(0);
return FALSE; /* make compiler happy */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment