Skip to content

Commit

Permalink
More MyRocks 8.0 test fixes - #4
Browse files Browse the repository at this point in the history
Summary:
1. INSERT/UPDATE will fail early in a rollback instead of failing at commit (see insert/update.test)
2. Add code (borrowed from innodb) to check for SKIP LOCKED / NOWAIT. Also update error message/error code for select_for_update_skip_locked_nowait
3. Update regex as SHOW ENGINE output is now slightly different in issue243_transactionStatus
4. Add proper cleanup in all_vars

Reviewed By: lloyd

Differential Revision: D17622868
  • Loading branch information
yizhang82 authored and inikep committed Jan 28, 2022
1 parent 47e5723 commit 07cb377
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 21 deletions.
1 change: 1 addition & 0 deletions mysql-test/suite/rocksdb/r/insert.result
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ INSERT t1 SET b = DEFAULT;
ROLLBACK TO SAVEPOINT spt1;
ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows.
INSERT INTO t1 (b,a) VALUES ('test1',10);
ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction.
COMMIT;
ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction.
SELECT a,b FROM t1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ select 1 for update skip locked;
select * from nonexistence for update skip locked;
ERROR 42S02: Table 'test.nonexistence' doesn't exist
select * from t1 for update skip locked;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR 42000: This version of MySQL doesn't yet support 'SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine'
select * from t1 where a > 1 and a < 3 for update skip locked;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR 42000: This version of MySQL doesn't yet support 'SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine'
insert into t1 select * from t1 for update skip locked;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR 42000: This version of MySQL doesn't yet support 'SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine'
Should succeed since no table gets involved
select 1 for update nowait;
1
1
select * from nonexistence for update nowait;
ERROR 42S02: Table 'test.nonexistence' doesn't exist
select * from t1 for update nowait;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR 42000: This version of MySQL doesn't yet support 'SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine'
select * from t1 where a > 1 and a < 3 for update nowait;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR 42000: This version of MySQL doesn't yet support 'SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine'
insert into t1 select * from t1 for update nowait;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR 42000: This version of MySQL doesn't yet support 'SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine'
drop table t1;
1 change: 1 addition & 0 deletions mysql-test/suite/rocksdb/r/update.result
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ UPDATE t1 SET b = '';
ROLLBACK TO SAVEPOINT spt1;
ERROR HY000: MyRocks currently does not support ROLLBACK TO SAVEPOINT if modifying rows.
UPDATE t1 SET b = 'upd' WHERE a = 10050;
ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction.
COMMIT;
ERROR HY000: This transaction was rolled back and cannot be committed. Only supported operation is to roll it back, so all pending changes will be discarded. Please restart another transaction.
SELECT * FROM t1 ORDER BY pk;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/rocksdb/t/insert.test
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ INSERT INTO t1 SET a = 11, b = 'f';
INSERT t1 SET b = DEFAULT;
--error ER_ROLLBACK_TO_SAVEPOINT
ROLLBACK TO SAVEPOINT spt1;
--error ER_ROLLBACK_ONLY
INSERT INTO t1 (b,a) VALUES ('test1',10);
--error ER_ROLLBACK_ONLY
COMMIT;
Expand Down
12 changes: 6 additions & 6 deletions mysql-test/suite/rocksdb/t/issue243_transactionStatus.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ INSERT INTO t1 VALUES(1,1,1),(2,1,2);
SELECT * FROM t1;
UPDATE t1 SET val1=2 WHERE id=2;
SELECT * FROM t1;
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /(thread handle) [0-9]+/\1 PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
SHOW ENGINE rocksdb TRANSACTION STATUS;

#
Expand All @@ -34,19 +34,19 @@ SELECT * FROM t1;
UPDATE t1 SET val1=20, val2=20 WHERE id=20;
SELECT * FROM t1;
DELETE FROM t1 WHERE id=30;
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /(thread handle) [0-9]+/\1 PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
SHOW ENGINE rocksdb TRANSACTION STATUS;

ROLLBACK;
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /(thread handle) [0-9]+/\1 PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
SHOW ENGINE rocksdb TRANSACTION STATUS;

START TRANSACTION;
INSERT INTO t1 VALUES(40,40,40);
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /(thread handle) [0-9]+/\1 PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
SHOW ENGINE rocksdb TRANSACTION STATUS;
COMMIT;
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /(thread handle) [0-9]+/\1 PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
SHOW ENGINE rocksdb TRANSACTION STATUS;

SET AUTOCOMMIT=1;
Expand All @@ -73,7 +73,7 @@ INSERT INTO t2 VALUES(1,2,0),(10,20,30);
UPDATE t2 SET value=3 WHERE id2=2;
DELETE FROM t2 WHERE id1=10;

--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /0x[0-9a-f]+/PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/TIMESTAMP/ /(ACTIVE) [0-9]+ /\1 NUM / /(thread id) [0-9]+/\1 TID/ /(thread handle) [0-9]+/\1 PTR/ /(query id) [0-9]+/\1 QID/ /(root) [a-z ]+/\1 ACTION/
SHOW ENGINE rocksdb TRANSACTION STATUS;
ROLLBACK;
SET AUTOCOMMIT=1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ select 1 for update skip locked;
--error ER_NO_SUCH_TABLE
select * from nonexistence for update skip locked;

--error ER_ILLEGAL_HA
--error ER_NOT_SUPPORTED_YET
select * from t1 for update skip locked;

--error ER_ILLEGAL_HA
--error ER_NOT_SUPPORTED_YET
select * from t1 where a > 1 and a < 3 for update skip locked;

--error ER_ILLEGAL_HA
--error ER_NOT_SUPPORTED_YET
insert into t1 select * from t1 for update skip locked;

### NOWAIT
Expand All @@ -36,13 +36,13 @@ select 1 for update nowait;
--error ER_NO_SUCH_TABLE
select * from nonexistence for update nowait;

--error ER_ILLEGAL_HA
--error ER_NOT_SUPPORTED_YET
select * from t1 for update nowait;

--error ER_ILLEGAL_HA
--error ER_NOT_SUPPORTED_YET
select * from t1 where a > 1 and a < 3 for update nowait;

--error ER_ILLEGAL_HA
--error ER_NOT_SUPPORTED_YET
insert into t1 select * from t1 for update nowait;

drop table t1;
1 change: 1 addition & 0 deletions mysql-test/suite/rocksdb/t/update.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ SAVEPOINT spt1;
UPDATE t1 SET b = '';
--error ER_ROLLBACK_TO_SAVEPOINT
ROLLBACK TO SAVEPOINT spt1;
--error ER_ROLLBACK_ONLY
UPDATE t1 SET b = 'upd' WHERE a = 10050;
--error ER_ROLLBACK_ONLY
COMMIT;
Expand Down
9 changes: 6 additions & 3 deletions mysql-test/suite/rocksdb_sys_vars/t/all_vars.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
--source include/have_rocksdb.inc
--source include/not_embedded.inc
--source include/not_threadpool.inc

# This test verifies that *all* MyRocks system variables are tested by the
Expand All @@ -25,8 +24,8 @@ create table t2 (variable_name text) engine=MyISAM;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data infile "$MYSQLTEST_VARDIR/tmp/rocksdb_sys_vars.all_vars.txt" into table t1;

insert into t2 select variable_name from information_schema.global_variables where variable_name like "rocksdb_%";
insert into t2 select variable_name from information_schema.session_variables where variable_name like "rocksdb_%";
insert into t2 select variable_name from performance_schema.global_variables where variable_name like "rocksdb_%";
insert into t2 select variable_name from performance_schema.session_variables where variable_name like "rocksdb_%";

--sorted_result
select variable_name as `There should be *no* long test name listed below:` from t2
Expand All @@ -38,3 +37,7 @@ select variable_name as `There should be *no* variables listed below:` from t2

drop table t1;
drop table t2;

# Cleanup
--remove_file $MYSQLTEST_VARDIR/tmp/rocksdb_sys_vars.all_vars.txt

8 changes: 8 additions & 0 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11078,6 +11078,14 @@ THR_LOCK_DATA **ha_rocksdb::store_lock(THD *const thd, THR_LOCK_DATA **to,
m_db_lock.type = lock_type;
}

if (lock_type != TL_IGNORE) {
auto action = table->pos_in_table_list->lock_descriptor().action;
if (action != THR_DEFAULT && action != THR_WAIT) {
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
"SKIP LOCKED | NOWAIT is not yet supported in RocksDB storage engine");
}
}

*to++ = &m_db_lock;

DBUG_RETURN(to);
Expand Down

0 comments on commit 07cb377

Please sign in to comment.