Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mysql-test/suite/maria/fulltext_parser-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--aria-checkpoint-interval=0
--aria-recover-options=OFF
150 changes: 150 additions & 0 deletions mysql-test/suite/maria/fulltext_parser.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
INSTALL PLUGIN simple_parser SONAME 'mypluglib';
# Fulltext parser with ROW_FORMAT=PAGE
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
RENAME TABLE t1 TO t2;
SELECT a FROM t2 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t2;
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
ALTER TABLE t1 ADD COLUMN b INT, ALGORITHM=COPY;
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
CREATE TABLE t1 (a TEXT)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
ALTER TABLE t1 ADD FULLTEXT(a) WITH PARSER simple_parser, ALGORITHM=COPY;
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
# Fulltext parser with ROW_FORMAT=DYNAMIC
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=DYNAMIC TRANSACTIONAL=0;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
RENAME TABLE t1 TO t2;
SELECT a FROM t2 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t2;
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=DYNAMIC TRANSACTIONAL=0;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
ALTER TABLE t1 ADD COLUMN b INT, ALGORITHM=COPY;
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=DYNAMIC TRANSACTIONAL=0;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser) ENGINE=Aria ROW_FORMAT=DYNAMIC TRANSACTIONAL=0;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
CREATE TABLE t1 (a TEXT)
ENGINE=Aria ROW_FORMAT=DYNAMIC TRANSACTIONAL=0;
INSERT INTO t1 VALUES ('abc-def'), ('abcd-efgh'), ('other text');
ALTER TABLE t1 ADD FULLTEXT(a) WITH PARSER simple_parser, ALGORITHM=COPY;
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
DROP TABLE t1;
# Recover committed rows written after the last checkpoint
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('baseline-two'), ('baseline-three');
CREATE TABLE t_flush (a INT) ENGINE=Aria TRANSACTIONAL=1;
INSERT INTO t_flush VALUES (0);
# restart
INSERT INTO t1 VALUES ('commit-one'), ('commit-two');
# restart
SELECT a FROM t1 ORDER BY a;
a
abc-def
baseline-three
baseline-two
commit-one
commit-two
SELECT a FROM t1 WHERE MATCH(a) AGAINST('commit-one commit-two') ORDER BY a;
a
commit-one
commit-two
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
# Roll back row and fulltext key changes without loading the parser
connect writer,localhost,root,,test;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('undo-insert');
UPDATE t1 SET a = 'undo-update' WHERE a = 'abc-def';
DELETE FROM t1 WHERE a = 'baseline-two';
connection default;
INSERT INTO t_flush VALUES (1);
# restart
disconnect writer;
include/assert_grep.inc [Recovery rolled back the writer transaction]
include/assert_grep.inc [Recovery did not skip UNDO records]
SELECT a FROM t1 ORDER BY a;
a
abc-def
baseline-three
baseline-two
commit-one
commit-two
SELECT a FROM t1
WHERE MATCH(a) AGAINST('abc-def baseline-two undo-insert undo-update')
ORDER BY a;
a
abc-def
baseline-two
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
# Recover a completed bulk-insert repair with a parser plugin
CREATE TABLE t_src (a TEXT) ENGINE=Aria;
INSERT INTO t_src VALUES ('abc-def'), ('abcd-efgh'), ('other text');
CREATE TABLE t2 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t2 SELECT a FROM t_src;
# restart
SELECT a FROM t2 WHERE MATCH(a) AGAINST('abc-def abcd');
a
abc-def
CHECK TABLE t2 EXTENDED;
Table Op Msg_type Msg_text
test.t2 check status OK
DROP TABLE t2, t_src;
DROP TABLE t1, t_flush;
UNINSTALL PLUGIN simple_parser;
87 changes: 87 additions & 0 deletions mysql-test/suite/maria/fulltext_parser.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
--source include/have_maria.inc
--source include/have_simple_parser.inc
--source include/not_embedded.inc

INSTALL PLUGIN simple_parser SONAME 'mypluglib';

# simple_parser keeps punctuation in words: 'abc-def abcd' finds
# 'abc-def', but not the fragment 'abcd' of 'abcd-efgh'.
--let $row_format= PAGE
--let $transactional= 1
--source suite/maria/include/fulltext_parser_ops.inc
--let $row_format= DYNAMIC
--let $transactional= 0
--source suite/maria/include/fulltext_parser_ops.inc

--echo # Recover committed rows written after the last checkpoint
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES ('abc-def'), ('baseline-two'), ('baseline-three');
CREATE TABLE t_flush (a INT) ENGINE=Aria TRANSACTIONAL=1;
INSERT INTO t_flush VALUES (0);

# A clean restart establishes the on-disk baseline. The .opt file disables
# periodic checkpoints and automatic repair, so they cannot hide failures.
--source include/restart_mysqld.inc
INSERT INTO t1 VALUES ('commit-one'), ('commit-two');
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc

# Check the recovered data and index before CHECK TABLE or REPAIR can help.
SELECT a FROM t1 ORDER BY a;
SELECT a FROM t1 WHERE MATCH(a) AGAINST('commit-one commit-two') ORDER BY a;
CHECK TABLE t1 EXTENDED;

--echo # Roll back row and fulltext key changes without loading the parser
# Aria defers its commit until UNLOCK TABLES, unlike ordinary statements.
--connect (writer,localhost,root,,test)
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('undo-insert');
UPDATE t1 SET a = 'undo-update' WHERE a = 'abc-def';
DELETE FROM t1 WHERE a = 'baseline-two';

--connection default
# Committing another Aria table flushes the preceding UNDO and REDO records
# without committing the writer or flushing t1's dirty pages.
INSERT INTO t_flush VALUES (1);
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
--disconnect writer

# The row checks alone could pass if recovery skipped t1 and its changes
# never reached disk. Require a completed rollback with no skipped UNDO
# records from this restart; the writer is the only uncommitted transaction.
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let $assert_only_after= Starting MariaDB
--let $assert_text= Recovery rolled back the writer transaction
--let $assert_select= transactions to roll back: 1 0
--let $assert_count= 1
--source include/assert_grep.inc
--let $assert_text= Recovery did not skip UNDO records
--let $assert_select= UNDO records skipped in UNDO phase
--let $assert_count= 0
--source include/assert_grep.inc

SELECT a FROM t1 ORDER BY a;
SELECT a FROM t1
WHERE MATCH(a) AGAINST('abc-def baseline-two undo-insert undo-update')
ORDER BY a;
CHECK TABLE t1 EXTENDED;

--echo # Recover a completed bulk-insert repair with a parser plugin
# INSERT ... SELECT into an empty table disables the keys and rebuilds them
# with a repair. Its state LSNs normally make recovery skip REDO_REPAIR_TABLE.
# fulltext_parser_debug covers a repair record newer than the saved state LSNs.
CREATE TABLE t_src (a TEXT) ENGINE=Aria;
INSERT INTO t_src VALUES ('abc-def'), ('abcd-efgh'), ('other text');
CREATE TABLE t2 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t2 SELECT a FROM t_src;
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
SELECT a FROM t2 WHERE MATCH(a) AGAINST('abc-def abcd');
CHECK TABLE t2 EXTENDED;
DROP TABLE t2, t_src;

DROP TABLE t1, t_flush;
UNINSTALL PLUGIN simple_parser;
2 changes: 2 additions & 0 deletions mysql-test/suite/maria/fulltext_parser_debug-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--aria-checkpoint-interval=0
--aria-recover-options=OFF
64 changes: 64 additions & 0 deletions mysql-test/suite/maria/fulltext_parser_debug.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
INSTALL PLUGIN simple_parser SONAME 'mypluglib';
# Keep the durable repair result without replaying it
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES
('abc-def'), ('abcd-efgh'), ('plain words'), ('other text'), ('more rows');
FLUSH TABLES t1;
SET SESSION debug_dbug='+d,maria_crash_after_repair_log';
REPAIR TABLE t1;
# restart
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd') ORDER BY a;
a
abc-def
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
# Recover changes committed after a bulk-insert repair record
CREATE TABLE t_src (a TEXT) ENGINE=Aria;
INSERT INTO t_src VALUES
('abcd-efgh'), ('keep-one'), ('keep-two'),
('update-before'), ('delete-before');
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
CREATE TABLE t_flush (a INT) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t_flush VALUES (0);
# restart
connect bulk,localhost,root,,test;
SET DEBUG_SYNC=
'maria_before_repair_log SIGNAL repair_ready WAIT_FOR log_advanced';
INSERT INTO t1 SELECT a FROM t_src;
connection default;
SET DEBUG_SYNC= 'now WAIT_FOR repair_ready';
INSERT INTO t_flush VALUES (1);
SET DEBUG_SYNC= 'now SIGNAL log_advanced';
connection bulk;
SET DEBUG_SYNC= 'RESET';
INSERT INTO t1 VALUES ('commit-one'), ('commit-two');
UPDATE t1 SET a= 'update-after' WHERE a= 'update-before';
DELETE FROM t1 WHERE a= 'delete-before';
connection default;
INSERT INTO t_flush VALUES (2);
# restart
disconnect bulk;
SELECT a FROM t1 ORDER BY a;
a
abcd-efgh
commit-one
commit-two
keep-one
keep-two
update-after
SELECT a FROM t1
WHERE MATCH(a) AGAINST('abcd-efgh commit-one update-after update-before')
ORDER BY a;
a
abcd-efgh
commit-one
update-after
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1, t_src, t_flush;
UNINSTALL PLUGIN simple_parser;
82 changes: 82 additions & 0 deletions mysql-test/suite/maria/fulltext_parser_debug.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
--source include/have_maria.inc
--source include/have_simple_parser.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc
--source include/not_valgrind.inc
--source include/not_crashrep.inc

INSTALL PLUGIN simple_parser SONAME 'mypluglib';

--echo # Keep the durable repair result without replaying it
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t1 VALUES
('abc-def'), ('abcd-efgh'), ('plain words'), ('other text'), ('more rows');

# Closing the share makes repair log a new FILE_ID before REDO_REPAIR_TABLE.
# The repair record is then strictly newer than protect_against_repair_crash's
# skip_redo_lsn, even without concurrent writes to the log.
FLUSH TABLES t1;
SET SESSION debug_dbug='+d,maria_crash_after_repair_log';
--source include/expect_crash.inc
--disable_result_log
# send/reap, so that --sp-protocol does not wrap the crashing statement
--send REPAIR TABLE t1
--error 2013,2026
--reap
--enable_result_log
--source include/start_mysqld.inc

# The table must be usable immediately, with the plugin's index intact.
SELECT a FROM t1 WHERE MATCH(a) AGAINST('abc-def abcd') ORDER BY a;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;

--echo # Recover changes committed after a bulk-insert repair record
CREATE TABLE t_src (a TEXT) ENGINE=Aria;
INSERT INTO t_src VALUES
('abcd-efgh'), ('keep-one'), ('keep-two'),
('update-before'), ('delete-before');
CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser)
ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
CREATE TABLE t_flush (a INT) ENGINE=Aria ROW_FORMAT=PAGE TRANSACTIONAL=1;
INSERT INTO t_flush VALUES (0);

# Establish an empty on-disk t1 before the bulk insert.
--source include/restart_mysqld.inc
--connect (bulk,localhost,root,,test)
SET DEBUG_SYNC=
'maria_before_repair_log SIGNAL repair_ready WAIT_FOR log_advanced';
--send INSERT INTO t1 SELECT a FROM t_src

--connection default
SET DEBUG_SYNC= 'now WAIT_FOR repair_ready';
# The quick, keys-only repair has written t1's state. Advance the log before
# its repair record, making that record strictly newer than is_of_horizon.
# T_NO_CREATE_RENAME_LSN prevents the repair from updating the LSNs later.
INSERT INTO t_flush VALUES (1);
SET DEBUG_SYNC= 'now SIGNAL log_advanced';

--connection bulk
--reap
SET DEBUG_SYNC= 'RESET';
# Each statement commits. Keep the table open and its changed pages cached:
# the .opt file disables checkpoints, and we do not flush or check t1.
INSERT INTO t1 VALUES ('commit-one'), ('commit-two');
UPDATE t1 SET a= 'update-after' WHERE a= 'update-before';
DELETE FROM t1 WHERE a= 'delete-before';

--connection default
INSERT INTO t_flush VALUES (2);
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
--disconnect bulk

SELECT a FROM t1 ORDER BY a;
SELECT a FROM t1
WHERE MATCH(a) AGAINST('abcd-efgh commit-one update-after update-before')
ORDER BY a;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1, t_src, t_flush;
UNINSTALL PLUGIN simple_parser;
Loading