diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2018-05-14 15:59:51 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2018-05-14 15:59:51 +0300 |
commit | 7e7592ade5bec98e80fb9a4aa6f6ad75107b605f (patch) | |
tree | 31c62465fb169371bcb80b20eadd2f197b9f586b /storage/rocksdb | |
parent | 6c0f3dd3414a97266912651fb169f630a36f2659 (diff) | |
download | mariadb-git-7e7592ade5bec98e80fb9a4aa6f6ad75107b605f.tar.gz |
MDEV-16154: Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_index
Backport the fix from the upstream and add our testcase.
Backported cset:
commit 997a979bf5e2f75ab88781d9d3fd22dddc1fc21f
Author: Manuel Ung <mung@fb.com>
Date: Thu Feb 15 08:38:12 2018 -0800
Fix crashes in autoincrement code paths
Summary:
There are two issues related to autoincrement that can lead to crashes:
1. The max value for double/float type for autoincrement was not implemented in MyRocks, and can lead to assertions. The fix is to add them in.
2. If we try to set auto_increment via alter table on a table without an auto_increment column defined, we segfault because there is no index from which to read the last value. The fix is to perform a check to see if autoincrement exists before reading from index (similar to code ha_rocksdb::open).
Fixes https://github.com/facebook/mysql-5.6/issues/792
Closes https://github.com/facebook/mysql-5.6/pull/794
Differential Revision: D6995096
Pulled By: lth
fbshipit-source-id: 1130ce1
Diffstat (limited to 'storage/rocksdb')
5 files changed, 48 insertions, 1 deletions
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 46d963860a2..8d7809a2213 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -5088,6 +5088,12 @@ static ulonglong rdb_get_int_col_max_value(const Field *field) { case HA_KEYTYPE_LONGLONG: max_value = 0x7FFFFFFFFFFFFFFFULL; break; + case HA_KEYTYPE_FLOAT: + max_value = 0x1000000ULL; + break; + case HA_KEYTYPE_DOUBLE: + max_value = 0x20000000000000ULL; + break; default: abort(); } @@ -11734,7 +11740,9 @@ bool ha_rocksdb::prepare_inplace_alter_table( if (!new_tdef) { new_tdef = m_tbl_def; } - max_auto_incr = load_auto_incr_value_from_index(); + if (table->found_next_number_field) { + max_auto_incr = load_auto_incr_value_from_index(); + } } ha_alter_info->handler_ctx = new Rdb_inplace_alter_ctx( diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result index 5da9a7e7e1c..8cc9b070a70 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result @@ -140,3 +140,13 @@ SELECT * FROM t1; a b 18446744073709551613 a DROP TABLE t1; +#---------------------------------- +# Issue #792 Crash in autoincrement +#---------------------------------- +CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB; +INSERT INTO t1 VALUES(2177,0); +DROP TABLE t1; +CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB; +INSERT INTO t0 VALUES(0); +ALTER TABLE t0 AUTO_INCREMENT=0; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result index 98c5ebe9f4c..eeb261d22e7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result @@ -89,3 +89,10 @@ CREATE TABLE t1 (i INT) ENGINE=RocksDB; FLUSH TABLE t1 FOR EXPORT; ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option DROP TABLE t1; +# +# MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde +# +CREATE TABLE t1 (a INT) ENGINE=RocksDB; +INSERT INTO t1 VALUES (1); +ALTER TABLE t1 AUTO_INCREMENT 10; +DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test index b8968590155..9d7f0365d07 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test @@ -103,3 +103,16 @@ SHOW CREATE TABLE t1; INSERT INTO t1 VALUES (NULL, 'c'); SELECT * FROM t1; DROP TABLE t1; + +--echo #---------------------------------- +--echo # Issue #792 Crash in autoincrement +--echo #---------------------------------- + +CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB; +INSERT INTO t1 VALUES(2177,0); +DROP TABLE t1; + +CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB; +INSERT INTO t0 VALUES(0); +ALTER TABLE t0 AUTO_INCREMENT=0; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test index 681e3d2d63f..a48c8a5e426 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test @@ -83,3 +83,12 @@ CREATE TABLE t1 (i INT) ENGINE=RocksDB; FLUSH TABLE t1 FOR EXPORT; DROP TABLE t1; +--echo # +--echo # MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde +--echo # +CREATE TABLE t1 (a INT) ENGINE=RocksDB; +INSERT INTO t1 VALUES (1); +ALTER TABLE t1 AUTO_INCREMENT 10; + +DROP TABLE t1; + |