Skip to content

Commit d752a97

Browse files
committed
Merge 10.1 to 10.2
2 parents 19ceaf2 + a41d429 commit d752a97

File tree

16 files changed

+342
-271
lines changed

16 files changed

+342
-271
lines changed

mysql-test/suite/innodb_fts/r/crash_recovery.result

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ INSERT INTO articles (title,body) VALUES
4141
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
4242
('MySQL vs. YourSQL','In the following database comparison ...'),
4343
('MySQL Security','When configured properly, MySQL ...');
44+
connect dml, localhost, root,,;
4445
BEGIN;
4546
INSERT INTO articles (title,body) VALUES
4647
('MySQL Tutorial','DBMS stands for DataBase ...');
48+
connection default;
4749
# Make durable the AUTO_INCREMENT in the above incomplete transaction.
4850
connect flush_redo_log,localhost,root,,;
4951
SET GLOBAL innodb_flush_log_at_trx_commit=1;
@@ -52,6 +54,7 @@ DELETE FROM articles LIMIT 1;
5254
ROLLBACK;
5355
disconnect flush_redo_log;
5456
connection default;
57+
disconnect dml;
5558
INSERT INTO articles (title,body) VALUES
5659
('MySQL Tutorial','DBMS stands for DataBase ...');
5760
SELECT * FROM articles
@@ -79,9 +82,39 @@ INSERT INTO articles VALUES
7982
(4, 11, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
8083
(5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'),
8184
(7, 4, 'MySQL Security','When configured properly, MySQL ...');
85+
connect dml, localhost, root,,;
8286
BEGIN;
8387
INSERT INTO articles VALUES
8488
(100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...');
89+
connect dml2, localhost, root,,;
90+
#
91+
# MDEV-19073 FTS row mismatch after crash recovery
92+
#
93+
CREATE TABLE mdev19073(id SERIAL, title VARCHAR(200), body TEXT,
94+
FULLTEXT(title,body)) ENGINE=InnoDB;
95+
INSERT INTO mdev19073 (title, body) VALUES
96+
('MySQL Tutorial', 'DBMS stands for Database...');
97+
CREATE FULLTEXT INDEX idx ON mdev19073(title, body);
98+
CREATE TABLE mdev19073_2 LIKE mdev19073;
99+
INSERT INTO mdev19073_2 (title, body) VALUES
100+
('MySQL Tutorial', 'DBMS stands for Database...');
101+
INSERT INTO mdev19073 (title, body) VALUES
102+
('MariaDB Tutorial', 'DB means Database ...');
103+
INSERT INTO mdev19073_2 (title, body) VALUES
104+
('MariaDB Tutorial', 'DB means Database ...');
105+
SELECT * FROM mdev19073 WHERE MATCH (title, body)
106+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
107+
id title body
108+
1 MySQL Tutorial DBMS stands for Database...
109+
2 MariaDB Tutorial DB means Database ...
110+
SELECT * FROM mdev19073_2 WHERE MATCH (title, body)
111+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
112+
id title body
113+
1 MySQL Tutorial DBMS stands for Database...
114+
2 MariaDB Tutorial DB means Database ...
115+
connection default;
116+
disconnect dml;
117+
disconnect dml2;
85118
INSERT INTO articles VALUES (8, 12, 'MySQL Tutorial','DBMS stands for DataBase ...');
86119
SELECT * FROM articles WHERE MATCH (title, body)
87120
AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE);
@@ -90,3 +123,14 @@ id FTS_DOC_ID title body
90123
1 10 MySQL Tutorial DBMS stands for DataBase ...
91124
8 12 MySQL Tutorial DBMS stands for DataBase ...
92125
DROP TABLE articles;
126+
SELECT * FROM mdev19073 WHERE MATCH (title, body)
127+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
128+
id title body
129+
1 MySQL Tutorial DBMS stands for Database...
130+
2 MariaDB Tutorial DB means Database ...
131+
SELECT * FROM mdev19073_2 WHERE MATCH (title, body)
132+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
133+
id title body
134+
1 MySQL Tutorial DBMS stands for Database...
135+
2 MariaDB Tutorial DB means Database ...
136+
DROP TABLE mdev19073, mdev19073_2;

mysql-test/suite/innodb_fts/t/crash_recovery.test

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
--source include/have_innodb.inc
77
# The embedded server tests do not support restarting.
88
--source include/not_embedded.inc
9+
--source include/maybe_debug.inc
910

1011
FLUSH TABLES;
1112
# Following are test for crash recovery on FTS index, the first scenario
@@ -73,10 +74,12 @@ INSERT INTO articles (title,body) VALUES
7374
('MySQL vs. YourSQL','In the following database comparison ...'),
7475
('MySQL Security','When configured properly, MySQL ...');
7576

77+
connect(dml, localhost, root,,);
7678
BEGIN;
7779

7880
INSERT INTO articles (title,body) VALUES
7981
('MySQL Tutorial','DBMS stands for DataBase ...');
82+
connection default;
8083

8184
--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction.
8285
--connect (flush_redo_log,localhost,root,,)
@@ -89,6 +92,8 @@ ROLLBACK;
8992

9093
--source include/restart_mysqld.inc
9194

95+
disconnect dml;
96+
9297
# This insert will re-initialize the Doc ID counter, it should not crash
9398
INSERT INTO articles (title,body) VALUES
9499
('MySQL Tutorial','DBMS stands for DataBase ...');
@@ -121,14 +126,57 @@ INSERT INTO articles VALUES
121126
(5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'),
122127
(7, 4, 'MySQL Security','When configured properly, MySQL ...');
123128

129+
connect(dml, localhost, root,,);
124130
BEGIN;
125131

126132
# Below we do not depend on the durability of the AUTO_INCREMENT sequence,
127133
# so we can skip the above flush_redo_log trick.
128134
INSERT INTO articles VALUES
129135
(100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...');
130136

137+
connect(dml2, localhost, root,,);
138+
139+
--echo #
140+
--echo # MDEV-19073 FTS row mismatch after crash recovery
141+
--echo #
142+
143+
CREATE TABLE mdev19073(id SERIAL, title VARCHAR(200), body TEXT,
144+
FULLTEXT(title,body)) ENGINE=InnoDB;
145+
INSERT INTO mdev19073 (title, body) VALUES
146+
('MySQL Tutorial', 'DBMS stands for Database...');
147+
CREATE FULLTEXT INDEX idx ON mdev19073(title, body);
148+
CREATE TABLE mdev19073_2 LIKE mdev19073;
149+
if ($have_debug)
150+
{
151+
--disable_query_log
152+
SET @saved_dbug = @@debug_dbug;
153+
SET DEBUG_DBUG = '+d,fts_instrument_sync_debug';
154+
--enable_query_log
155+
}
156+
INSERT INTO mdev19073_2 (title, body) VALUES
157+
('MySQL Tutorial', 'DBMS stands for Database...');
158+
if ($have_debug)
159+
{
160+
--disable_query_log
161+
SET DEBUG_DBUG = @saved_dbug;
162+
--enable_query_log
163+
}
164+
165+
INSERT INTO mdev19073 (title, body) VALUES
166+
('MariaDB Tutorial', 'DB means Database ...');
167+
INSERT INTO mdev19073_2 (title, body) VALUES
168+
('MariaDB Tutorial', 'DB means Database ...');
169+
170+
# Should return 2 rows
171+
SELECT * FROM mdev19073 WHERE MATCH (title, body)
172+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
173+
SELECT * FROM mdev19073_2 WHERE MATCH (title, body)
174+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
175+
176+
connection default;
131177
--source include/restart_mysqld.inc
178+
disconnect dml;
179+
disconnect dml2;
132180

133181
# This would re-initialize the FTS index and do the re-tokenization
134182
# of above records
@@ -138,3 +186,10 @@ SELECT * FROM articles WHERE MATCH (title, body)
138186
AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE);
139187

140188
DROP TABLE articles;
189+
190+
# Should return 2 rows
191+
SELECT * FROM mdev19073 WHERE MATCH (title, body)
192+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
193+
SELECT * FROM mdev19073_2 WHERE MATCH (title, body)
194+
AGAINST ('Database' IN NATURAL LANGUAGE MODE);
195+
DROP TABLE mdev19073, mdev19073_2;

storage/innobase/dict/dict0load.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ Created 4/24/1996 Heikki Tuuri
4343
#include "rem0cmp.h"
4444
#include "srv0start.h"
4545
#include "srv0srv.h"
46-
#include <stack>
47-
#include <set>
46+
#include "fts0opt.h"
4847

4948
/** Following are the InnoDB system tables. The positions in
5049
this array are referenced by enum dict_system_table_id. */
@@ -3121,8 +3120,12 @@ dict_load_table_one(
31213120
FTS */
31223121
fts_optimize_remove_table(table);
31233122
fts_free(table);
3124-
} else {
3123+
} else if (fts_optimize_wq) {
31253124
fts_optimize_add_table(table);
3125+
} else {
3126+
/* fts_optimize_thread is not started yet.
3127+
So make the table as non-evictable from cache. */
3128+
dict_table_move_from_lru_to_non_lru(table);
31263129
}
31273130
}
31283131

storage/innobase/fts/fts0fts.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,10 @@ fts_cmp_set_sync_doc_id(
27122712
}
27132713

27142714
if (read_only) {
2715+
/* InnoDB stores actual synced_doc_id value + 1 in
2716+
FTS_CONFIG table. Reduce the value by 1 while reading
2717+
after startup. */
2718+
if (*doc_id) *doc_id -= 1;
27152719
goto func_exit;
27162720
}
27172721

@@ -5388,11 +5392,11 @@ fts_t::fts_t(
53885392
const dict_table_t* table,
53895393
mem_heap_t* heap)
53905394
:
5391-
in_queue(0), added_synced(0), dict_locked(0),
5395+
added_synced(0), dict_locked(0),
53925396
bg_threads(0),
53935397
add_wq(NULL),
53945398
cache(NULL),
5395-
doc_col(ULINT_UNDEFINED),
5399+
doc_col(ULINT_UNDEFINED), in_queue(false),
53965400
fts_heap(heap)
53975401
{
53985402
ut_a(table->fts == NULL);

0 commit comments

Comments
 (0)