Bug #40862 main.subselect_notembedded test case fails
Submitted: 19 Nov 2008 18:24 Modified: 10 Jan 2013 11:25
Reporter: BJ Dierkes Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.1.29-rc OS:Any
Assigned to: Joerg Bruehe CPU Architecture:Any

[19 Nov 2008 18:24] BJ Dierkes
Description:

This case still fails:

System: RHEL 4 ES, and 5.2 Server i386 fully patched
MySQL 5.1.29-rc

main.subselect_notembedded     
[ fail ]
mysqltest: At line 52: query '$start $end' failed with wrong errno 2013: 'Lost connection
to MySQL server during query', instead of 0...
The result from queries just before the failure was:
purge master logs before (select adddate(current_timestamp(), interval -4 day));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'select
adddate(current_timestamp(), interval -4 day))' at line 1
purge master logs before adddate(current_timestamp(), interval -4 day);
create table t1(a int,b int,key(a),key(b));
insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
(6,7),(7,4),(5,3);
5
4
3
2
1
26
25
24
23
22
21
More results from queries before failure can be found in
/builddir/build/BUILD/mysql-5.1.29-rc/mysql-test/var/log/subselect_notembedded.log
Aborting: main.subselect_notembedded failed in default mode. 
To continue, re-run with '--force'.
Stopping All Servers

How to repeat:
configure && make && make test

Suggested fix:
Not sure....
[19 Nov 2008 18:59] Joerg Bruehe
The test passed in the build of 5.1.29 on all our x86 machines, so this is a nasty surprise.

Two questions:

1) Did you build from source, or did you download one of our packages?
   If download, which one (exact file name please, if possible)?

2) The symptom looks suspiciously like that of bug#21476.
   We have never seen that bug on a Linux/x86, but who knows ...
   Could you please tell us the value of your "thread_stack" setting?
[19 Nov 2008 21:47] BJ Dierkes
This is building from Source RPMS that we maintain... therefore niether from source nor your RPM sets.  the following is *exactly* what is being run:

#!/bin/sh

RPM_SOURCE_DIR="/builddir/build/SOURCES"
RPM_BUILD_DIR="/builddir/build/BUILD"
RPM_OPT_FLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables"
RPM_ARCH="i386"
RPM_OS="linux"
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
RPM_DOC_DIR="/usr/share/doc"
export RPM_DOC_DIR
RPM_PACKAGE_NAME="mysql"
RPM_PACKAGE_VERSION="5.1.29"
RPM_PACKAGE_RELEASE="2.1.rs.el5"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
RPM_BUILD_ROOT="/var/tmp/mysql-5.1.29-root"
export RPM_BUILD_ROOT

PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig"
export PKG_CONFIG_PATH

set -x
umask 022
cd /builddir/build/BUILD

cd mysql-5.1.29-rc
LANG=C
export LANG
unset DISPLAY

CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
# MySQL 4.1.10 definitely doesn't work under strict aliasing; also,
# gcc 4.1 breaks MySQL 5.0.16 without -fwrapv
CFLAGS="$CFLAGS -fno-strict-aliasing -fwrapv"

CFLAGS="$CFLAGS -fPIC"
CXXFLAGS="$CFLAGS -felide-constructors -fno-rtti -fno-exceptions"
export CFLAGS CXXFLAGS

export CFLAGS CXXFLAGS CC LDFLAGS

  CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables}" ; export CFLAGS ; 
  CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables}" ; export CXXFLAGS ; 
  FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables}" ; export FFLAGS ; 
  for i in $(find . -name config.guess -o -name config.sub) ; do 
           [ -f /usr/lib/rpm/redhat/$(basename $i) ] && /bin/rm -f $i && /bin/cp -fv /usr/lib/rpm/redhat/$(basename $i) $i ; 
  done ; 
  ./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu \
        --target=i386-redhat-linux-gnu \
        --program-prefix= \
        --prefix=/usr \
        --exec-prefix=/usr \
        --bindir=/usr/bin \
        --sbindir=/usr/sbin \
        --sysconfdir=/etc \
        --datadir=/usr/share \
        --includedir=/usr/include \
        --libdir=/usr/lib \
        --libexecdir=/usr/libexec \
        --localstatedir=/var \
        --sharedstatedir=/usr/com \
        --mandir=/usr/share/man \
        --infodir=/usr/share/info \
        --with-pic \
        --with-readline \
        --with-ssl \
        --without-debug \
        --enable-shared \
        --with-bench \
        --localstatedir=/var/lib/mysql \
        --with-unix-socket-path=/var/lib/mysql/mysql.sock \
        --with-mysqld-user="mysql" \
        --with-extra-charsets=all \
        --with-innodb \
        --with-berkeley-db \
        --enable-local-infile \
        --enable-largefile \
        --enable-thread-safe-client \
        --disable-dependency-tracking \
        --with-plugin-partition \
        --with-plugin-csv \
        --with-plugin-ndbcluster \
         \
        --with-named-thread-libs="-lpthread"

gcc $CFLAGS $LDFLAGS -o scriptstub "-DLIBDIR=\"/usr/lib/mysql\"" /builddir/build/SOURCES/scriptstub.c

make -j4
make check

make test
[20 Nov 2008 10:14] Joerg Bruehe
Grabbing this one, because I suspect this is a build/options issue and want to get rid of it ASAP.

Sorry, from your "How to repeat" I should have guessed you build yourself.

Regarding the thread stack size:
However the server gets the size (config file, ...), at any time there is a current value of it. This is the one I would like to know.
I propose you apply this patch to the test and run it again:

=== modified file 'mysql-test/t/subselect_notembedded.test'
--- mysql-test/t/subselect_notembedded.test     2008-03-07 18:14:34 +0000
+++ mysql-test/t/subselect_notembedded.test     2008-11-20 09:46:04 +0000
@@ -8,6 +8,8 @@
 purge master logs before (select adddate(current_timestamp(), interval -4 day));
 purge master logs before adddate(current_timestamp(), interval -4 day);

+show variables like 'thread_stack';
+
 #
 # Bug31048: Many nested subqueries may cause server crash.
 #

As this changes the output, the test will definitely fail then:
   +show variables like 'thread_stack';
   +Variable_name  Value
   +thread_stack   ?????????
Please report that value.

Regarding bug#21476:
It seems there is no final patch yet, as the minimum required value depends on the platform used (and maybe other things).

Does test "execution_constants" pass for your build?

I see a proposal to modify 'sql/mysql_priv.h' and raise the value of STACK_MIN_SIZE from 12000 to 16000, but that isn't yet pushed.

Another setting in that file which might be relevant is STACK_BUFF_ALLOC, I read the comments to mean this is a minimum for decent error reporting.
If you like to experiment, I propose to raise this from 352 to 512.

Also, there is the report of bug#35019 which I read to mean
  "the minimum stack size and its handling depend on
   threading library features which changed in RedHat 5",
so this might be relevant for your case too.

I'm sorry I don't have a similar environment available locally, so I can't try myself, and the build hosts are quite busy with other stuff at the moment.
[21 Nov 2008 19:48] BJ Dierkes
Joerg,

I am currently rebuilding to grab that thread_stack value and will update you once I have it.  With regard to your question about 'execution_constants', yes... that test passes along with all other tests except for the following I have added to disabled.def:

--- mysql-5.1.29-rc/mysql-test/t/disabled.def.orig      2008-10-11 17:19:41.000000000 -0500
+++ mysql-5.1.29-rc/mysql-test/t/disabled.def   2008-11-18 18:58:24.000000000 -0600
@@ -15,3 +15,6 @@
 log_tables.test                       : Bug #37798: main.log_tables fails randomly on powermacg5 and windows
 slow_query_log_func.test              : Bug #37962: *_func tests containing sleeps/race conditions
 events-bugs.test                      : Bug #39848, Bug #39863, Bug #39569, Bug #37774
+limit                                 : Bug #37075 (fixed in 5.1.30)
+innodb_max_dirty_pages_pct_func       : Bug #40752 
+subselect_notembedded                 : Bug #40862 

I will experiment with the STACK_MIN_SIZE as well as STACK_BUFF_ALLOC after I get the thread_stack value for you.

Thank you.
[21 Nov 2008 20:45] BJ Dierkes
The following is the output from the test case after adding the show variables line:

show variables like 'thread_stack';
Variable_name   Value
thread_stack    196608
[22 Nov 2008 19:00] Joerg Bruehe
Ok, thanks for the info:

"thread_stack 196608" is what I expect, so the allocation of thread stack space seems to work correctly.

If test "execution_constants" passes, I take this to mean that recognizing a stack overflow works as designed, the command is aborted without the server crashing (see bug#21476 for more discussions).

So unless varying STACK_MIN_SIZE and STACK_BUFF_ALLOC yields some result, I am at a loss.

I fear we don't have a RedHat 5 machine patched to RH 5.2 - that's how I understand your description.
[25 Nov 2008 0:39] BJ Dierkes
OK...  I think you can halt concern on this.  I was just able to successfully build on EL5 i386 and the subselect_notembedded test passed successfully.  The original builds were via the Fedora Mock Utility (as is every other build we do).  Building this in a true el5 install the tests were all successful.

I apologize for any inconvenience... I'm still concerned why the test fails, but if you are unable to reproduce it then I will say it is likely something to due with the Mock environment.
[24 Jan 2009 19:29] Kent Boortz
In building 5.1.31 this failure is seen on HP-UX 11.23, HP-UX 11.31,
SLES10, RHEL4 and RHEL5.
[4 Mar 2009 21:22] BJ Dierkes
Verified to fail on Redhat Enterprise Linux 5 32bit....  MySQL 5.1.32