Bug #11268 select with datetime + interval crashes mysql server
Submitted: 12 Jun 2005 10:55 Modified: 14 Jun 2005 9:39
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.10a-pro-gpl-log certified OS:Linux (REDHAT ES 3 update 4)
Assigned to: CPU Architecture:Any

[12 Jun 2005 10:55] [ name withheld ]
Description:
We have a year subscription of mysql network and we have
this crash on our production ecommerce database

The firts time we execute this select (later in the log error)
works well but later it crashes the mysql server always

Select with this:
min(ecdatv) + interval stgmt hour
crashes mysql server 

ecdatv: datetime
stgmt :integer
----------------------------------------------
Client : Windows2000 + MySQLODBC 3.51.11

This select crashes always with 4.1.10a-pro certified on differents
server installations (not depends on hardware)

-----------------
stack trace

0x814eb9a handle_segfault + 458
0xc32e58 (?)
0x91e38f8 _end + 13554568
0x8191cca _Z9do_selectP4JOINP4ListI4ItemEP8st_tableP9Procedure + 938
0x8187623 _ZN4JOIN4execEv + 3811
0x8187e5c _Z12mysql_selectP3THDPPP4ItemP13st_table_listjR4ListIS1_ES2_jP8st_orderSB_S2_SB_mP13select_resultP18st_select_lex_unitP13st_sel + 364
0x8208aa6 _ZN18st_select_lex_unit4execEv + 1158
0x8207558 _Z11mysql_unionP3THDP6st_lexP13select_resultP18st_select_lex_unit + 88
0x81847b9 _Z13handle_selectP3THDP6st_lexP13select_result + 57
0x81634f5 _Z21mysql_execute_commandP3THD + 1237
0x81686e0 _Z11mysql_parseP3THDPcj + 208
0x8161e97 _Z16dispatch_command19enum_server_commandP3THDPcj + 967
0x8161a76 _Z10do_commandP3THD + 134
0x816124c handle_one_connection + 860
0xc2cdec (?)
0x1eda2a (?)

----------------------------------

Version: '4.1.10a-pro-gpl-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Pro Certified Server (GPL)
mysqld got signal 11;
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=67108864
read_buffer_size=126976
max_used_connections=1
max_connections=100
threads_connected=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 103535 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x9333248
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...
Cannot determine thread, fp=0x350b1c, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x814eb9a
0x707e58
0x93f78f8
0x8191cca
0x8187623
0x8187e5c
0x8208aa6
0x8207558
0x81847b9
0x81634f5
0x81686e0
0x8161e97
0x8161a76
0x816124c
0x701dec
0x202a2a
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/Using_stack_trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do 
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x9367090 = select  ecsist, ecdesc, rtprov, nvtipo, eccont, count(ecdesc) as total, nvnent, ecflg3,     
      ecactv, coimap, eccpel, nvfnov        
          , min(ecdatv) + interval stgmt hour as ecdatv        
     from gtnove nove, pfcfunc, pfsistema, pfrcnto
           left join gtconte on coid = eccont and cosist = ecsist and coidi = 'E' 
    where ecsist = nvsist
      and ecdesc = nvdesc
      and ecsist = stsist 
      and rtsist = ecsist 
      and rtrcto = ectipo
      and ecauto = 1      
      and ecprox <> 'N'      
        and stcdom = 'KTX'      
        and substr(ecactv, 1,1) <> 'Z'      
        and (nvfnov > '2005-06-10 13:20:00' - interval 2 day or ecdatv >= '2005-06-10 13:20:00')
        and ecdate >= '2005-06-10 13:20:00'
    group by ecsist, ecdesc, rtprov, nvtipo, eccont, nvnent, ecflg3, ecactv, coimap, eccpel, nvfnov  
    union  
     select distinct acsist as ecsist, acvar
thd->thread_id=1
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.
050610 13:20:49  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
050610 13:20:49  InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 1861881492.
InnoDB: Doing recovery: scanned up to log sequence number 0 1861881526
InnoDB: Last MySQL binlog file position 0 79, file name ./gt_binario.000009
050610 13:20:49  InnoDB: Flushing modified pages from the buffer pool...
050610 13:20:49  InnoDB: Started; log sequence number 0 1861881526
/usr/sbin/mysqld: ready for connections. 

How to repeat:
This select always crashes mysql server

We suspect that the problem is 
min(ecdatv) + interval stgmt

select  ecsist, ecdesc, rtprov, nvtipo, eccont, count(ecdesc) as total, nvnent, ecflg3,     
      ecactv, coimap, eccpel, nvfnov        
          , min(ecdatv) + interval stgmt hour as ecdatv        
     from gtnove nove, pfcfunc, pfsistema, pfrcnto
           left join gtconte on coid = eccont and cosist = ecsist and coidi = 'E' 
    where ecsist = nvsist
      and ecdesc = nvdesc
      and ecsist = stsist 
      and rtsist = ecsist 
      and rtrcto = ectipo
      and ecauto = 1      
      and ecprox <> 'N'      
        and stcdom = 'KTX'      
        and substr(ecactv, 1,1) <> 'Z'      
        and (nvfnov > '2005-06-10 13:20:00' - interval 2 day or ecdatv >= '2005-06-10 13:20:00')
        and ecdate >= '2005-06-10 13:20:00'
    group by ecsist, ecdesc, rtprov, nvtipo, eccont, nvnent, ecflg3, ecactv, coimap, eccpel, nvfnov  
    union  
     select distinct acsist as ecsist, acvar
[12 Jun 2005 18:33] MySQL Verification Team
This bug looks like a duplicate of http://bugs.mysql.com/bug.php?id=9577 (UNION ALL with + INTERVAL N DAY crashes server)
[12 Jun 2005 19:08] [ name withheld ]
Yes, it seems like bug #9577
http://bugs.mysql.com/bug.php?id=9577

but this bug is on latest certified stable  Mysql binary (4.1.10a-pro-gpl)

Will be this bug  be resolved on the next certified versions of 4.1.x  like version 5.0.4, or is it  resolved on the lastest 4.1.12 version ?
[14 Jun 2005 9:39] MySQL Verification Team
I tested this with latest 4.1 BK tree and wasn't able reprode server crash too. So I close this bug report now.