Commit graph

321 commits

Author SHA1 Message Date
Mattias Jonsson
aefbea7d0b Post push fix for bug#11766249 bug#59316
Partitions can have different ref_length (position data length).
Removed DBUG_ASSERT which crashed debug builds when using
MAX_ROWS on some partitions.
2011-04-27 17:51:06 +02:00
Mattias Jonsson
0ef0c541af post fix for werror build for bug#11766249. 2011-04-26 10:21:09 +02:00
Mattias Jonsson
002426a9eb merge 2011-04-20 18:00:50 +02:00
Mattias Jonsson
f6641998be Bug#11766249 bug#59316: PARTITIONING AND INDEX_MERGE MEMORY LEAK
Update for previous patch according to reviewers comments.

Updated the constructors for ha_partitions to use the common
init_handler_variables functions

Added use of defines for size and offset to get better readability for the code that reads
and writes the .par file. Also refactored the get_from_handler_file function.
2011-04-20 17:52:33 +02:00
Mattias Jonsson
a6b70da9a3 Bug#11766249 bug#59316: PARTITIONING AND INDEX_MERGE MEMORY LEAK
When executing row-ordered-retrieval index merge,
the handler was cloned, but it used the wrong
memory root, so instead of allocating memory
on the thread/query's mem_root, it used the table's
mem_root, resulting in non released memory in the
table object, and was not freed until the table was
closed.

Solution was to ensure that memory used during cloning
of a handler was allocated from the correct memory root.

This was implemented by fixing handler::clone() to also
take a name argument, so it can be used with partitioning.
And in ha_partition only allocate the ha_partition's ref, and
call the original ha_partition partitions clone() and set at cloned
partitions.

Fix of .bzrignore on Windows with VS 2010
2011-03-25 12:36:02 +01:00
Mattias Jonsson
fd5782dca7 Bug#59297: Can't find record in 'tablename' on update inner join
Regression introduced in bug#52455. Problem was that the
fixed function did not set the last used partition variable, resulting
in wrong partition used when storing the position of the newly
retrieved row.

Fixed by setting the last used partition in ha_partition::index_read_idx_map.
2011-01-24 13:41:44 +01:00
Georgi Kodinov
c5987223db merge 2010-11-26 14:51:48 +02:00
Mattias Jonsson
a58527deec Bug#57890: Assertion failed: next_insert_id == 0
with on duplicate key update

There was a missed corner case in the partitioning
handler, which caused the next_insert_id to be changed
in the second level handlers (i.e the hander of a partition),
which caused this debug assertion.

The solution was to always ensure that only the partitioning
level generates auto_increment values, since if it was done
within a partition, it may fail to match the partition
function.
2010-11-11 11:34:55 +01:00
Alexey Botchkov
5f06f44f8b merging. 2010-10-15 20:13:35 +05:00
Mattias Jonsson
2246f67f7a merge 2010-10-15 09:27:28 +02:00
Mattias Jonsson
cddd0d685f merge 2010-10-01 15:41:27 +02:00
Mattias Jonsson
460fcf7c5e merge 2010-10-01 13:39:49 +02:00
Mattias Jonsson
a01773dbee Bug#51851: Server with SBR locks mutex twice on
LOAD DATA into partitioned MyISAM table

Problem was that both partitioning and myisam
used the same table_share->mutex for different protections
(auto inc and repair).

Solved by adding a specific mutex for the partitioning
auto_increment.

Also adding destroying the ha_data structure in
free_table_share (which is to be propagated
into 5.5).

This is a 5.1 ONLY patch, already fixed in 5.5+.
2010-10-01 13:39:04 +02:00
Mattias Jonsson
d7bfd59a5a Bug#55458: Partitioned MyISAM table gets crashed by multi-table update
Bug#57113: ha_partition::extra(ha_extra_function):
            Assertion `m_extra_cache' failed

Fix for bug#55458 included DBUG_ASSERTS causing
debug builds of the server to crash on
another multi-table update.

Removed the asserts since they where wrong.
(updated after testing the patch in 5.5).
2010-09-30 15:57:33 +02:00
Mattias Jonsson
1387f38969 Bug#56287: mysql5.1.50 crash when using Partition datetime in sub in query
When having a sub query in partitioned innodb one could
make the partitioning engine to search for a 'index_next_same'
on a partition that had not been initialized.

Problem was that the subselect function looks at table->status
which was not set in the partitioning handler when it skipped
scanning due to no matching partitions found.

Fixed by setting table->status = STATUS_NOT_FOUND when
there was no partitions to scan. (If there are partitions to
scan, it will be set in the partitions handler.)
2010-09-16 11:01:06 +02:00
Mattias Jonsson
063a34b681 Bug#55458: Partitioned MyISAM table gets crashed by multi-table update
Updated according to reviewers comments.
2010-09-07 17:56:43 +02:00
Mattias Jonsson
89d7ac6007 merge 2010-08-19 09:20:17 +02:00
Mattias Jonsson
a30b3b43d6 merge 2010-09-10 11:52:35 +02:00
Alexey Botchkov
e1d54fc7a8 Bug#55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map
As we check for the impossible partitions earlier, it's possible that we don't find any
              suitable partitions at all. So this assertion just has to be corrected for this case.
      
per-file comments:
mysql-test/r/partition_innodb.result
Bug#55146      Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map
        test result updated.

mysql-test/t/partition_innodb.test
Bug#55146      Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map
        test case added.

sql/ha_partition.cc
Bug#55146      Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map
        Assertion changed to '>=' as the  prune_partition_set() in the get_partition_set() can
        do start_part= end_part+1 if no possible partitions were found.
2010-08-12 15:59:02 +05:00
Mattias Jonsson
5bde03c8e1 Bug#55458: Partitioned MyISAM table gets crashed by multi-table update
Problem was that the handler call ::extra(HA_EXTRA_CACHE) was cached
but the ::extra(HA_EXTRA_PREPARE_FOR_UPDATE) was not.

Solution was to also cache the other call and forward it when moving
to a new partition to scan.
2010-08-10 10:43:12 +02:00
Mattias Jonsson
0b273845de Bug#46086: crash when dropping a partitioned table
and the original engine is disabled

Missing check that engine is available.
2010-07-08 14:36:55 +02:00
Mattias Jonsson
e13405a79f Bug#52455: Subpar INSERT ON DUPLICATE KEY UPDATE performance with many partitions
The handler function for reading one row from a specific index
was not optimized in the partitioning handler since it
used the default implementation.

No test case since it is performance only, verified by hand.
2010-07-09 01:09:31 +02:00
Mattias Jonsson
ff36f028c3 Bug#49161: Out of memory; restart server and try again (needed 2 bytes)
Problem was reporting wrong error

Fixed by adding a new error which better explain the problem.
2010-05-25 15:41:00 +02:00
Mattias Jonsson
ae171f1e40 merge into mysql-5.1-bugteam 2010-05-21 14:18:14 +02:00
Mattias Jonsson
3b897f2bc5 Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with
concurrent I_S query

There were two problem:
1) MYSQL_LOCK_IGNORE_FLUSH also ignored name locks
2) there was a race between abort_and_upgrade_locks and
   alter_close_tables
   (i.e. remove_table_from_cache and
    close_data_files_and_morph_locks)

Which allowed the table to be opened with MYSQL_LOCK_IGNORE_FLUSH flag
resulting in renaming a partition that was already in use,
which could cause the table to be unusable.

Solution was to not allow IGNORE_FLUSH to skip waiting for
a named locked table.

And to not release the LOCK_open mutex between the
calls to remove_table_from_cache and
close_data_files_and_morph_locks by merging the functions
abort_and_upgrade_locks and alter_close_tables.
2010-03-17 15:10:41 +01:00
Mattias Jonsson
da26454dcb merged 2010-03-12 11:14:40 +01:00
Mattias Jonsson
cb6d0e3cac merge 2010-03-11 14:18:44 +01:00
Mattias Jonsson
25596746db Bug#50392: insert_id is not reset for partitioned tables
auto_increment on duplicate entry

The bug was that when INSERT_ID was used and the storage
engine was told to release any reserved but not used
auto_increment values, it set the highest auto_increment
value to INSERT_ID.

The fix was to check if the auto_increment value was forced
by user (INSERT_ID) or by slave-thread, i.e. not auto-
generated. So that it is only allowed to release generated
values.
2010-03-04 18:16:10 +01:00
Mattias Jonsson
2d5c6b5bfe Bug#48229: group by performance issue of partitioned table
Problem was block_size on partitioned tables was not set,
resulting in keys_per_block was not correct which affects
the cost calculation for read time of indexes (including
cost for group min/max).Which resulted in a bad optimizer
decision.

Fixed by setting stats.block_size correctly.
2010-03-04 12:09:09 +01:00
Mattias Jonsson
252db713c9 Manual merge (moved the check for log_table before name lock) 2010-02-12 10:03:10 +01:00
Mattias Jonsson
54c076e984 Bug#42438: Crash ha_partition::change_table_ptr
There was two problems:
The first was the symptom, caused by bad error handling in
ha_partition. It did not handle print_error etc. when
having no partitions (when used by dummy handler).

The second was the real problem that when dropping tables
it reused the table type (storage engine) from when the lock
was asked for, not the table type that it had when gaining
the exclusive name lock. So that it tried to delete tables
from wrong storage engines.

Solutions for the first problem was to accept some handler
calls to the partitioning handler even if it was not setup
with any partitions, and also if possible fallback
to use the base handler's default functions.

Solution for the second problem was to remove the optimization
to reuse the definition from the cache, instead always check
the frm-file when holding the LOCK_open mutex

(updated with a fix for a debug print crash and better
comments as required by reviewer, and removed optimization
to avoid reading the frm-file).
2010-02-01 16:07:00 +01:00
Mattias Jonsson
fdf1441a5a post-push patch for bug#47343.
Missing ha_rnd_end in copy_partitions, found due to a
DBUG_ASSERT in mysql-pe
2010-01-19 17:02:51 +01:00
Mattias Jonsson
b1987bdcbf Bug#47343: InnoDB fails to clean-up after lock wait timeout on
REORGANIZE PARTITION

There were several problems which lead to this this,
all related to bad error handling.

1) There was several bugs preventing the ddl-log to be used for
   cleaning up created files on error.

2) The error handling after the copy partition rows did not close
   and unlock the tables, resulting in deletion of partitions
   which were in use, which lead InnoDB to put the partition to
   drop in a background queue.
2010-01-18 17:49:18 +01:00
Mattias Jonsson
f86c438f7c Bug#48846: Too much time spent in ha_partition::records_in_range if not able to prune
Problem was that ha_partition::records_in_range called
records_in_range for all non pruned partitions, even if
an estimate should be given.

Solution is to only use 1/3 of the partitions (up to 10) for
records_in_range and estimate the total from this subset.
(And continue until a non zero return value from the called
partitions records_in_range is given, since 0 means no rows
will match.)
2009-11-17 20:02:16 +01:00
Mattias Jonsson
cd73187378 merge into mysql-5.1-bugteam 2009-10-09 09:56:07 +02:00
Mattias Jonsson
27b80f9db8 Bug#44059: Incorrect cardinality of indexes on a partitioned table
backport for bug#44059 from mysql-pe to mysql-5.1-bugteam

Using the partition with most rows instead of first partition
to estimate the cardinality of indexes.
2009-10-08 15:58:17 +02:00
Mattias Jonsson
87a4644db8 Bug#46922: crash when adding partitions and open_files_limit
is reached

Problem was bad error handling, leaving some new temporary
partitions locked and initialized and some not yet initialized
and locked, leading to a crash when trying to unlock the not
yet initialized and locked partitions

Solution was to unlock the already locked partitions, and not
include any of the new temporary partitions in later unlocks
2009-10-08 15:36:43 +02:00
Staale Smedseng
8b9843408d Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2

Cleaning up warnings not present in 5.0.
2009-09-23 15:21:29 +02:00
Anurag Shekhar
05bf2ebaa8 Bug #45840 read_buffer_size allocated for each partition when
"insert into.. select * from"

When inserting into a partitioned table using 'insert into
<target> select * from <src>', read_buffer_size bytes of memory
are allocated for each partition in the target table.

This resulted in large memory consumption when the number of
partitions are high.

This patch introduces a new method which tries to estimate the
buffer size required for each partition and limits the maximum
buffer size used to maximum of 10 * read_buffer_size, 
11 * read_buffer_size in case of monotonic partition functions.
2009-09-17 17:35:43 +05:30
Mattias Jonsson
3174c31dfc merge 2009-09-12 00:40:23 +02:00
Mikael Ronstrom
6a368130ae Automerge 2009-09-07 12:22:57 +02:00
Mikael Ronstrom
ea5d204370 Fix to ensure that all subpartitions gets deleted before renaming starts, BUG#47029 2009-09-07 10:37:54 +02:00
Mattias Jonsson
cc900f2c50 Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions
(Backport)

Problem is that when insert (ha_start_bulk_insert) in i partitioned table,
it will call ha_start_bulk_insert for every partition, used or not.

Solution is to delay the call to the partitions ha_start_bulk_insert until
the first row is to be inserted into that partition
2009-09-04 15:02:15 +02:00
V Narayanan
097023fee7 Bug#45823 Assertion failure in file row/row0mysql.c line 1386
Inserting a negative value in the autoincrement column of a
partitioned innodb table was causing the value of the auto
increment counter to wrap around into a very large positive
value. The consequences are the same as if a very large positive
value was inserted into a column, e.g. reduced autoincrement
range, failure to read autoincrement counter.

The current patch ensures that before calculating the next
auto increment value, the current value is within the positive
maximum allowed limit.
2009-09-04 09:27:11 +05:30
Mattias Jonsson
586ee5d616 Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...

Problem was that when bulk insert is used on an empty
table/partition, it disables the indexes for better
performance, but in this specific case it also tries
to read from that partition using an index, which is
not possible since it has been disabled.

Solution was to allow index reads on disabled indexes
if there are no records.

Also reverted the patch for bug#38005, since that was a workaround
in the partitioning engine instead of a fix in myisam.
2009-08-21 17:38:29 +02:00
Satya B
ad951044e0 Fix for BUG#45816 - assertion failure with index containing double
column on partitioned table
      
      
An assertion 'ASSERT_COULUMN_MARKED_FOR_READ' is failed if the query 
is executed with index containing double column on partitioned table.
The problem is that assertion expects all the fields which are read,
to be in the read_set.
      
In this query only the field 'a' is in the readset as the tables in
the query are joined by the field 'a' and so the assertion fails 
expecting other field 'b'.
      
Since the function cmp() is just comparison of two parameters passed, 
the assertion is not required.
      
Fixed by removing the assertion in the double fields comparision
function and also fixed the index initialization to do ordered
index scan with RW LOCK which ensures all the fields from a key are in
the read_set.
 

Note: this bug is not reproducible with other datatypes because the
      assertion doesn't exist in comparision function for other 
      datatypes.
2009-08-06 17:01:26 +05:30
Tatiana A. Nurnberg
b925e40fc0 auto-merge 2009-07-31 21:58:40 +02:00
Tatiana A. Nurnberg
f6b8b9d2f8 Bug#40281, partitioning the general log table crashes the server
We disallow the partitioning of a log table. You could however
partition a table first, and then point logging to it. This is
not only against the docs, it also crashes the server.

We catch this case now.
2009-07-31 14:38:18 +02:00
Anurag Shekhar
4e1ec3bb0b Bug#30102: Rename table does corrupt tables with partition files on failure
Problem was that a failing rename just left the partitions at the state
it was at the failure.

Solution was to try to revert the started rename if a failure occured.
2009-07-24 15:41:23 +05:30
Satya B
77f7311673 Bug#35111 - Truncate a MyISAM partitioned table does not reset
the auto_increment value
      
This is an alternative patch that instead of allowing RECREATE TABLE
on TRUNCATE TABLE it implements reset_auto_increment that is called
after delete_all_rows.

Note: this bug was fixed by Mattias Jonsson:
Pusing this patch: http://lists.mysql.com/commits/70370
2009-07-08 17:41:34 +05:30