[Commits] f0655a2: Re-commit in git: Explicit insert into an auto-inc column is not noticed by RocksDB

Sergei Petrunia psergey at askmonty.org
Sat Jul 12 00:32:25 EEST 2014


revision-id: f0655a24da3dcd1d1f77c0160558e04f467b07df
parent(s): d257f92bbe35474764cf91ac8bfaf643542034cf
committer: Sergei Petrunia
branch nick: webscalesql-5.6
timestamp: 2014-07-12 01:32:25 +0400
message:

Re-commit in git:  Explicit insert into an auto-inc column is not noticed by RocksDB

Basic fix: don't forget to update the table-wide auto-increment value.

-----------------------

 mysql-test/r/rocksdb.result   |   32 ++++++++++++++++++++++++++++++++
 mysql-test/t/rocksdb.test     |   28 +++++++++++++++++++++++++++-
 storage/rocksdb/ha_rocksdb.cc |    6 +++---
 3 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/mysql-test/r/rocksdb.result b/mysql-test/r/rocksdb.result
index d12326e..87e18ec 100644
--- a/mysql-test/r/rocksdb.result
+++ b/mysql-test/r/rocksdb.result
@@ -688,6 +688,7 @@ DROP TABLE t33;
 #
 #  Unique indexes can be created, but uniqueness won't be enforced
 create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB;
+drop table t33;
 #
 # MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range 
 #
@@ -1169,3 +1170,34 @@ set rocksdb_max_row_locks= 20;
 update t1 set a=a+10;
 ERROR HY000: Got error 189 'Number of locks held reached @@rocksdb_max_row_locks' from ROCKSDB
 DROP TABLE t1;
+# 
+# Test AUTO_INCREMENT behavior problem,
+#  "explicit insert into an auto-inc column is not noticed by RocksDB"
+# 
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+i
+1
+2
+drop table t1;
+create table t2 (i int primary key auto_increment) engine=RocksDB;
+insert into t2 values (1);
+select * from t2;
+i
+1
+# this fails (ie. used to fail), RocksDB engine did not notice use of '1' above
+insert into t2 values (null);
+select * from t2;
+i
+1
+2
+# but then this succeeds, so previous statement must have incremented next number counter
+insert into t2 values (null);
+select * from t2;
+i
+1
+2
+3
+drop table t2;
diff --git a/mysql-test/t/rocksdb.test b/mysql-test/t/rocksdb.test
index f4e158e..26745fa 100644
--- a/mysql-test/t/rocksdb.test
+++ b/mysql-test/t/rocksdb.test
@@ -613,7 +613,7 @@ DROP TABLE t33;
 #--error ER_GET_ERRMSG
 --echo #  Unique indexes can be created, but uniqueness won't be enforced
 create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB;
-
+drop table t33;
 
 --echo #
 --echo # MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range 
@@ -1052,3 +1052,29 @@ set rocksdb_max_row_locks= 20;
 update t1 set a=a+10;
 DROP TABLE t1;
 
+
+--echo # 
+--echo # Test AUTO_INCREMENT behavior problem,
+--echo #  "explicit insert into an auto-inc column is not noticed by RocksDB"
+--echo # 
+create table t1 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t1 values (null);
+insert into t1 values (null);
+select * from t1;
+drop table t1;
+
+create table t2 (i int primary key auto_increment) engine=RocksDB;
+
+insert into t2 values (1);
+select * from t2;
+
+--echo # this fails (ie. used to fail), RocksDB engine did not notice use of '1' above
+insert into t2 values (null);
+select * from t2;
+
+--echo # but then this succeeds, so previous statement must have incremented next number counter
+insert into t2 values (null);
+select * from t2;
+drop table t2;
+
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index bfb6ef5..0d940e2 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -1694,7 +1694,7 @@ int ha_rocksdb::write_row(uchar *buf)
   DBUG_ASSERT(lock_rows);
   
   /* Update AUTO_INCREMENT column */
-  bool using_auto_incr_value= false;
+  //bool using_auto_incr_value= false;
 
   /*
     Note: "buf == table->record[0]" is copied from innodb. I am not aware of 
@@ -1707,7 +1707,7 @@ int ha_rocksdb::write_row(uchar *buf)
     {
       DBUG_RETURN(err);
     }
-    using_auto_incr_value= true;
+    //using_auto_incr_value= true;
   }
 
   /* Get a packed primary key value */
@@ -1776,7 +1776,7 @@ int ha_rocksdb::write_row(uchar *buf)
   }
  
   /* Write primary_key -> record */
-  if (!using_auto_incr_value && table->next_number_field)
+  if (/*!using_auto_incr_value &&*/ table->next_number_field)
     update_auto_incr_val();
 
   rocksdb::Slice value_slice;


More information about the commits mailing list