← Back to team overview

oqgraph-dev team mailing list archive

Problem with alter table and opening table on our storage engine - maybe bug in mysql core itself

 

Hi Arjen, Antony

I started on the harder bugs now, the segfaults, as everything is building ok
for v3 even with latest boost, and I sorted the last of the functional issues
I hope

So looking at https://bugs.launchpad.net/oqgraph/+bug/1134355

I think this specific segfault may actually be triggered by a bug in Mysql:

During alter table, when altering an option, an extra option record is added
to the end of the current option list.
This list node is created in something called 'root' (temporary) memory which
is freed on exit from dispatch_command() in sql_parse.cc (which is back up the
call stack into the crash point)

If alter table succeeds, I assume the options get merged and the list rejigged
and the _old_ option in the list is properly removed and its ancestor next
fixed correctly, and the new item moved out of (root) ( or some behaviour
similar to this that doesnt cause memory problems)

If alter table fails when the alter consists of changing the value of an
option, the merged option list doesnt get rejigged to remove the 'new' option,
so when the temp memory is freed the last item in the list next is left
pointing to junk on exit form dispatch_command() ...

So when I added a 'fix', which delinked the extra list item, it triggers a
further crash complaining that oqgraph is reopening a table twice (stack trace
after)

So I am wondering if we are not properly doing something in our storage engine
that only manifests when edge cases like alter tables are attempted?

I had a look in the ha_example.cc code.  ALthough I cant immediately see
anything obvious (I dont know what the HASH is for in it) there is a method
  check_if_incompatible_data() called if ALTER TABLE can't detect otherwise
  if new and old definition are compatible
which we dont seem to implement, I am wondering if we hook this and refuse to
ever alter our tables as a short term fix.  If somene then requests a new
feature to make our tables alterable, we can deal with it then... or of there
is some other way to achieve the same result?

I suspect this particualr problem is caused because ha_oqgraph opens the
backing store in the first alter table and not closed it again




mysqld:
/home/andrew/develop/maria/repo/oqgraph-varchar/storage/myisam/mi_open.c:56:
test_if_reopen: Assertion `strcmp(share->unique_file_name,filename) ||
share->last_version' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffea15d700 (LWP 6254)]
0x00007ffff6fce1b5 in *__GI_raise (sig=<optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
        in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) bt
#0  0x00007ffff6fce1b5 in *__GI_raise (sig=<optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff6fd0fc0 in *__GI_abort () at abort.c:92
#2  0x00007ffff6fc7301 in *__GI___assert_fail (assertion=0xfaf250
"strcmp(share->unique_file_name,filename) || share->last_version",
file=<optimized out>, line=56,  unction=0xfaf48c "test_if_reopen") at assert.c:81
#3  0x0000000000cd560d in test_if_reopen (filename=0x7fffea158bd0
"/home/andrew/develop/maria/repo/oqgraph-varchar/build/mysql-test/var/mysqld.1/data/test/graph_bas
.MYI") at
/home/andrew/develop/maria/repo/oqgraph-varchar/storage/myisam/mi_open.c:55
#4  0x0000000000cd57df in mi_open (name=0x2284c18 "./test/graph_base", mode=2,
open_flags=82) at
/home/andrew/develop/maria/repo/oqgraph-varchar/storage/myisam/mi_o en.c:103
#5  0x0000000000caa52d in ha_myisam::open (this=0x2285c28, name=0x2284c18
"./test/graph_base", mode=2, test_if_locked=18) at
/home/andrew/develop/maria/repo/oqgraph varchar/storage/myisam/ha_myisam.cc:746
#6  0x00000000007e501a in handler::ha_open (this=0x2285c28,
table_arg=0x2283918, name=0x2284c18 "./test/graph_base", mode=2,
test_if_locked=18) at /home/andrew/deve
op/maria/repo/oqgraph-varchar/sql/handler.cc:2347
#7  0x00000000006e5713 in open_table_from_share (thd=0x232e4f0,
share=0x22834f8, alias=0x7fffea4838ad "", db_stat=39, prgflag=44,
ha_open_flags=16, outparam=0x22839 8, is_create_table=false) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/table.cc:2663
#8  0x00007fffea4613e6 in ha_oqgraph::open (this=0x22830e8, name=0x2280f08
"./test/#sql-185f_2", mode=2, test_if_locked=18) at
/home/andrew/develop/maria/repo/oqgra h-varchar/storage/oqgraph/ha_oqgraph.cc:559
#9  0x00000000007e501a in handler::ha_open (this=0x22830e8,
table_arg=0x2280190, name=0x2280f08 "./test/#sql-185f_2", mode=2,
test_if_locked=18) at /home/andrew/dev
lop/maria/repo/oqgraph-varchar/sql/handler.cc:2347
#10 0x00000000006e5713 in open_table_from_share (thd=0x232e4f0,
share=0x2280ae8, alias=0x7fffea15b3c0 "#sql-185f_2", db_stat=7, prgflag=44,
ha_open_flags=16, outpar m=0x2280190, is_create_table=false) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/table.cc:2663
#11 0x00000000005b9b65 in open_table_uncached (thd=0x232e4f0,
path=0x7fffea15a1c0 "./test/#sql-185f_2", db=0x2382ae0 "test",
table_name=0x7fffea15b3c0 "#sql-185f_2"  add_to_temporary_tables_list=true) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_base.cc:6185
#12 0x00000000006bf1f4 in mysql_alter_table (thd=0x232e4f0, new_db=0x2382ae0
"test", new_name=0x23824d8 "graph", create_info=0x7fffea15bcc0,
table_list=0x2382518, a ter_info=0x7fffea15bdc0, order_num=0, order=0x0,
ignore=false, require_online=false) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_table.cc:6869
#13 0x000000000096f977 in Alter_table_statement::execute (this=0x2382b58,
thd=0x232e4f0) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_alter.cc:106
#14 0x000000000061c840 in mysql_execute_command (thd=0x232e4f0) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_parse.cc:4834
#15 0x000000000061f9ec in mysql_parse (thd=0x232e4f0, rawbuf=0x2382408 "alter
table graph ORIGID = 'something_else'", length=43,
parser_state=0x7fffea15c620) at /ho
e/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_parse.cc:6124
#16 0x00000000006129ba in dispatch_command (command=COM_QUERY, thd=0x232e4f0,
packet=0x223afc1 "alter table graph ORIGID = 'something_else'",
packet_length=43) at /
ome/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_parse.cc:1266
#17 0x0000000000611b35 in do_command (thd=0x232e4f0) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_parse.cc:982
#18 0x0000000000721c45 in do_handle_one_connection (thd_arg=0x232e4f0) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_connect.cc:1267
#19 0x00000000007216ed in handle_one_connection (arg=0x232e4f0) at
/home/andrew/develop/maria/repo/oqgraph-varchar/sql/sql_connect.cc:1181
#20 0x00000000009c5be2 in pfs_spawn_thread (arg=0x2148b30) at
/home/andrew/develop/maria/repo/oqgraph-varchar/storage/perfschema/pfs.cc:1800
#21 0x00007ffff7bc98ca in start_thread (arg=<optimized out>) at
pthread_create.c:300
#22 0x00007ffff706b92d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#23 0x0000000000000000 in ?? ()