Skip to content

Commit d54bc3c

Browse files
author
Nirbhay Choubey
committed
Cleanup: remove dead code which could also lead to race.
1 parent 9d5767c commit d54bc3c

File tree

3 files changed

+59
-18
lines changed

3 files changed

+59
-18
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
2+
SET GLOBAL read_only=TRUE;
3+
INSERT INTO t1 VALUES (1);
4+
SELECT COUNT(*) = 1 FROM t1;
5+
COUNT(*) = 1
6+
1
7+
CREATE USER foo@localhost;
8+
# Open connection to node 2 using 'foo' user.
9+
10+
# Connect with foo_node_2
11+
INSERT INTO t1 VALUES (2);
12+
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
13+
SELECT COUNT(*) = 1 FROM t1;
14+
COUNT(*) = 1
15+
1
16+
SET GLOBAL read_only=FALSE;
17+
DROP TABLE t1;
18+
DROP USER foo@localhost;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--source include/galera_cluster.inc
2+
--source include/have_innodb.inc
3+
4+
#
5+
# Ensure that the read_only option does not apply to Galera appliers and that replication
6+
# continues, the way MySQL replication would.
7+
#
8+
9+
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
10+
11+
--connection node_2
12+
SET GLOBAL read_only=TRUE;
13+
14+
--connection node_1
15+
INSERT INTO t1 VALUES (1);
16+
17+
--connection node_2
18+
SELECT COUNT(*) = 1 FROM t1;
19+
20+
CREATE USER foo@localhost;
21+
22+
--echo # Open connection to node 2 using 'foo' user.
23+
--let $port_2= \$NODE_MYPORT_2
24+
--connect(foo_node_2,127.0.0.1,foo,,test,$port_2,)
25+
26+
--echo
27+
--echo # Connect with foo_node_2
28+
--connection foo_node_2
29+
--error ER_OPTION_PREVENTS_STATEMENT
30+
INSERT INTO t1 VALUES (2);
31+
32+
--connection node_2
33+
SELECT COUNT(*) = 1 FROM t1;
34+
35+
# Cleanup
36+
SET GLOBAL read_only=FALSE;
37+
DROP TABLE t1;
38+
DROP USER foo@localhost;
39+

sql/sql_parse.cc

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -982,22 +982,6 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
982982
}
983983

984984
#ifdef WITH_WSREP
985-
static my_bool wsrep_read_only_option(THD *thd, TABLE_LIST *all_tables)
986-
{
987-
int opt_readonly_saved = opt_readonly;
988-
ulong flag_saved = (ulong)(thd->security_ctx->master_access & SUPER_ACL);
989-
990-
opt_readonly = 0;
991-
thd->security_ctx->master_access &= ~SUPER_ACL;
992-
993-
my_bool ret = !deny_updates_if_read_only_option(thd, all_tables);
994-
995-
opt_readonly = opt_readonly_saved;
996-
thd->security_ctx->master_access |= flag_saved;
997-
998-
return ret;
999-
}
1000-
1001985
static void wsrep_copy_query(THD *thd)
1002986
{
1003987
thd->wsrep_retry_command = thd->command;
@@ -1011,6 +995,7 @@ static void wsrep_copy_query(THD *thd)
1011995
thd->wsrep_retry_query[thd->wsrep_retry_query_len] = '\0';
1012996
}
1013997
#endif /* WITH_WSREP */
998+
1014999
/**
10151000
Perform one connection-level (COM_XXXX) command.
10161001
@@ -6355,8 +6340,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
63556340
bool is_autocommit=
63566341
!thd->in_multi_stmt_transaction_mode() &&
63576342
thd->wsrep_conflict_state == NO_CONFLICT &&
6358-
!thd->wsrep_applier &&
6359-
wsrep_read_only_option(thd, thd->lex->query_tables);
6343+
!thd->wsrep_applier;
63606344

63616345
do
63626346
{

0 commit comments

Comments
 (0)