File: innodb_fts_misc_debug.test

package info (click to toggle)
mariadb-10.0 10.0.32-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 476,064 kB
  • sloc: cpp: 1,400,131; ansic: 832,140; perl: 54,391; sh: 41,304; pascal: 32,365; yacc: 14,921; xml: 5,257; sql: 4,667; cs: 4,647; makefile: 4,555; ruby: 4,465; python: 2,292; lex: 1,427; java: 941; asm: 295; awk: 54; php: 22; sed: 16
file content (209 lines) | stat: -rw-r--r-- 6,995 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#------------------------------------------------------------------------------
# Misc FTS test on debug servers only
#------------------------------------------------------------------------------
--source include/have_innodb.inc

# Must have debug code to use SET SESSION debug
--source include/have_debug.inc

# Valgrind would complain about memory leaks when we crash on purpose.
--source include/not_valgrind.inc

# Embedded server does not support crashing
--source include/not_embedded.inc

# Avoid CrashReporter popup on Mac
--source include/not_crashrep.inc

# Following are test for crash recovery on FTS index, the first scenario
# is for bug Bug #14586855 INNODB: FAILING ASSERTION: (DICT_INDEX_GET_N_UNIQUE(
# PLAN->INDEX) <= PLAN->N_EXAC

# Scenario 1: Hidden FTS_DOC_ID column, and FTS index dropped
# Create FTS table
CREATE TABLE articles (
        id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
        title VARCHAR(200),
        body TEXT,
        FULLTEXT (title,body)
        ) ENGINE=InnoDB;

# Drop the FTS index before more insertion. The FTS_DOC_ID should
# be kept
DROP INDEX title ON articles;

# Insert six rows
INSERT INTO articles (title,body) VALUES
        ('MySQL Tutorial','DBMS stands for DataBase ...')  ,
        ('How To Use MySQL Well','After you went through a ...'),
        ('Optimizing MySQL','In this tutorial we will show ...'),
        ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
        ('MySQL vs. YourSQL','In the following database comparison ...'),
        ('MySQL Security','When configured properly, MySQL ...');

BEGIN;

INSERT INTO articles (title,body) VALUES
        ('MySQL Tutorial','DBMS stands for DataBase ...');

# Request a crash on next execution of commit.
SET SESSION debug_dbug="+d,crash_commit_before";
#
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
#
# Execute the statement that causes the crash.
--error 2013
COMMIT;

--source include/wait_until_disconnected.inc
--sleep 2

# Turn on reconnect
--enable_reconnect
#
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc
#
# Turn off reconnect again
--disable_reconnect

# This insert will re-initialize the Doc ID counter, it should not crash
INSERT INTO articles (title,body) VALUES
        ('MySQL Tutorial','DBMS stands for DataBase ...');

# Recreate fulltext index to see if everything is OK
CREATE FULLTEXT INDEX idx ON articles (title,body);

# Should return 3 rows
SELECT * FROM articles
        WHERE MATCH (title,body)
        AGAINST ('Database' IN NATURAL LANGUAGE MODE);

# Scenario 2: Hidden FTS_DOC_ID column, with FTS index
# Now let's do more insertion and test a crash with FTS on
INSERT INTO articles (title,body) VALUES
        ('MySQL Tutorial','DBMS stands for DataBase ...')  ,
        ('How To Use MySQL Well','After you went through a ...'),
        ('Optimizing MySQL','In this tutorial we will show ...'),
        ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
        ('MySQL vs. YourSQL','In the following database comparison ...'),
        ('MySQL Security','When configured properly, MySQL ...');

# Now let's crash the server with "crash_commit_before"
BEGIN;

INSERT INTO articles (title,body) VALUES
        ('MySQL Tutorial','DBMS stands for DataBase ...');

# Request a crash on next execution of commit.
SET SESSION debug_dbug="+d,crash_commit_before";
#
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
#
# Execute the statement that causes the crash.
--error 2013
COMMIT;

--source include/wait_until_disconnected.inc
--sleep 2

# Turn on reconnect
--enable_reconnect
#
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc
#
# Turn off reconnect again
--disable_reconnect

# This insert will re-initialize the Doc ID counter, it should not crash
INSERT INTO articles (title,body) VALUES
        ('MySQL Tutorial','DBMS stands for DataBase ...');

# Should return 6 rows
SELECT * FROM articles
        WHERE MATCH (title,body)
        AGAINST ('Database' IN NATURAL LANGUAGE MODE);

DROP TABLE articles;

# Scenario 3: explicit FTS_DOC_ID column with FTS index 
# Now let's test user defined FTS_DOC_ID

CREATE TABLE articles (
	id int PRIMARY KEY,
        FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
        title VARCHAR(200),
        body TEXT
        ) ENGINE=InnoDB;

CREATE FULLTEXT INDEX idx1 on articles (title, body);

# Note the FTS_DOC_ID is not fully ordered with primary index
INSERT INTO articles VALUES
        (1, 10, 'MySQL Tutorial','DBMS stands for DataBase ...')  ,
        (2, 1, 'How To Use MySQL Well','After you went through a ...'),
        (3, 2, 'Optimizing MySQL','In this tutorial we will show ...'),
        (4, 11, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
        (5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'),
        (7, 4, 'MySQL Security','When configured properly, MySQL ...');

# Now let's crash the server with "crash_commit_before"
BEGIN;

INSERT INTO articles VALUES
        (100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...');

# Request a crash on next execution of commit.
SET SESSION debug_dbug="+d,crash_commit_before";
#
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
#
# Execute the statement that causes the crash.
--error 2013
COMMIT;

--source include/wait_until_disconnected.inc
--sleep 2

# Turn on reconnect
--enable_reconnect
#
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc
#

# This would re-initialize the FTS index and do the re-tokenization
# of above records
INSERT INTO articles VALUES         (8, 12, 'MySQL Tutorial','DBMS stands for DataBase ...');

SELECT * FROM articles WHERE MATCH (title, body)
        AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE);

DROP TABLE articles;

# Following test is for Bug 14668777 - ASSERT ON IB_VECTOR_SIZE(
# TABLE->FTS->INDEXES, ALTER TABLE
CREATE TABLE articles (
        id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
        title VARCHAR(200),
        body TEXT,
        FULLTEXT (title,body)
        ) ENGINE=InnoDB;

# Abort the operation in dict_create_index_step by setting
# return status of dict_create_index_tree_step() to DB_OUT_OF_MEMORY
# The newly create dict_index_t should be removed from fts cache
SET SESSION debug_dbug="+d,ib_dict_create_index_tree_fail";
--error ER_OUT_OF_RESOURCES
CREATE FULLTEXT INDEX idx ON articles(body);
SET SESSION debug_dbug="-d,ib_dict_create_index_tree_fail";

# This simply go through ha_innobase::commit_inplace_alter_table
# and do a fts_check_cached_index()
ALTER TABLE articles STATS_PERSISTENT=DEFAULT;

DROP TABLE articles;