List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:September 7 2007 9:01pm
Subject:Re: bk commit into 5.1 tree (svoj:1.2569) BUG#30583
View as plain text  
Hi!

On Sep 06, Sergey Vojtovich wrote:
> ChangeSet@stripped, 2007-09-06 17:05:07+05:00, svoj@stripped +3 -0
>   BUG#30583 - Partition on DOUBLE key + INNODB + count(*) == crash
>   
>   Issuing SELECT COUNT(*) against partitioned InnoDB table may cause
>   server crash.
>   
>   Fixed that not all required fields were included into read_set.
> 
> diff -Nrup a/sql/ha_partition.cc b/sql/ha_partition.cc
> --- a/sql/ha_partition.cc	2007-08-02 09:50:52 +05:00
> +++ b/sql/ha_partition.cc	2007-09-06 17:05:05 +05:00
> @@ -3324,6 +3324,24 @@ int ha_partition::index_init(uint inx, b
>    */
>    if (m_lock_type == F_WRLCK)
>      bitmap_union(table->read_set, &m_part_info->full_part_field_set);
> +  else if (!(m_table_flags & HA_STATS_RECORDS_IS_EXACT) &&
> +           m_table_flags & HA_PARTIAL_COLUMN_READ)

1.  Why HA_STATS_RECORDS_IS_EXACT ? Your test case uses COUNT(*) but I
doubt it's the only scenario when ha_partition will decide to do an
ordered scan and read_set will be lacking necessary columns.

2. You need to check for 'sorted' - if it's false, ha_partition will do
unordered scan, and as far as I understand there will be no need to
modify read_set.

> +  {
> +    /*
> +      We may get empty read_set for engines that support partial column
> +      read and ::info doesn't return exact row count. This may happen
> +      e.g. with SELECT COUNT(*) FROM t1. We must ensure that all columns
> +      of current key are included into read_set, as partitioning requires
> +      them for sorting (see ha_partition::handle_ordered_index_scan).

Too specific. It should not mention COUNT(*) and ::info(), but describe
a generic situation - a ordered scan is requested and necessary fields
aren't in read_set (you can add "for example this can happen in COUNT(*)
queries, see the test for bug#...").

> +      TODO: optimize this workaround away from here, as we actually do not
> +      need to perform ordered index scan in this case.

Wrong comment. I agree that COUNT(*) should be optimized not to request
ordered scan, but this fix should not be removed anyway as - see above -
there could be other cases when an ordered scan is requested and
necessary fields aren't in read_set.

> +    */
> +    uint i;
> +    for (i= 0; i < m_curr_key_info->key_parts; i++)
> +      bitmap_set_bit(table->read_set,
> +                     m_curr_key_info->key_part[i].field->field_index);
> +  }
>    file= m_file;
>    do
>    {
> 
Regards / Mit vielen Grüssen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Developer
/_/  /_/\_, /___/\___\_\___/  MySQL GmbH, Dachauer Str. 37, D-80335 München
       <___/                  Geschäftsführer: Kaj Arnö - HRB
München 162140
Thread
bk commit into 5.1 tree (svoj:1.2569) BUG#30583Sergey Vojtovich6 Sep
  • Re: bk commit into 5.1 tree (svoj:1.2569) BUG#30583Sergei Golubchik7 Sep