MDEV-5748 Assertion `status_var.memory_used == 0' fails on disconnect after opening an OQGRAPH table

make sure MY_THREAD_SPECIFIC is not set for memroot that can be
transferred between threads
This commit is contained in:
Sergei Golubchik 2014-03-02 19:01:34 +01:00
parent 66883ee08d
commit 8705d00ab6
3 changed files with 73 additions and 0 deletions

View File

@ -538,7 +538,11 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
origid= destid= weight= 0;
// Here we're abusing init_tmp_table_share() which is normally only works for thread-local shares.
init_tmp_table_share( thd, share, table->s->db.str, table->s->db.length, options->table_name, "");
// because of that, we need to reinitialize the memroot (to reset MY_THREAD_SPECIFIC flag)
DBUG_ASSERT(share->mem_root.used == NULL); // it's still empty
init_sql_alloc(&share->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
// What I think this code is doing:
// * Our OQGRAPH table is `database_blah/name`

View File

@ -0,0 +1,32 @@
CREATE TABLE oq_backing (
origid INT UNSIGNED NOT NULL,
destid INT UNSIGNED NOT NULL,
weight DOUBLE NOT NULL,
PRIMARY KEY (origid, destid),
KEY (destid)
);
CREATE TABLE oq_table (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH
data_table='oq_backing' origid='origid' destid='destid' weight='weight';
flush tables;
show fields in oq_table;
Field Type Null Key Default Extra
latch varchar(32) YES MUL NULL
origid bigint(20) unsigned YES NULL
destid bigint(20) unsigned YES NULL
weight double YES NULL
seq bigint(20) unsigned YES NULL
linkid bigint(20) unsigned YES NULL
show tables;
Tables_in_test
oq_backing
oq_table
drop table oq_table, oq_backing;

View File

@ -0,0 +1,37 @@
#
# MDEV-5748 Assertion `status_var.memory_used == 0' fails on disconnect after opening an OQGRAPH table
#
# try to open oqgraph table in one connection and use in another:
--connect (con1,localhost,root,,)
CREATE TABLE oq_backing (
origid INT UNSIGNED NOT NULL,
destid INT UNSIGNED NOT NULL,
weight DOUBLE NOT NULL,
PRIMARY KEY (origid, destid),
KEY (destid)
);
CREATE TABLE oq_table (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH
data_table='oq_backing' origid='origid' destid='destid' weight='weight';
flush tables;
show fields in oq_table;
--disconnect con1
--connection default
show tables;
drop table oq_table, oq_backing;