Skip to content

Commit 3dd88fb

Browse files
author
Nirbhay Choubey
committed
MDEV-10714: Could not execute Delete_rows event on table; wsrep_max_ws_rows exceeded. Error_Code 1180
The wsrep_max_ws_rows related implementation should be skipped when server is running with wsrep disabled.
1 parent 616271b commit 3dd88fb

File tree

4 files changed

+104
-22
lines changed

4 files changed

+104
-22
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include/master-slave.inc
2+
[connection master]
3+
#
4+
# MDEV-10714: Could not execute Delete_rows event on table;
5+
# wsrep_max_ws_rows exceeded. Error_Code 1180
6+
#
7+
CREATE TABLE t1(i INT) ENGINE = INNODB;
8+
SET @@GLOBAL.wsrep_max_ws_rows = 1;
9+
INSERT INTO t1 VALUES(1), (2);
10+
SELECT COUNT(*) = 2 FROM t1;
11+
COUNT(*) = 2
12+
1
13+
SET @@GLOBAL.wsrep_max_ws_rows = 1;
14+
DELETE FROM t1;
15+
SELECT COUNT(*) = 0 FROM t1;
16+
COUNT(*) = 0
17+
1
18+
DROP TABLE t1;
19+
SET @@GLOBAL.wsrep_max_ws_rows = 0;
20+
SET @@GLOBAL.wsrep_max_ws_rows = 0;
21+
include/rpl_end.inc
22+
# End of test.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!include ../../rpl/my.cnf
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--source include/have_wsrep.inc
2+
--source include/have_innodb.inc
3+
--source include/master-slave.inc
4+
5+
--echo #
6+
--echo # MDEV-10714: Could not execute Delete_rows event on table;
7+
--echo # wsrep_max_ws_rows exceeded. Error_Code 1180
8+
--echo #
9+
# Save wsrep_max_ws_rows on master and slave.
10+
connection master;
11+
let $wsrep_max_ws_rows_master = `SELECT @@GLOBAL.wsrep_max_ws_rows`;
12+
connection slave;
13+
let $wsrep_max_ws_rows_slave = `SELECT @@GLOBAL.wsrep_max_ws_rows`;
14+
15+
connection master;
16+
CREATE TABLE t1(i INT) ENGINE = INNODB;
17+
18+
# Setting wsrep_max_ws_rows should have no impact on replication master
19+
# unless its a cluster node.
20+
SET @@GLOBAL.wsrep_max_ws_rows = 1;
21+
INSERT INTO t1 VALUES(1), (2);
22+
23+
sync_slave_with_master;
24+
SELECT COUNT(*) = 2 FROM t1;
25+
26+
connection slave;
27+
# Setting wsrep_max_ws_rows should have no impact on replication slave
28+
# unless its a cluster node.
29+
SET @@GLOBAL.wsrep_max_ws_rows = 1;
30+
31+
connection master;
32+
DELETE FROM t1;
33+
34+
sync_slave_with_master;
35+
SELECT COUNT(*) = 0 FROM t1;
36+
37+
connection master;
38+
DROP TABLE t1;
39+
40+
sync_slave_with_master;
41+
42+
# Restore wsrep_max_ws_rows on master and slave
43+
connection master;
44+
eval SET @@GLOBAL.wsrep_max_ws_rows = $wsrep_max_ws_rows_master;
45+
connection slave;
46+
eval SET @@GLOBAL.wsrep_max_ws_rows = $wsrep_max_ws_rows_slave;
47+
48+
--source include/rpl_end.inc
49+
--echo # End of test.
50+

sql/handler.cc

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6109,14 +6109,17 @@ int handler::ha_write_row(uchar *buf)
61096109
if (unlikely(error= binlog_log_row(table, 0, buf, log_func)))
61106110
DBUG_RETURN(error); /* purecov: inspected */
61116111
#ifdef WITH_WSREP
6112-
current_thd->wsrep_affected_rows++;
6113-
if (wsrep_max_ws_rows &&
6114-
current_thd->wsrep_exec_mode != REPL_RECV &&
6115-
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
6112+
if (WSREP(current_thd))
61166113
{
6117-
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
6118-
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
6119-
DBUG_RETURN(ER_ERROR_DURING_COMMIT);
6114+
current_thd->wsrep_affected_rows++;
6115+
if (wsrep_max_ws_rows &&
6116+
current_thd->wsrep_exec_mode != REPL_RECV &&
6117+
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
6118+
{
6119+
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
6120+
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
6121+
DBUG_RETURN(ER_ERROR_DURING_COMMIT);
6122+
}
61206123
}
61216124
#endif /* WITH_WSREP */
61226125

@@ -6153,14 +6156,17 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
61536156
if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func)))
61546157
return error;
61556158
#ifdef WITH_WSREP
6156-
current_thd->wsrep_affected_rows++;
6157-
if (wsrep_max_ws_rows &&
6158-
current_thd->wsrep_exec_mode != REPL_RECV &&
6159-
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
6159+
if (WSREP(current_thd))
61606160
{
6161-
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
6162-
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
6163-
return ER_ERROR_DURING_COMMIT;
6161+
current_thd->wsrep_affected_rows++;
6162+
if (wsrep_max_ws_rows &&
6163+
current_thd->wsrep_exec_mode != REPL_RECV &&
6164+
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
6165+
{
6166+
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
6167+
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
6168+
return ER_ERROR_DURING_COMMIT;
6169+
}
61646170
}
61656171
#endif /* WITH_WSREP */
61666172
return 0;
@@ -6191,14 +6197,17 @@ int handler::ha_delete_row(const uchar *buf)
61916197
if (unlikely(error= binlog_log_row(table, buf, 0, log_func)))
61926198
return error;
61936199
#ifdef WITH_WSREP
6194-
current_thd->wsrep_affected_rows++;
6195-
if (wsrep_max_ws_rows &&
6196-
current_thd->wsrep_exec_mode != REPL_RECV &&
6197-
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
6198-
{
6199-
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
6200-
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
6201-
return ER_ERROR_DURING_COMMIT;
6200+
if (WSREP(current_thd))
6201+
{
6202+
current_thd->wsrep_affected_rows++;
6203+
if (wsrep_max_ws_rows &&
6204+
current_thd->wsrep_exec_mode != REPL_RECV &&
6205+
current_thd->wsrep_affected_rows > wsrep_max_ws_rows)
6206+
{
6207+
trans_rollback_stmt(current_thd) || trans_rollback(current_thd);
6208+
my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
6209+
return ER_ERROR_DURING_COMMIT;
6210+
}
62026211
}
62036212
#endif /* WITH_WSREP */
62046213
return 0;

0 commit comments

Comments
 (0)