Skip to content

Commit 9d13ac3

Browse files
author
Allen lai
committed
Bug#15963619 GETTING "TABLE IS READ ONLY" ERROR EVEN WHILE READING
WITH --INNODB-READ-ONLY rb://2439 Approved by Jimmy This fix is based on the Sunny's patch in the bug report. When InnoDB is in read-only mode, we prevent all lock operation in ha_innodbase::external_lock as MySQL want to create table. In fact, we only need to prevent write lock operation when MySQL is doing create table.
1 parent 2cc1e9d commit 9d13ac3

File tree

11 files changed

+68
-26
lines changed

11 files changed

+68
-26
lines changed

include/my_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ is the global server default. */
479479
#define HA_ERR_TABLESPACE_EXISTS 184 /* The tablespace existed in storage engine */
480480
#define HA_ERR_TOO_MANY_FIELDS 185 /* Table has too many columns */
481481
#define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partition */
482-
#define HA_ERR_LAST 186 /* Copy of last error nr */
482+
#define HA_ERR_INNODB_READ_ONLY 187 /* InnoDB is in read only mode. */
483+
#define HA_ERR_LAST 187 /* Copy of last error nr */
483484

484485
/* Number of different errors */
485486
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Write file to make mysql-test-run.pl expect the "crash", but don't start
2+
# it until it's told to
3+
--let $_server_id= `SELECT @@server_id`
4+
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
5+
--exec echo "wait" > $_expect_file_name
6+
7+
# Send shutdown to the connected server and give
8+
# it 10 seconds to die before zapping it
9+
shutdown_server 10;
10+
11+
# Write file to make mysql-test-run.pl start up the server again
12+
--exec echo "restart: --innodb-read-only " > $_expect_file_name
13+
14+
# Turn on reconnect
15+
--enable_reconnect
16+
17+
# Call script that will poll the server waiting for it to be back online again
18+
--source include/wait_until_connected_again.inc
19+
20+
# Turn off reconnect again
21+
--disable_reconnect

mysql-test/suite/innodb/r/innodb-wl6445-1.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ i LEFT(j,20)
6363
2 bbbbbbbbbbbbbbbbbbbb
6464
3 cccccccccccccccccccc
6565
CREATE TABLE t2 ( i int ,j blob) ENGINE = Innodb;
66-
ERROR HY000: Table 't2' is read only
66+
ERROR HY000: InnoDB is in read only mode.
6767
UPDATE t1 SET i = i+1;
6868
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
6969
# disconnect con_test1_user
@@ -80,7 +80,7 @@ i LEFT(j,20)
8080
2 bbbbbbbbbbbbbbbbbbbb
8181
3 cccccccccccccccccccc
8282
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
83-
ERROR HY000: Table 't2' is read only
83+
ERROR HY000: InnoDB is in read only mode.
8484
UPDATE t1 SET i = i+1;
8585
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
8686
FLUSH STATUS;
@@ -99,7 +99,7 @@ i LEFT(j,20)
9999
2 bbbbbbbbbbbbbbbbbbbb
100100
3 cccccccccccccccccccc
101101
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
102-
ERROR HY000: Table 't2' is read only
102+
ERROR HY000: InnoDB is in read only mode.
103103
UPDATE t1 SET i = i+1;
104104
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
105105
INSERT INTO otherlocation VALUES (1),(2),(3);
@@ -153,7 +153,7 @@ i LEFT(j,20)
153153
40 a40a40a40a40a40a40a4
154154
50 a50a50a50a50a50a50a5
155155
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
156-
ERROR HY000: Table 't2' is read only
156+
ERROR HY000: InnoDB is in read only mode.
157157
UPDATE t1 SET i = i+1;
158158
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
159159
SELECT i,LEFT(j,20) FROM t1 WHERE i%10=0 ORDER BY i;
@@ -1180,7 +1180,7 @@ SELECT * FROM t3;
11801180
i j
11811181
1 test1
11821182
CREATE TEMPORARY TABLE temp_1 ( i INT ) ENGINE = Innodb;
1183-
ERROR HY000: Table 'temp_1' is read only
1183+
ERROR HY000: InnoDB is in read only mode.
11841184
INSERT INTO testdb_wl6445.t4 VALUES (1),(2),(3),(4),(5),(6);
11851185
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
11861186
SELECT * FROM testdb_wl6445.t4 ORDER BY val;
@@ -1276,7 +1276,7 @@ ERROR HY000: Can't lock file (errno: 165 - Table is read only)
12761276
DELETE FROM t1;
12771277
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
12781278
CREATE TABLE t2 ( i INT ) ENGINE = Innodb;
1279-
ERROR HY000: Table 't2' is read only
1279+
ERROR HY000: InnoDB is in read only mode.
12801280
CREATE USER 'test5'@'localhost' IDENTIFIED BY '123';
12811281
GRANT ALL ON testdb_wl6445.* TO 'test5'@'localhost';
12821282
USE testdb_wl6445;

mysql-test/suite/innodb/r/innodb-wl6445-2.result

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ i LEFT(j,20)
4444
2 bbbbbbbbbbbbbbbbbbbb
4545
3 cccccccccccccccccccc
4646
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
47-
ERROR HY000: Table 't2' is read only
47+
ERROR HY000: InnoDB is in read only mode.
4848
UPDATE t1 SET i = i+1;
4949
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
5050
FLUSH STATUS;
@@ -109,6 +109,8 @@ i LEFT(j,20)
109109
3 cccccccccccccccccccc
110110
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
111111
ERROR 42S01: Table 't2' already exists
112+
CREATE TABLE t3 ( i int , j blob) ENGINE = Innodb;
113+
ERROR HY000: InnoDB is in read only mode.
112114
UPDATE t1 SET i = i+1;
113115
ERROR HY000: Can't lock file (errno: 165 - Table is read only)
114116
FLUSH STATUS;

mysql-test/suite/innodb/t/innodb-wl6445-1.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ USE testdb_wl6445;
105105
--ERROR ER_CANT_LOCK
106106
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
107107
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
108-
--ERROR ER_OPEN_AS_READONLY
108+
--ERROR ER_INNODB_READ_ONLY
109109
CREATE TABLE t2 ( i int ,j blob) ENGINE = Innodb;
110110
--ERROR ER_CANT_LOCK
111111
UPDATE t1 SET i = i+1;
@@ -121,7 +121,7 @@ USE testdb_wl6445;
121121
--ERROR ER_CANT_LOCK
122122
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
123123
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
124-
--ERROR ER_OPEN_AS_READONLY
124+
--ERROR ER_INNODB_READ_ONLY
125125
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
126126
--ERROR ER_CANT_LOCK
127127
UPDATE t1 SET i = i+1;
@@ -144,7 +144,7 @@ USE testdb_wl6445;
144144
--ERROR ER_CANT_LOCK
145145
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
146146
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
147-
--ERROR ER_OPEN_AS_READONLY
147+
--ERROR ER_INNODB_READ_ONLY
148148
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
149149
--ERROR ER_CANT_LOCK
150150
UPDATE t1 SET i = i+1;
@@ -245,7 +245,7 @@ USE testdb_wl6445;
245245
--ERROR ER_CANT_LOCK
246246
INSERT INTO t1 VALUES (211,repeat('a',200)),(212,repeat('b',200)),(213,repeat('c',200));
247247
SELECT i,LEFT(j,20) FROM t1 WHERE i%10=0 ORDER BY i;
248-
--ERROR ER_OPEN_AS_READONLY
248+
--ERROR ER_INNODB_READ_ONLY
249249
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
250250
--ERROR ER_CANT_LOCK
251251
UPDATE t1 SET i = i+1;
@@ -457,7 +457,7 @@ CALL proc2(2,'test2');
457457
SELECT * FROM t3;
458458

459459
# try to CREATE temp table
460-
--ERROR ER_OPEN_AS_READONLY
460+
--ERROR ER_INNODB_READ_ONLY
461461
CREATE TEMPORARY TABLE temp_1 ( i INT ) ENGINE = Innodb;
462462

463463
# Try to insert with partitioned table
@@ -632,7 +632,7 @@ INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',2
632632
UPDATE t1 SET i = i + 20;
633633
--ERROR ER_CANT_LOCK
634634
DELETE FROM t1;
635-
--ERROR ER_OPEN_AS_READONLY
635+
--ERROR ER_INNODB_READ_ONLY
636636
CREATE TABLE t2 ( i INT ) ENGINE = Innodb;
637637
CREATE USER 'test5'@'localhost' IDENTIFIED BY '123';
638638
GRANT ALL ON testdb_wl6445.* TO 'test5'@'localhost';

mysql-test/suite/innodb/t/innodb-wl6445-2.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
8787
--ERROR ER_CANT_LOCK
8888
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
8989
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
90-
--ERROR ER_OPEN_AS_READONLY
90+
--ERROR ER_INNODB_READ_ONLY
9191
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
9292
--ERROR ER_CANT_LOCK
9393
UPDATE t1 SET i = i+1;
@@ -171,9 +171,10 @@ SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
171171
--ERROR ER_CANT_LOCK
172172
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
173173
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
174-
#--ERROR ER_OPEN_AS_READONLY
175174
--ERROR ER_TABLE_EXISTS_ERROR
176175
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
176+
--ERROR ER_INNODB_READ_ONLY
177+
CREATE TABLE t3 ( i int , j blob) ENGINE = Innodb;
177178
--ERROR ER_CANT_LOCK
178179
UPDATE t1 SET i = i+1;
179180

mysys/my_handler_errors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ static const char *handler_error_messages[]=
8989
"Table is being used in foreign key check",
9090
"Tablespace already exists",
9191
"Too many columns",
92-
"Row in wrong partition"
92+
"Row in wrong partition",
93+
"InnoDB is in read only mode"
9394
};
9495

9596
extern void my_handler_error_register(void);

sql/handler.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,6 +3696,9 @@ void handler::print_error(int error, myf errflag)
36963696
case HA_ERR_TOO_MANY_FIELDS:
36973697
textno= ER_TOO_MANY_FIELDS;
36983698
break;
3699+
case HA_ERR_INNODB_READ_ONLY:
3700+
textno= ER_INNODB_READ_ONLY;
3701+
break;
36993702
default:
37003703
{
37013704
/* The error was "unknown" to this function.

sql/log_event.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ static const char *HA_ERR(int i)
177177
case HA_ERR_LOGGING_IMPOSSIBLE: return "HA_ERR_LOGGING_IMPOSSIBLE";
178178
case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT";
179179
case HA_ERR_ROWS_EVENT_APPLY : return "HA_ERR_ROWS_EVENT_APPLY";
180+
case HA_ERR_INNODB_READ_ONLY: return "HA_ERR_INNODB_READ_ONLY";
180181
}
181182
return "No Error!";
182183
}

sql/share/errmsg-utf8.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7073,6 +7073,8 @@ ER_ACCESS_DENIED_CHANGE_USER_ERROR 28000
70737073
eng "Access denied trying to change to user '%-.48s'@'%-.64s' (using password: %s). Disconnecting."
70747074
bgn "Отказан достъп при опит за смяна към потребител %-.48s'@'%-.64s' (използвана парола: %s). Затваряне на връзката."
70757075

7076+
ER_INNODB_READ_ONLY
7077+
eng "InnoDB is in read only mode."
70767078

70777079
#
70787080
# End of 5.6 error messages.

0 commit comments

Comments
 (0)