[Commits] 0ea68f0: Issue #22: SELECT ... FOR UPDATE takes a long time

Sergei Petrunia psergey at askmonty.org
Thu Nov 6 17:16:22 EET 2014


revision-id: 0ea68f0a355c6197475f7bd5e0c8cbf1a04b84de
parent(s): 1cf078f1dd148e8e31e1129e8571327c36d19b1e
committer: Sergei Petrunia
branch nick: webscalesql-5.6
timestamp: 2014-11-06 18:16:22 +0300
message:

Issue #22: SELECT ... FOR UPDATE takes a long time
- Specify the right column family when making a rocksdb::Get() call.

---
 mysql-test/r/rocksdb.result   |   31 +++++++++++++++++++++++++++++++
 mysql-test/t/rocksdb.test     |   34 ++++++++++++++++++++++++++++++++++
 storage/rocksdb/ha_rocksdb.cc |    6 ++++--
 3 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/mysql-test/r/rocksdb.result b/mysql-test/r/rocksdb.result
index e2d6feb..b706e06 100644
--- a/mysql-test/r/rocksdb.result
+++ b/mysql-test/r/rocksdb.result
@@ -1440,3 +1440,34 @@ PRIMARY KEY (id),
 index (key1) comment '$per_idnex_cf'
 )engine=rocksdb;
 ERROR 42000: This version of MySQL doesn't yet support 'column family name looks like a typo of $per_index_cf'
+#
+# Issue #22: SELECT ... FOR UPDATE takes a long time
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+id1 int,
+id2 int,
+value1 int,
+value2 int,
+primary key(id1, id2) COMMENT 'new_column_family',
+key(id2)
+) engine=rocksdb default charset=latin1 collate=latin1_bin;
+insert into t1 select A.a, B.a, 31, 1234 from t0 A, t0 B;
+explain 
+select * from t1 where id1=30 and value1=30 for update;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	PRIMARY	PRIMARY	4	const	10	Using where
+set @var1=(select variable_value 
+from information_schema.global_status 
+where variable_name='rocksdb_number_keys_read');
+select * from t1 where id1=3 and value1=3 for update;
+id1	id2	value1	value2
+set @var2=(select variable_value 
+from information_schema.global_status 
+where variable_name='rocksdb_number_keys_read');
+# The following must return true (before the fix, the difference was 70):
+select (@var2 - @var1) < 12;
+(@var2 - @var1) < 12
+1
+drop table t0,t1;
diff --git a/mysql-test/t/rocksdb.test b/mysql-test/t/rocksdb.test
index ff48631..9ebe2ed 100644
--- a/mysql-test/t/rocksdb.test
+++ b/mysql-test/t/rocksdb.test
@@ -1283,3 +1283,37 @@ create table t1 (
   index (key1) comment '$per_idnex_cf'
 )engine=rocksdb;
 
+
+--echo #
+--echo # Issue #22: SELECT ... FOR UPDATE takes a long time
+--echo #
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (
+  id1 int,
+  id2 int,
+  value1 int,
+  value2 int,
+  primary key(id1, id2) COMMENT 'new_column_family',
+  key(id2)
+) engine=rocksdb default charset=latin1 collate=latin1_bin;
+
+insert into t1 select A.a, B.a, 31, 1234 from t0 A, t0 B;
+
+explain 
+select * from t1 where id1=30 and value1=30 for update;
+
+set @var1=(select variable_value 
+           from information_schema.global_status 
+           where variable_name='rocksdb_number_keys_read');
+
+select * from t1 where id1=3 and value1=3 for update;
+
+set @var2=(select variable_value 
+           from information_schema.global_status 
+           where variable_name='rocksdb_number_keys_read');
+--echo # The following must return true (before the fix, the difference was 70):
+select (@var2 - @var1) < 12;
+
+drop table t0,t1;
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 9649699..c5b0b46 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -2553,7 +2553,8 @@ retry:
         bool found;
         if (!trx->changes.Get(key, &retrieved_record, &found))
         {
-          rocksdb::Status s= rdb->Get(options, key, &retrieved_record);
+          rocksdb::Status s= rdb->Get(options, pk_descr->get_cf(), key,
+                                      &retrieved_record);
           found= !s.IsNotFound();
         }
 
@@ -2774,7 +2775,8 @@ int ha_rocksdb::update_row(const uchar *old_data, uchar *new_data)
     {
       rocksdb::ReadOptions options; 
       /* Not setting options.snapshot, we need to check the real contents */
-      rocksdb::Status s= rdb->Get(options, key_slice, &retrieved_record);
+      rocksdb::Status s= rdb->Get(options, pk_descr->get_cf(), key_slice,
+                                  &retrieved_record);
       found= !s.IsNotFound();
     }
 


More information about the commits mailing list