Skip to content

Commit 9e572fe

Browse files
committed
Merge mysql-8.0 -> trunk
2 parents 369a584 + 9c22450 commit 9e572fe

File tree

11 files changed

+128
-97
lines changed

11 files changed

+128
-97
lines changed

mysql-test/suite/ndb_binlog/r/ndb_binlog_restart.result

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ Disconnect both mysqld servers from all datanodes -> binlog restarts
4949
Wait for 'server1' binlog rotate to indicate disconnect
5050
Wait for 'server2' binlog rotate to indicate disconnect
5151
Wait for (fast) 'server1' to complete setup and get out of read-only mode
52-
Reading 'mysql.ndb_schema' on 'server2' announce schema distr. participation as a side effect.
53-
select * from mysql.ndb_schema where db="" and name="";
5452
Create table operation on 'server1' grab MDL lock while waiting for
5553
schema distribution to all subscribing mysqld -> stuck on 'server2'
5654
create table t1 (a int primary key) engine=ndb;

mysql-test/suite/ndb_binlog/t/ndb_binlog_discover.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ reset master;
2020
let $mysql_errno= 1;
2121
while ($mysql_errno)
2222
{
23-
# Table t1 is readonly until the mysqld has reconnected properly
24-
--error 0,1036,1296
23+
# Table t1 can't be opened until the mysqld has reconnected properly
24+
--error 0,ER_GET_ERRMSG
2525
insert into t1 values(1);
2626
if ($mysql_errno)
2727
{

mysql-test/suite/ndb_binlog/t/ndb_binlog_restart.test

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,6 @@ connection server1;
246246
--echo Wait for (fast) 'server1' to complete setup and get out of read-only mode
247247
--source include/ndb_not_readonly.inc
248248

249-
connection server2;
250-
--echo Reading 'mysql.ndb_schema' on 'server2' announce schema distr. participation as a side effect.
251-
disable_result_log;
252-
--error 0,ER_NO_SUCH_TABLE,ER_OPEN_AS_READONLY,ER_GET_ERRMSG,ER_TABLE_DEF_CHANGED,ER_NOT_FORM_FILE,ER_KEY_NOT_FOUND
253-
select * from mysql.ndb_schema where db="" and name="";
254-
enable_result_log;
255-
256249
connection server1;
257250
--echo Create table operation on 'server1' grab MDL lock while waiting for
258251
--echo schema distribution to all subscribing mysqld -> stuck on 'server2'

mysql-test/suite/ndb_ddl/identifier_limits.result

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@
55
create table abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123(
66
id int primary key
77
) engine=ndb;
8-
ERROR 42000: Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
9-
show warnings;
10-
Level Code Message
11-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
12-
Error 1059 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
13-
Error 1031 Table storage engine for 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' doesn't have this option
8+
drop table abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
149
# ############################################################
1510
# Bug19550973: CREATE/DROP DATABASE STATEMENT SEGFAULTS IF
1611
# IDENTIFIER LENGTH IS >=64
1712
# ############################################################
1813
#
1914
# 1. Testing schema identifier with length 63
20-
# NOTE! ndb_schema identifier length limit is currently 63
2115
#
2216
CREATE DATABASE
2317
abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12;
@@ -30,76 +24,52 @@ DROP TABLE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12.t1;
3024
DROP DATABASE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12;
3125
#
3226
# 2. Testing schema identifier with length 64
33-
# NOTE! MySQL Server allows 64, but ndb_schema limit is currently 63
3427
#
3528
CREATE DATABASE
3629
abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
37-
Warnings:
38-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
39-
Warning 1296 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
4030
# Verify database existence
4131
USE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
4232
# Create non NDB table
4333
CREATE TABLE t1 (
4434
a int
4535
);
46-
# Create NDB table should fail
36+
# Create NDB table
4737
CREATE TABLE t2 (
4838
a int
4939
) ENGINE=NDB;
50-
ERROR 42000: Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
51-
show warnings;
52-
Level Code Message
53-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
54-
Error 1059 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
55-
Error 1031 Table storage engine for 't2' doesn't have this option
5640
#
57-
# 3. Databases with identifier length = 64 won't be replicated to other
58-
# MySQL Servers. Verify that the above created dabatase is not present
41+
# 3. Databases with identifier length = 64 is synchronized to other
42+
# MySQL Servers. Verify that the above created dabatase is present
5943
# in the other Server
44+
# NOTE! This testcase was fixed by BUG#27447958 which extended ndb_schema
45+
# to support identifiers > 63
6046
#
6147
USE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
62-
ERROR 42000: Unknown database 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123'
6348
#
6449
# 4. Testing alter database
6550
#
6651
ALTER DATABASE
6752
abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123
6853
character set=utf8mb4;
69-
Warnings:
70-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
71-
Warning 1296 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
7254
CREATE DATABASE db1;
7355
CREATE TABLE db1.t1 (
7456
a int
7557
) ENGINE=NDB;
58+
CREATE TABLE db1.t2 (
59+
a int
60+
) ENGINE=NDB;
7661
#
77-
# 4.1 Renaming table to too long database name should fail
62+
# 4.1 Renaming table to long database name
7863
#
7964
ALTER TABLE db1.t1
8065
RENAME abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123.t3;
81-
ERROR 42000: Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
82-
SHOW WARNINGS;
83-
Level Code Message
84-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
85-
Error 1059 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
86-
Error 1025 Error on rename of './db1/t1' to './abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123/t3' (errno: 140 - Wrong create options)
8766
#
88-
# 4.2 Renaming table to too long table name should fail
67+
# 4.2 Renaming table to long table name
8968
#
90-
ALTER TABLE db1.t1
69+
ALTER TABLE db1.t2
9170
RENAME db1.abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
92-
ERROR 42000: Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
93-
SHOW WARNINGS;
94-
Level Code Message
95-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
96-
Error 1059 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
97-
Error 1025 Error on rename of './db1/t1' to './db1/abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' (errno: 140 - Wrong create options)
9871
DROP DATABASE db1;
9972
DROP DATABASE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
100-
Warnings:
101-
Warning 1296 [mysql.ndb_schema] Identifier length exceeds the 63 byte limit
102-
Warning 1296 Identifier name 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123' is too long
10373
# Checking that database doesn't exists
10474
USE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
10575
ERROR 42000: Unknown database 'abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123'

mysql-test/suite/ndb_ddl/identifier_limits.test

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
--echo # Bug11753491: MYSQLD CRASHES WHEN CREATING A CLUSTER TABLE WITH 64
1010
--echo # CHARACTER TABLE NAME
1111
--echo # ####################################################################
12-
--error ER_TOO_LONG_IDENT
1312
create table abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123(
1413
id int primary key
1514
) engine=ndb;
16-
show warnings;
17-
15+
drop table abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
1816

1917
--echo # ############################################################
2018
--echo # Bug19550973: CREATE/DROP DATABASE STATEMENT SEGFAULTS IF
@@ -28,7 +26,6 @@ call mtr.add_suppression("Failed to distribute");
2826

2927
--echo #
3028
--echo # 1. Testing schema identifier with length 63
31-
--echo # NOTE! ndb_schema identifier length limit is currently 63
3229
--echo #
3330
CREATE DATABASE
3431
abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12;
@@ -43,7 +40,6 @@ DROP DATABASE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12;
4340

4441
--echo #
4542
--echo # 2. Testing schema identifier with length 64
46-
--echo # NOTE! MySQL Server allows 64, but ndb_schema limit is currently 63
4743
--echo #
4844
CREATE DATABASE
4945
abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
@@ -54,20 +50,19 @@ USE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
5450
CREATE TABLE t1 (
5551
a int
5652
);
57-
--echo # Create NDB table should fail
58-
--error ER_TOO_LONG_IDENT
53+
--echo # Create NDB table
5954
CREATE TABLE t2 (
6055
a int
6156
) ENGINE=NDB;
62-
show warnings;
6357

6458
--echo #
65-
--echo # 3. Databases with identifier length = 64 won't be replicated to other
66-
--echo # MySQL Servers. Verify that the above created dabatase is not present
59+
--echo # 3. Databases with identifier length = 64 is synchronized to other
60+
--echo # MySQL Servers. Verify that the above created dabatase is present
6761
--echo # in the other Server
62+
--echo # NOTE! This testcase was fixed by BUG#27447958 which extended ndb_schema
63+
--echo # to support identifiers > 63
6864
--echo #
6965
--connection mysqld2
70-
--error ER_BAD_DB_ERROR
7166
USE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
7267
--connection mysqld1
7368

@@ -82,26 +77,21 @@ CREATE DATABASE db1;
8277
CREATE TABLE db1.t1 (
8378
a int
8479
) ENGINE=NDB;
80+
CREATE TABLE db1.t2 (
81+
a int
82+
) ENGINE=NDB;
8583

8684
--echo #
87-
--echo # 4.1 Renaming table to too long database name should fail
85+
--echo # 4.1 Renaming table to long database name
8886
--echo #
89-
--error ER_TOO_LONG_IDENT
9087
ALTER TABLE db1.t1
9188
RENAME abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123.t3;
92-
# replace win slashes since not using default database
93-
--replace_regex /[\\]/\//
94-
SHOW WARNINGS;
9589

9690
--echo #
97-
--echo # 4.2 Renaming table to too long table name should fail
91+
--echo # 4.2 Renaming table to long table name
9892
--echo #
99-
--error ER_TOO_LONG_IDENT
100-
ALTER TABLE db1.t1
93+
ALTER TABLE db1.t2
10194
RENAME db1.abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
102-
# replace win slashes since not using default database
103-
--replace_regex /[\\]/\//
104-
SHOW WARNINGS;
10595

10696
DROP DATABASE db1;
10797
DROP DATABASE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz123;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Test failure to acquire NDB_SHARE while opening table. This is an
3+
# unusual error condition and can thus be reproduced only with
4+
# error injection.
5+
#
6+
CREATE TABLE t1(
7+
id INT PRIMARY KEY,
8+
val INT
9+
) ENGINE=ndbcluster;
10+
set @save_debug = @@session.debug;
11+
SET SESSION debug="+d,ndb_share_acquire_fail1";
12+
SELECT * FROM t1;
13+
ERROR HY000: Got error 4009 'Cluster Failure' from NDBCLUSTER
14+
SHOW WARNINGS;
15+
Level Code Message
16+
Warning 1296 Could not open NDB_SHARE for './test/t1'
17+
Error 1296 Got error 4009 'Cluster Failure' from NDBCLUSTER
18+
SET SESSION debug=@save_debug;
19+
# Cleanup and remove the table
20+
DROP TABLE t1;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- source include/have_ndb.inc
2+
-- source include/have_debug.inc
3+
4+
--echo #
5+
--echo # Test failure to acquire NDB_SHARE while opening table. This is an
6+
--echo # unusual error condition and can thus be reproduced only with
7+
--echo # error injection.
8+
--echo #
9+
CREATE TABLE t1(
10+
id INT PRIMARY KEY,
11+
val INT
12+
) ENGINE=ndbcluster;
13+
14+
set @save_debug = @@session.debug;
15+
# Force error to occur while opening table
16+
SET SESSION debug="+d,ndb_share_acquire_fail1";
17+
--error ER_GET_ERRMSG
18+
SELECT * FROM t1;
19+
SHOW WARNINGS;
20+
SET SESSION debug=@save_debug;
21+
22+
--echo # Cleanup and remove the table
23+
DROP TABLE t1;

storage/ndb/plugin/ha_ndbcluster.cc

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11184,13 +11184,29 @@ int ha_ndbcluster::open(const char *name, int, uint,
1118411184
return res;
1118511185
}
1118611186

11187+
// Don't allow opening table unless schema distribution is ready and
11188+
// schema synchronization have completed. The user who wants to use
11189+
// this table has to wait.
11190+
if (ndb_binlog_is_read_only()) {
11191+
const Thd_ndb *thd_ndb = get_thd_ndb(thd);
11192+
thd_ndb->push_warning(
11193+
"Can't open table '%s' from NDB, schema distribution is not ready",
11194+
name);
11195+
local_close(thd, false);
11196+
return HA_ERR_NO_CONNECTION;
11197+
}
11198+
1118711199
// Acquire NDB_SHARE reference for handler
1118811200
m_share = NDB_SHARE::acquire_for_handler(name, this);
1118911201
if (m_share == nullptr) {
11190-
// NOTE! This never happens, the NDB_SHARE should already have been
11191-
// created by schema distribution or auto discovery
11202+
// Failed to acquire the NDB_SHARE. This is a rare case, it should already
11203+
// have been created when table was created, during schema synchronization
11204+
// or by auto discovery. Push warning explaining the problem and return a
11205+
// sensible error
11206+
const Thd_ndb *thd_ndb = get_thd_ndb(thd);
11207+
thd_ndb->push_warning("Could not open NDB_SHARE for '%s'", name);
1119211208
local_close(thd, false);
11193-
return 1;
11209+
return HA_ERR_NO_CONNECTION;
1119411210
}
1119511211

1119611212
// Init table lock structure
@@ -11205,10 +11221,6 @@ int ha_ndbcluster::open(const char *name, int, uint,
1120511221
local_close(thd, true);
1120611222
return res;
1120711223
}
11208-
if (ndb_binlog_is_read_only()) {
11209-
table->db_stat |= HA_READ_ONLY;
11210-
ndb_log_info("table '%s' opened read only", name);
11211-
}
1121211224
return 0;
1121311225
}
1121411226

storage/ndb/plugin/ha_ndbcluster_binlog.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,8 +5337,7 @@ class Ndb_schema_event_handler {
53375337
case NdbDictionary::Event::TE_DROP:
53385338
// Cluster failure or ndb_schema_result table dropped
53395339
if (ndb_binlog_tables_inited && ndb_binlog_running)
5340-
ndb_log_verbose(
5341-
1, "NDB Binlog: NDB tables initially readonly on reconnect.");
5340+
ndb_log_verbose(1, "NDB Binlog: util tables need to reinitialize");
53425341

53435342
// Indicate util tables not ready
53445343
mysql_mutex_lock(&injector_data_mutex);
@@ -5412,8 +5411,7 @@ class Ndb_schema_event_handler {
54125411
case NDBEVENT::TE_DROP:
54135412
/* ndb_schema table DROPped */
54145413
if (ndb_binlog_tables_inited && ndb_binlog_running)
5415-
ndb_log_verbose(
5416-
1, "NDB Binlog: NDB tables initially readonly on reconnect.");
5414+
ndb_log_verbose(1, "NDB Binlog: util tables need to reinitialize");
54175415

54185416
// Indicate util tables not ready
54195417
mysql_mutex_lock(&injector_data_mutex);
@@ -6955,8 +6953,7 @@ static void handle_non_data_event(THD *thd, NdbEventOperation *pOp,
69556953
case NDBEVENT::TE_DROP:
69566954
if (ndb_apply_status_share == share) {
69576955
if (ndb_binlog_tables_inited && ndb_binlog_running)
6958-
ndb_log_verbose(
6959-
1, "NDB Binlog: NDB tables initially readonly on reconnect.");
6956+
ndb_log_verbose(1, "NDB Binlog: util tables need to reinitialize");
69606957

69616958
/* release the ndb_apply_status_share */
69626959
NDB_SHARE::release_reference(ndb_apply_status_share,

0 commit comments

Comments
 (0)