-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a global my.cnf parameter, rocksdb_use_range_locking.
When it is ON, MyRocks will: - initialize RocksDB to use range-locking lock manager - for all DML operations (including SELECT .. FOR UPDATE) will lock the scanned range before reading/modifying rows. - In range locking mode, there is no snapshot checking (cannot do that for ranges). Instead, MyRocks will read and modify latest committed data, just like InnoDB does (in the code, grep for (start|end) _ignore_snapshot) - Queries that do not have a finite range to scan, like UPDATE t1 .... ORDER BY t1.key LIMIT n will use a "Locking iterator" which will read rows, lock the range, and re-read the rows. See class LockingIterator.
- Loading branch information
Showing
73 changed files
with
5,674 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (`select count(*) = 0 from performance_schema.session_variables where variable_name = 'rocksdb_use_range_locking' and variable_value = 'ON';`) { | ||
--skip Test requires range locking | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--let $_use_range_locking= `select @@rocksdb_use_range_locking` | ||
if ($_use_range_locking == 1) | ||
{ | ||
--skip Test doesn't support range locking | ||
} |
77 changes: 77 additions & 0 deletions
77
mysql-test/suite/rocksdb/include/select_from_is_rowlocks.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--echo # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc | ||
# | ||
# An include to print contents of I_S.ROCKSB_LOCKS | ||
# | ||
# Implicit "parameters" | ||
# - Currently it prints locks on t1.PRIMARY | ||
# | ||
# Explicit "parameter" variables: | ||
# - $TRX1_ID - print this transaction as "TRX1" | ||
# - $TRX2_ID - print this transaction as "TRX2" | ||
# | ||
# - $select_from_is_rowlocks_current_trx_only | ||
# - $order_by_rowkey | ||
|
||
--disable_query_log | ||
set @cf_id=(select column_family from information_schema.rocksdb_ddl | ||
where table_name='t1' and index_name='PRIMARY'); | ||
set @rtrx_id=(select transaction_id from information_schema.rocksdb_trx | ||
where thread_id=connection_id()); | ||
set @indexnr= (select lower( | ||
concat( | ||
lpad(hex(db_number),8,'0'), | ||
lpad(hex(index_number),8,'0') | ||
) | ||
) | ||
from information_schema.rocksdb_ddl | ||
where table_name='t1' and index_name='PRIMARY'); | ||
|
||
set @indexnr_next= (select lower( | ||
concat( | ||
lpad(hex(db_number),8,'0'), | ||
lpad(hex(index_number+1),8,'0') | ||
) | ||
) | ||
from information_schema.rocksdb_ddl | ||
where table_name='t1' and index_name='PRIMARY'); | ||
|
||
let $extra_where = where 1; | ||
|
||
if ($select_from_is_rowlocks_current_trx_only) | ||
{ | ||
let $extra_where = where transaction_id=(select transaction_id from information_schema.rocksdb_trx where connection_id()=thread_id); | ||
} | ||
|
||
# If TRX1_ID is not specified, get the current transaction: | ||
let $transaction_col= replace(transaction_id, @rtrx_id, "\$trx_id"); | ||
if ($TRX1_ID) | ||
{ | ||
let $transaction_col = replace(transaction_id, '$TRX1_ID', "\$TRX1_ID"); | ||
} | ||
|
||
if ($TRX2_ID) | ||
{ | ||
let $transaction_col = replace($transaction_col, '$TRX2_ID', "\$TRX2_ID"); | ||
} | ||
|
||
if ($order_by_rowkey) | ||
{ | ||
let $extra_order_by = ORDER BY 3,2; | ||
} | ||
|
||
if (!$order_by_rowkey) | ||
{ | ||
--sorted_result | ||
} | ||
|
||
eval select | ||
replace(column_family_id, @cf_id, "\$cf_id") as COLUMN_FAMILY_ID, | ||
$transaction_col as TRANSACTION_ID, | ||
replace( | ||
replace(`key`, @indexnr, '\${indexnr}'), | ||
@indexnr_next, '\${indexnr+1}' | ||
) as `KEY`, | ||
mode | ||
from information_schema.rocksdb_locks $extra_where $extra_order_by; | ||
|
||
--enable_query_log |
Oops, something went wrong.