Bug #32374 crash with filesort when selecting from federated table and view
Submitted: 14 Nov 2007 13:58 Modified: 14 Jan 2008 19:32
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S1 (Critical)
Version:5.0.50, 5.1.23, 6.0.3 OS:Any
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: bfsm_2007_12_06

[14 Nov 2007 13:58] Shane Bester
Description:
Stack trace of a crash that occurred during filesort of data from a view->federated table:

mysqld-nt.exe!ptr_compare_1
mysqld-nt.exe!queue_insert
mysqld-nt.exe!merge_buffers
mysqld-nt.exe!filesort
mysqld-nt.exe!create_sort_index
mysqld-nt.exe!JOIN::exec
mysqld-nt.exe!mysql_select
mysqld-nt.exe!handle_select
mysqld-nt.exe!mysql_execute_command
mysqld-nt.exe!mysql_parse
mysqld-nt.exe!dispatch_command
mysqld-nt.exe!do_command
mysqld-nt.exe!handle_one_connection
mysqld-nt.exe!pthread_start
mysqld-nt.exe!_threadstart

How to repeat:
see private section. public testcase will come later.
[30 Nov 2007 11:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38946

ChangeSet@1.2576, 2007-11-30 15:15:49+04:00, holyfoot@mysql.com +4 -0
  Bug #32374 crash with filesort when selecting from federated table and view.
  
  filesort() uses file->estimate_rows_upper_bound() call to allocate
  internal buffers. If this function returns a value smaller than
  a number of row that will be returned later in find_all_keys(),
  that can cause server crash.
  Fixed by implementing ha_federated::estimate_rows_upper_bound() to
  return maximum possible number of rows.
  Technically we can estimate the number of FEDERATED rows more precisely,
  but this number can change in the remote table after that before we
  retrive all the records.
[30 Nov 2007 13:14] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38958

ChangeSet@1.2576, 2007-11-30 17:08:00+04:00, holyfoot@mysql.com +4 -0
  Bug #32374 crash with filesort when selecting from federated table and view.
  
  filesort() uses file->estimate_rows_upper_bound() call to allocate
  internal buffers. If this function returns a value smaller than
  a number of row that will be returned later in find_all_keys(),
  that can cause server crash.
  Fixed by implementing ha_federated::estimate_rows_upper_bound() to
  return maximum possible number of rows.
  Present estimation for FEDERATED always returns 0 if the linked to the VIEW.
[14 Dec 2007 8:15] Bugs System
Pushed into 5.0.54
[14 Dec 2007 8:19] Bugs System
Pushed into 5.1.23-rc
[14 Dec 2007 8:22] Bugs System
Pushed into 6.0.5-alpha
[14 Jan 2008 19:32] Jon Stephens
Documented in the 5.0.54, 5.1.23, and 6.0.5 changelogs as follows:

        An ORDER BY query on a view created using a FEDERATED table as a
        base table caused the server to crash.