Skip to content

Fixes codership/mysql-wsrep#149 #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 5.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions mysql-test/suite/galera/r/galera_flush.result
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,24 @@ CREATE TABLE t2 (f1 INTEGER);
FLUSH TABLES t2;
wsrep_last_committed_diff
1
FLUSH ERROR LOGS;
wsrep_last_committed_diff
1
FLUSH SLOW LOGS;
wsrep_last_committed_diff
1
FLUSH GENERAL LOGS;
wsrep_last_committed_diff
1
FLUSH ENGINE LOGS;
wsrep_last_committed_diff
1
FLUSH RELAY LOGS;
wsrep_last_committed_diff
1
CREATE TABLE t1 (f1 INTEGER);
FLUSH LOGS;
FLUSH BINARY LOGS;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
FLUSH TABLES t1 WITH READ LOCK;
Expand Down
70 changes: 70 additions & 0 deletions mysql-test/suite/galera/r/galera_flush_gtid.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FLUSH DES_KEY_FILE;
wsrep_last_committed_diff
1
FLUSH HOSTS;
wsrep_last_committed_diff
1
SET GLOBAL wsrep_replicate_myisam = TRUE;
INSERT INTO mysql.user VALUES('localhost','user1',PASSWORD('pass1'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password','','N');
FLUSH PRIVILEGES;
DELETE FROM mysql.user WHERE user = 'user1';
SET GLOBAL wsrep_replicate_myisam = FALSE;
FLUSH PRIVILEGES;
FLUSH QUERY CACHE;
wsrep_last_committed_diff
1
FLUSH STATUS;
wsrep_last_committed_diff
1
FLUSH USER_RESOURCES;
wsrep_last_committed_diff
1
FLUSH TABLES;
wsrep_last_committed_diff
1
CREATE TABLE t2 (f1 INTEGER);
FLUSH TABLES t2;
wsrep_last_committed_diff
1
FLUSH ERROR LOGS;
wsrep_last_committed_diff
1
FLUSH SLOW LOGS;
wsrep_last_committed_diff
1
FLUSH GENERAL LOGS;
wsrep_last_committed_diff
1
FLUSH ENGINE LOGS;
wsrep_last_committed_diff
1
FLUSH RELAY LOGS;
wsrep_last_committed_diff
1
CREATE TABLE t1 (f1 INTEGER);
FLUSH LOGS;
FLUSH BINARY LOGS;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
FLUSH TABLES t1 WITH READ LOCK;
UNLOCK TABLES;
FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
wsrep_last_committed_diff
1
LOCK TABLES t1 WRITE;
FLUSH TABLES t1;
UNLOCK TABLES;
wsrep_last_committed_diff
1
LOCK TABLES t1 READ;
FLUSH TABLES t1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
UNLOCK TABLES;
wsrep_last_committed_diff
1
FLUSH TABLES t1;
wsrep_last_committed_diff
1
DROP TABLE t1;
DROP TABLE t2;
55 changes: 54 additions & 1 deletion mysql-test/suite/galera/t/galera_flush.test
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,60 @@ FLUSH TABLES t2;
--enable_query_log


--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
FLUSH ERROR LOGS;
--connection node_2
--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--disable_query_log
--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
--enable_query_log


--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
FLUSH SLOW LOGS;
--connection node_2
--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--disable_query_log
--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
--enable_query_log

--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
FLUSH GENERAL LOGS;
--connection node_2
--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--disable_query_log
--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
--enable_query_log

--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
FLUSH ENGINE LOGS;
--connection node_2
--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--disable_query_log
--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
--enable_query_log

--connection node_2
--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--connection node_1
FLUSH RELAY LOGS;
--connection node_2
--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
--disable_query_log
--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff;
--enable_query_log


#
# The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES WITH LOCKS
# The following statements should not be replicated: FLUSH LOGS, FLUSH BINARY LOGS, FLUSH TABLES WITH LOCKS.
#


Expand All @@ -114,6 +166,7 @@ CREATE TABLE t1 (f1 INTEGER);

--connection node_1
FLUSH LOGS;
FLUSH BINARY LOGS;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
FLUSH TABLES t1 WITH READ LOCK;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/galera/t/galera_flush_gtid-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--query_cache_type=1 --query_cache_size=1000000 --gtid-mode=ON --log-bin --log-slave-updates --enforce-gtid-consistency
9 changes: 9 additions & 0 deletions mysql-test/suite/galera/t/galera_flush_gtid.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Test that various FLUSH commands are replicated.
# This is similar to galera_flush.test except
# with gtid and binlogging enabled.
#

--source include/have_log_bin.inc
--source suite/galera/t/galera_flush.test

32 changes: 13 additions & 19 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4581,7 +4581,20 @@ case SQLCOM_PREPARE:
if (lex->type & (
REFRESH_GRANT |
REFRESH_HOSTS |
#ifdef HAVE_OPENSSL
REFRESH_DES_KEY_FILE |
#endif
/*
* Write all flush log statements except
* FLUSH LOGS
* FLUSH BINARY LOGS
* Check reload_acl_and_cache for why.
*/
REFRESH_RELAY_LOG |
REFRESH_SLOW_LOG |
REFRESH_GENERAL_LOG |
REFRESH_ENGINE_LOG |
REFRESH_ERROR_LOG |
#ifdef HAVE_QUERY_CACHE
REFRESH_QUERY_CACHE_FREE |
#endif /* HAVE_QUERY_CACHE */
Expand All @@ -4598,25 +4611,6 @@ case SQLCOM_PREPARE:
*/
if (!reload_acl_and_cache(thd, lex->type, first_table, &write_to_binlog))
{
#ifdef WITH_WSREP
if ((lex->type & REFRESH_TABLES) && !(lex->type & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK)))
{
/*
This is done after reload_acl_and_cache is because
LOCK TABLES is not replicated in galera, the upgrade of which
is checked in reload_acl_and_cache.
Hence, done after/if we are able to upgrade locks.
*/
if (first_table)
{
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, first_table);
}
else
{
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
}
}
#endif /* WITH_WSREP */
/*
We WANT to write and we CAN write.
! we write after unlocking the table.
Expand Down
35 changes: 35 additions & 0 deletions sql/sql_reload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "rpl_mi.h"
#include "debug_sync.h"

#ifdef WITH_WSREP
#include "sql_parse.h"
#endif /* WITH_WSREP */

/**
Reload/resets privileges and the different caches.
Expand Down Expand Up @@ -303,6 +306,35 @@ bool reload_acl_and_cache(THD *thd, unsigned long options,
}
}
}
#ifdef WITH_WSREP
if (WSREP(thd) && (options & REFRESH_TABLES) &&
!(options & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK)))
{
/*
This is done here because LOCK TABLES is not replicated in galera,
the upgrade of which is checked above. Hence, done after/if we
are able to upgrade locks.

Also, note that, in error log with debug you may see
'thread holds MDL locks at TI' but since this is a flush
tables and is required for LOCK TABLE WRITE
it can be ignored there.
*/
if (tables)
{
if (wsrep_to_isolation_begin(thd, NULL, NULL, tables))
{
result= 1;
goto cleanup;
}
}
else if (wsrep_to_isolation_begin(thd, WSREP_MYSQL_DB, NULL, NULL))
{
result= 1;
goto cleanup;
}
}
#endif /* WITH_WSREP */

if (close_cached_tables(thd, tables,
((options & REFRESH_FAST) ? FALSE : TRUE),
Expand All @@ -316,6 +348,9 @@ bool reload_acl_and_cache(THD *thd, unsigned long options,
result= 1;
}
}
#ifdef WITH_WSREP
cleanup:
#endif /* WITH_WSREP */
my_dbopt_cleanup();
}
if (options & REFRESH_HOSTS)
Expand Down