Skip to content

Commit c768ac6

Browse files
janlindstromsysprg
authored andcommitted
MDEV-25731 : Assertion `mode_ == m_local' failed in wsrep::client_state::streaming_params()
Problem was that if wsrep_load_data_splitting was used streaming replication (SR) parameters were set for MyISAM table. Galera does not currently support SR for MyISAM. Fix is to ignore wsrep_load_data_splitting setting (with warning) if table is not InnoDB table. This is 10.4-10.5 case of fix. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent daaa16a commit c768ac6

File tree

4 files changed

+98
-10
lines changed

4 files changed

+98
-10
lines changed

mysql-test/std_data/mdev-25731.dat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1
2+
2
3+
3
4+
1
5+
5
6+
6
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
connection node_2;
2+
connection node_1;
3+
connection node_1;
4+
SET GLOBAL wsrep_load_data_splitting=ON;
5+
Warnings:
6+
Warning 1287 '@@wsrep_load_data_splitting' is deprecated and will be removed in a future release
7+
SET GLOBAL wsrep_replicate_myisam=ON;
8+
CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
9+
LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n';
10+
Warnings:
11+
Warning 1235 wsrep_load_data_splitting for other than InnoDB tables
12+
SELECT COUNT(*) AS EXPECT_6 FROM t1;
13+
EXPECT_6
14+
6
15+
connection node_2;
16+
SELECT COUNT(*) AS EXPECT_6 FROM t1;
17+
EXPECT_6
18+
6
19+
connection node_1;
20+
ALTER TABLE t1 ENGINE=InnoDB;
21+
LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n';
22+
SELECT COUNT(*) AS EXPECT_12 FROM t1;
23+
EXPECT_12
24+
12
25+
connection node_2;
26+
SELECT COUNT(*) AS EXPECT_12 FROM t1;
27+
EXPECT_12
28+
12
29+
connection node_1;
30+
DROP TABLE t1;
31+
SET GLOBAL wsrep_load_data_splitting=OFF;
32+
Warnings:
33+
Warning 1287 '@@wsrep_load_data_splitting' is deprecated and will be removed in a future release
34+
SET GLOBAL wsrep_replicate_myisam=OFF;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--source include/galera_cluster.inc
2+
--source include/have_aria.inc
3+
4+
--connection node_1
5+
SET GLOBAL wsrep_load_data_splitting=ON;
6+
SET GLOBAL wsrep_replicate_myisam=ON;
7+
CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
8+
LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n';
9+
SELECT COUNT(*) AS EXPECT_6 FROM t1;
10+
11+
--connection node_2
12+
SELECT COUNT(*) AS EXPECT_6 FROM t1;
13+
14+
--connection node_1
15+
ALTER TABLE t1 ENGINE=InnoDB;
16+
LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n';
17+
SELECT COUNT(*) AS EXPECT_12 FROM t1;
18+
19+
--connection node_2
20+
SELECT COUNT(*) AS EXPECT_12 FROM t1;
21+
22+
--connection node_1
23+
DROP TABLE t1;
24+
SET GLOBAL wsrep_load_data_splitting=OFF;
25+
SET GLOBAL wsrep_replicate_myisam=OFF;
26+
27+

sql/sql_load.cc

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,41 @@ class Term_string
105105
class Wsrep_load_data_split
106106
{
107107
public:
108-
Wsrep_load_data_split(THD *thd)
108+
Wsrep_load_data_split(THD *thd, TABLE *table)
109109
: m_thd(thd)
110-
, m_load_data_splitting(wsrep_load_data_splitting)
110+
, m_load_data_splitting(false)
111111
, m_fragment_unit(thd->wsrep_trx().streaming_context().fragment_unit())
112112
, m_fragment_size(thd->wsrep_trx().streaming_context().fragment_size())
113113
{
114-
if (WSREP(m_thd) && m_load_data_splitting)
114+
/*
115+
We support load data splitting for InnoDB only as it will use
116+
streaming replication (SR).
117+
*/
118+
if (WSREP(thd) && wsrep_load_data_splitting)
115119
{
116-
/* Override streaming settings with backward compatible values for
117-
load data splitting */
118-
m_thd->wsrep_cs().streaming_params(wsrep::streaming_context::row, 10000);
120+
handlerton *ht= table->s->db_type();
121+
// For partitioned tables find underlying hton
122+
if (table->file->partition_ht())
123+
ht= table->file->partition_ht();
124+
if (ht->db_type != DB_TYPE_INNODB)
125+
{
126+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
127+
ER_NOT_SUPPORTED_YET,
128+
"wsrep_load_data_splitting for other than InnoDB tables");
129+
}
130+
else
131+
{
132+
/* Override streaming settings with backward compatible values for
133+
load data splitting */
134+
m_thd->wsrep_cs().streaming_params(wsrep::streaming_context::row, 10000);
135+
m_load_data_splitting= true;
136+
}
119137
}
120138
}
121139

122140
~Wsrep_load_data_split()
123141
{
124-
if (WSREP(m_thd) && m_load_data_splitting)
142+
if (m_load_data_splitting)
125143
{
126144
/* Restore original settings */
127145
m_thd->wsrep_cs().streaming_params(m_fragment_unit, m_fragment_size);
@@ -346,6 +364,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
346364
bool is_concurrent;
347365
#endif
348366
const char *db= table_list->db.str; // This is never null
367+
349368
/*
350369
If path for file is not defined, we will use the current database.
351370
If this is not set, we will use the directory where the table to be
@@ -356,9 +375,6 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
356375
bool transactional_table __attribute__((unused));
357376
DBUG_ENTER("mysql_load");
358377

359-
#ifdef WITH_WSREP
360-
Wsrep_load_data_split wsrep_load_data_split(thd);
361-
#endif /* WITH_WSREP */
362378
/*
363379
Bug #34283
364380
mysqlbinlog leaves tmpfile after termination if binlog contains
@@ -422,6 +438,11 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
422438
{
423439
DBUG_RETURN(TRUE);
424440
}
441+
442+
#ifdef WITH_WSREP
443+
Wsrep_load_data_split wsrep_load_data_split(thd, table_list->table);
444+
#endif /* WITH_WSREP */
445+
425446
thd_proc_info(thd, "Executing");
426447
/*
427448
Let us emit an error if we are loading data to table which is used

0 commit comments

Comments
 (0)