Bug #41516 Assertion fails when error returned from handler::external_lock(thd, F_UNLCK)
Submitted: 16 Dec 2008 19:37 Modified: 7 Jul 2010 13:03
Reporter: Paul McCullagh (Basic Quality Contributor) (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.30 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: assertion failure, external_lock, F_UNLCK, qc

[16 Dec 2008 19:37] Paul McCullagh
Description:
The failure of an assertion prevents the return of an error from handler::external_lock(thd, F_UNLCK):

line 477 file sql_class.cc
  DBUG_ASSERT(! is_set() || can_overwrite_status);

The problem is, external_lock(thd, F_UNLCK), marks the end of a statement when not in auto-commit mode.

Foreign keys can cause failures at the end of a statement. So it is required to return an error at this point.

How to repeat:
Compile the latest version of the PBXT storage engine from bzr:

bzr branch lp:pbxt/1.0.07-rc, with MySQL 5.1.30.

Before compiling uncomment the line:

#define XT_IMPLEMENT_NO_ACTION

in xt_defs.h

This will enable the correct implementation of the NO ACTION foreign key action.

Then run the following test:

DROP TABLE IF EXISTS t2,t1;
CREATE TABLE t1 (s1 INT PRIMARY KEY) engine=pbxt;
CREATE TABLE t2 (s1 INT PRIMARY KEY, FOREIGN KEY (s1) REFERENCES t1 (s1) ON DELETE NO ACTION) engine=pbxt;

INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);

begin;
INSERT INTO t1 VALUES (2);
DELETE FROM t1 where s1 = 1;

The assertion specified above will fail.

Suggested fix:
MySQL should handle failures in external_lock() and handler::start_stmt(), which can both indicate the end of a statement.
[17 Dec 2008 14:41] MySQL Verification Team
Thank you for the bug report. I tried to compile PBXT with latest 5.1 source tree on Ubuntu 8.10 64-bit and I got the below error:

/bin/bash ../libtool --preserve-dup-deps --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I/home/miguel/bzr/mysql-5.1-build/sql -I/home/miguel/bzr/mysql-5.1-build/include -I/home/miguel/bzr/mysql-5.1-build/regex -I/home/miguel/bzr/mysql-5.1-build    -DMYSQL_DYNAMIC_PLUGIN -g -DDEBUG     -fno-implicit-templates -fno-exceptions -fno-rtti -MT libpbxt_la-bsearch_xt.lo -MD -MP -MF .deps/libpbxt_la-bsearch_xt.Tpo -c -o libpbxt_la-bsearch_xt.lo `test -f 'bsearch_xt.cc' || echo './'`bsearch_xt.cc
../libtool: line 656: X--tag=CXX: command not found
../libtool: line 689: libtool: ignoring unknown tag : command not found
../libtool: line 656: X--mode=compile: command not found
../libtool: line 806: *** Warning: inferring the mode of operation is deprecated.: command not found
../libtool: line 807: *** Future versions of Libtool will require -mode=MODE be specified.: command not found
../libtool: line 950: Xg++: command not found
../libtool: line 950: X-DHAVE_CONFIG_H: command not found
../libtool: line 950: X-I.: command not found
../libtool: line 950: X-I..: command not found
../libtool: line 950: X-I/home/miguel/bzr/mysql-5.1-build/sql: No such file or directory
../libtool: line 950: X-I/home/miguel/bzr/mysql-5.1-build/include: No such file or directory
../libtool: line 950: X-I/home/miguel/bzr/mysql-5.1-build/regex: No such file or directory
../libtool: line 950: X-I/home/miguel/bzr/mysql-5.1-build: No such file or directory
../libtool: line 950: X-DMYSQL_DYNAMIC_PLUGIN: command not found
../libtool: line 950: X-g: command not found
../libtool: line 950: X-DDEBUG: command not found
../libtool: line 950: X-fno-implicit-templates: command not found
../libtool: line 950: X-fno-exceptions: command not found
../libtool: line 950: X-fno-rtti: command not found
../libtool: line 950: X-MT: command not found
../libtool: line 950: Xlibpbxt_la-bsearch_xt.lo: command not found
../libtool: line 950: X-MD: command not found
../libtool: line 950: X-MP: command not found
../libtool: line 950: X-MF: command not found
../libtool: line 950: X.deps/libpbxt_la-bsearch_xt.Tpo: No such file or directory
../libtool: line 950: X-c: command not found
../libtool: line 998: Xlibpbxt_la-bsearch_xt.lo: command not found
../libtool: line 1003: libtool: compile: cannot determine name of library object from `': command not found
make[2]: *** [libpbxt_la-bsearch_xt.lo] Error 1
make[2]: Leaving directory `/home/miguel/bzr/1.0.07-rc/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/miguel/bzr/1.0.07-rc'
make: *** [all] Error 2
miguel@hegel:~/bzr/1.0.07-rc$ 

Could you please provide instructions how to compile correctly or if there is some problem with PBXT code. Thanks in advance.
[18 Dec 2008 14:21] Paul McCullagh
Hi Miguel,

Please make sure that you have built the MySQL tree. And it is best to do a "make install" as well, because the "make install" in PBXT will work correctly.

Then, assuming that you built 5.1.30 in the following directory: /home/miguel/bzr/mysql-5.1-build/

go to the PBXT directory (which should not be under the MySQL tree when compiling as a plugin) and enter:

./configure --with-mysql=/home/miguel/bzr/mysql-5.1-build

Then please check that configure does not print any error at the end. Then,

make
make install

should do it.

After that, start mysqld, and with mysql, enter:

install plugin PBXT soname 'libpbxt.so';
[21 Jan 2009 16:08] MySQL Verification Team
Hi Paul,

I followed your instructions now trying to compile on Suse 11.1 64-bit and I got the same compile error:

../libtool: line 953: X-MP: command not found
../libtool: line 953: X-MF: command not found
../libtool: line 953: X.deps/libpbxt_la-bsearch_xt.Tpo: No such file or directory
../libtool: line 953: X-c: command not found
../libtool: line 1001: Xlibpbxt_la-bsearch_xt.lo: command not found
../libtool: line 1006: libtool: compile: cannot determine name of library object from `': command not found
make[2]: *** [libpbxt_la-bsearch_xt.lo] Error 1
make[2]: Leaving directory `/home/miguel/dbs/1.0.07-rc/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/miguel/dbs/1.0.07-rc'
make: *** [all] Error 2
miguel@hegel:~/dbs/1.0.07-rc>
[21 Jan 2009 16:28] Paul McCullagh
Hi Miguel,

Looks like the src/Makefile generated by configure is bad. There seems to be an 'X' too much in there. Unfortunately it impossible to tell what the problem is without a lot more information.

As far as I know, there is only one reason the PBXT configure may fail. It reads the MySQL top-level Makefile and extracts certain parameters for the build. If the Makefile has an unexpected format in a critical spot then this may fail.

However, with SUSE 11.1 you should not have any problems because we use SUSE ourselves.

But anyway, maybe you can try building on a different system. Otherwise contact me directly to sort this out. I will need to get some files from you (or maybe a login) in order to figure why the build doesn't work.

Regards,

Paul
[21 Jan 2009 16:35] Paul McCullagh
Hi Miguel,

I am not sure if my previous comment was relevant, because I see you have already tried on 2 different systems.

So maybe the problem is with libtool itself.

What version of libtool are you using?

The command line:

/bin/bash ../libtool --preserve-dup-deps --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H
-I. -I.. -I/home/miguel/bzr/mysql-5.1-build/sql -I/home/miguel/bzr/mysql-5.1-build/include
-I/home/miguel/bzr/mysql-5.1-build/regex -I/home/miguel/bzr/mysql-5.1-build   
-DMYSQL_DYNAMIC_PLUGIN -g -DDEBUG     -fno-implicit-templates -fno-exceptions -fno-rtti
-MT libpbxt_la-bsearch_xt.lo -MD -MP -MF .deps/libpbxt_la-bsearch_xt.Tpo -c -o
libpbxt_la-bsearch_xt.lo `test -f 'bsearch_xt.cc' || echo './'`bsearch_xt.cc

looks good. So it should work.

Regards,

Paul
[28 Jan 2009 14:03] MySQL Verification Team
Hi Paul,
Now I was able to compile on OpenSolaris 2008.11 but the current source has a bug when installing the plugin. I will try older source tree.

miguel@skybr.net:~/dbs$ 5.1/bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.32-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> install plugin PBXT soname 'libpbxt.so';
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[28 Jan 2009 14:14] Paul McCullagh
Hi Miguel,

If you are running on RISK, then you will run into this bug, which was only fixed after 1.0.07 release:

RN213: Fixed an index corruption bug on SPARC Solaris. Note this error will occur on any machine that does not use the x86 (little endian) byte order.

OpenSolaris on x86 should be OK.

However, I am not sure why the server crashed on INSTALL PLUGIN.

My advice would be to stick to Linux and try to solve the compile problem with libtool. Perhaps you can contact me directly (paul-dot-mccullagh-at-primebase-dot-org), and give me a login so that I can solve the compile problem for you.

Best regards,

Paul
[28 Jan 2009 15:06] MySQL Verification Team
5.1.30 is crashing too!

miguel@skybr.net:~/mysql-5.1.30$ 5.1/bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.30-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> install plugin PBXT soname 'libpbxt.so';
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>
[31 Jan 2009 12:08] MySQL Verification Team
Hi Paul,
I am using X86 computer and I was able to fix my compile problems doing some search about the error message I was getting, actually it is a problem with libtool version which assume is newer in my computers:

miguel@skybr:~$ libtool --version
ltmain.sh (GNU libtool) 2.2.4
Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996

Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
miguel@skybr:~$ 

To fix the problem I did:

libtoolize --force --copy
aclocal
autoconf
automake --add-missing

then I followed your instructions with success:

miguel@skybr:~/dbs$ 5.1/bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.32-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> install plugin PBXT soname 'libpbxt.so';
Query OK, 0 rows affected (0.34 sec)

mysql> use test
Database changed
mysql> DROP TABLE IF EXISTS t2,t1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)

mysql> CREATE TABLE t1 (s1 INT PRIMARY KEY) engine=pbxt;
Query OK, 0 rows affected (1.84 sec)

mysql> CREATE TABLE t2 (s1 INT PRIMARY KEY, FOREIGN KEY (s1) REFERENCES t1 (s1) ON DELETE NO
    -> ACTION) engine=pbxt;
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> INSERT INTO t1 VALUES (1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO t2 VALUES (1);
Query OK, 1 row affected (0.01 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 VALUES (2);
Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM t1 where s1 = 1;
Query OK, 1 row affected (0.00 sec)

090131  8:40:39 [Note] 5.1/libexec/mysqld: ready for connections.
Version: '5.1.32-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
090131 09:50:37 [Note] PrimeBase XT (PBXT) Engine 1.0.07i RC loaded...
090131 09:50:37 [Note] Paul McCullagh, PrimeBase Technologies GmbH, http://www.primebase.org
mysqld: sql_class.cc:502: void Diagnostics_area::set_error_status(THD*, uint, const char*): Assertion `! is_set() || can_overwrite_status' failed.
090131  9:53:23 - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 337725 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd: 0x92ce990
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xb2fba3c0 thread_stack 0x30000
5.1/libexec/mysqld(my_print_stacktrace+0x26)[0x871a335]
5.1/libexec/mysqld(handle_segfault+0x2ae)[0x82bd91f]
[0xb7f75400]
/lib/tls/i686/cmov/libc.so.6(abort+0x188)[0xb7d72248]
/lib/tls/i686/cmov/libc.so.6(__assert_fail+0xee)[0xb7d6972e]
5.1/libexec/mysqld(_ZN16Diagnostics_area16set_error_statusEP3THDjPKc+0x47)[0x82a56e7]
5.1/libexec/mysqld(my_message_sql+0x24f)[0x82bc83f]
5.1/libexec/mysqld(my_error+0x1d0)[0x8700990]
5.1/libexec/mysqld[0x82b2c4b]
5.1/libexec/mysqld[0x82b3a82]
5.1/libexec/mysqld(_Z19mysql_unlock_tablesP3THDP13st_mysql_lock+0x88)[0x82b4508]
5.1/libexec/mysqld(_Z19close_thread_tablesP3THD+0x2b3)[0x831c62d]
5.1/libexec/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1cc8)[0x82db05f]
5.1/libexec/mysqld(_Z10do_commandP3THD+0x263)[0x82db42c]
5.1/libexec/mysqld(handle_one_connection+0x11b)[0x82c73fb]
/lib/tls/i686/cmov/libpthread.so.0[0xb7f3550f]
/lib/tls/i686/cmov/libc.so.6(clone+0x5e)[0xb7e267ee]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x931e5b8 = DELETE FROM t1 where s1 = 1

The weird thing I experienced is that sometimes the plugin compile
with success and then crash the server in the install process or when is started
again (another bug was reported regarding this behaviour) and it isn't MySQL bug
instead is a plugin build issue. I will re-verify that bug report.
[31 Jan 2009 16:26] MySQL Verification Team
Thank you for the bug report. Verified as described.
[27 Feb 2009 7:23] Davi Arnaut
This assertion usually means that the operation has already sent a response (error or ok packet) and the server can't really overwrite it later. So, why do you want to overwrite the statement status?
[12 Mar 2010 12:12] Konstantin Osipov
See Bug#37521 for E/R.
[12 Mar 2010 12:40] Paul McCullagh
Hi Davi,

In answer to your question:

The DELETE statement, has a FK action on it which is performed at the "end of statement". This action can fail, and with that failure, the DELETE statement should also fail.

So if the MySQL server has already sent an OK to the client by the time the "end of statement" is reached (according to the engine), then this is a bit problematic.

For one thing, it prevents the correct implementation of FKs in this case.

But this problem may just be a symptom of a greater problem, which is the engine API itself.
[7 Jul 2010 13:03] Jon Olav Hauglid
Closing as a duplicate of bug#37521
[4 Aug 2010 7:52] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:55] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:56] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:57] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:58] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:59] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:00] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:08] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:13] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:14] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:15] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:16] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:17] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:24] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 9:00] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:20)
[4 Aug 2010 9:03] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100804081630-ntapn8bf9pko9vj3) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (pib:20)