[Commits] e11e7d1: Fix Issue #5: Transaction rollback doesn't undo all changes.

Sergei Petrunia psergey at askmonty.org
Thu Jul 24 19:23:04 EEST 2014


revision-id: e11e7d11aa515b36119f8915198f6a5674340ae2
parent(s): f0eca4824d32d143e4a6961f0409a00435e74458
committer: Sergei Petrunia
branch nick: webscalesql-5.6
timestamp: 2014-07-24 20:23:04 +0400
message:

Fix Issue #5: Transaction rollback doesn't undo all changes.

ha_rocksdb::write_row() had a wrong check which caused its default
behavior to work like its bulk-insert mode: commit the changes
every @@bulk_load_size rows.

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

 mysql-test/r/rocksdb.result   |   18 ++++++++++++++++++
 mysql-test/t/rocksdb.test     |   20 ++++++++++++++++++++
 storage/rocksdb/ha_rocksdb.cc |    2 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/mysql-test/r/rocksdb.result b/mysql-test/r/rocksdb.result
index c587b75..9541aab 100644
--- a/mysql-test/r/rocksdb.result
+++ b/mysql-test/r/rocksdb.result
@@ -1264,3 +1264,21 @@ b+t
 100000000000000100
 1000000000000000100
 DROP TABLE t1;
+#
+# Fix issue #5: Transaction rollback doesn't undo all changes.
+#
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (id int auto_increment primary key, value int) engine=rocksdb;
+set autocommit=0;
+begin;
+set @a:=0;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+rollback;
+select count(*) from t1;
+count(*)
+0
+set autocommit=1;
+drop table t0, t1;
diff --git a/mysql-test/t/rocksdb.test b/mysql-test/t/rocksdb.test
index 83bec5c..0d11fe5 100644
--- a/mysql-test/t/rocksdb.test
+++ b/mysql-test/t/rocksdb.test
@@ -1119,3 +1119,23 @@ INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000
 SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
 DROP TABLE t1;
 
+--echo #
+--echo # Fix issue #5: Transaction rollback doesn't undo all changes.
+--echo #
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (id int auto_increment primary key, value int) engine=rocksdb;
+
+set autocommit=0;
+begin;
+set @a:=0;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4;
+rollback;
+select count(*) from t1;
+
+set autocommit=1;
+drop table t0, t1;
+
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 849ed72..4ebec6f 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -1785,7 +1785,7 @@ int ha_rocksdb::write_row(uchar *buf)
   trx->changes.Put(key_slice, value_slice);
   trx->n_writes++;
 
-  if (do_locking && trx->n_writes > THDVAR(table->in_use, bulk_load_size))
+  if (!do_locking && trx->n_writes > THDVAR(table->in_use, bulk_load_size))
   {
     /* Bulk insert mode: flush the write batch if it became too big */
     if (trx->flush_batch())


More information about the commits mailing list