Commit graph

483 commits

Author SHA1 Message Date
Marko Makela
ff906f032f Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1 CAUSES INFINITE PAGE SPLIT
The debug configuration parameter innodb_optimistic_insert_debug
which was introduced for testing corner cases in B-tree handling
had a bug in it. The value 1 would trigger an infinite sequence
of page splits.

Fix: When the value 1 is specified, disable this debug feature.
Approved by Yasufumi Kinoshita
2014-10-30 08:53:46 +02:00
Annamalai Gurusami
db78f29b31 Bug #19306524 FAILING ASSERTION WITH TEMP TABLE FOR A PROCEDURE CALLED
FROM A FUNCTION

Scenario:

In a stored procedure, CREATE TABLE statement is not allowed.  But an
exception is provided for CREATE TEMPORARY TABLE.  We can create a temporary
table in a stored procedure.

Let there be two stored functions f1 and f2 and two stored procedures p1 and
p2.  Their properties are as follows:

. stored function f1() calls stored procedure p1().
. stored function f2() calls stored procedure p2().
. stored procedure p1() creates temporary table t1.
. stored procedure p2() does DML on t1.

Consider the following situation:

1.  Autocommit mode is on. 
2.  select f1()
3.  select f2()

Step 2:  In this step, t1 would be created via p1().  A table level transaction
lock would have been taken.  The ::external_lock() would not have been called
on this table.  At the end of step 2, because of autocommit mode on, this table
level lock will be released.

Step 3:  When we execute DML on table t1 via p2() we have two problems:

Problem 1:

The function ha_innobase::external_lock() would have been called but since
it is a select query no table level locks would have been taken.  Hence the
following assert will fail:

ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));

Solution:

The solution would be to identify this situation and take a table level lock
and use the proper lock type prebuilt->select_lock_type = LOCK_X for DML
operations.

Problem 2:

Another problem is that in step 3, ha_innobase::open() is never called on
the table t1.  

Solution:

The solution would be to identify this situation and call re-init the handler
of table t1.

rb#6429 approved by Krunal.
2014-09-18 15:17:39 +05:30
Annamalai Gurusami
ada5a9a2cf Bug #18806829 OPENING INNODB TABLES WITH MANY FOREIGN KEY REFERENCES IS
SLOW/CRASHES SEMAPHORE

Problem:

There are 2 lakh tables - fk_000001, fk_000002 ... fk_200000.  All of them
are related to the same parent_table through a foreign key constraint.
When the parent_table is loaded into the dictionary cache, all the child table
will also be loaded.  This is taking lot of time.  Since this operation happens
when the dictionary latch is taken, the scenario leads to "long semaphore wait"
situation and the server gets killed.

Analysis:

A simple performance analysis showed that the slowness is because of the
dict_foreign_find() function.  It does a linear search on two linked list
table->foreign_list and table->referenced_list, looking for a particular
foreign key object based on foreign->id as the key.  This is called two
times for each foreign key object.

Solution:

Introduce a rb tree in table->foreign_rbt and table->referenced_rbt, which
are some sort of index on table->foreign_list and table->referenced_list
respectively, using foreign->id as the key.  These rbt structures will be
solely used by dict_foreign_find().  

rb#5599 approved by Vasil
2014-06-10 09:35:50 +05:30
Mattias Jonsson
aceb173714 post-push fix for bug17565888. 2013-10-19 15:29:51 +02:00
Mattias Jonsson
6be5ea37d0 post-push fix for bug17565888.
Too restrictive assertion, failing during purge
2013-10-18 23:49:35 +02:00
Mattias Jonsson
4ff62c01ce post-push fix for bug17565888.
Too restrictive assertion, can fail during purge
2013-10-18 23:39:15 +02:00
Mattias Jonsson
f4fd68857b Bug#17565888: UP TO 75% INCREASE IN DBT3 QUERY (Q7) EXECUTION TIME
Regression from bug#14621190 due to disabled optimistic restoration
of cursor, which required full key lookup instead of verifying
if previously positioned btree cursor could be reused.

Fixed by enable optimistic restore and adjust cursor afterward.

rb#3324 approved by Marko.
2013-10-18 19:25:59 +02:00
Anil Toshniwal
ccfd3a0e75 Bug#17513737 INTRODUCE CHECK TABLE...QUICK
--Implemented CHECK TABLE...QUICK.
  Introduce CHECK TABLE...QUICK that would skip the btr_validate_index()
  and btr_search_validate() call, and count the no. of records in each index.

Approved by Marko and Kevin. (rb#3567).
2013-10-17 18:09:04 +05:30
Yasufumi Kinoshita
47312f19cb Bug#11758196 : INNODB ASSERTION FAILURE WHEN CONVERTING FROM MYISAM TO INNODB
Changed to try to extend log buffer instead of crash, when log size is too large for the size.

Approved by Marko in rb#3229
2013-09-30 13:41:48 +09:00
Satya Bodapati
57df886c9f Merge fix for BUG#17446090 from mysql-5.1 to mysql-5.5
The testcase for this bug fails randomly due to two reasons.
1. Due to ibuf merge happening background
2. Due to dict stats update which brings the evicted page back into
   buffer pool.

Fix ibuf_contract_ext() to not do any merges with ibuf_debug enabled and
also changed dict_stats_update() to return fake statistics without
bringing the secondary index pages into buffer pool.

Approved by Marko. rb#3419
2013-09-27 18:32:13 +05:30
Satya Bodapati
b904197361 Additional Fix to BUG#16755251 for 5.1 build failure and
disable testcase due to BUG#17446090
2013-09-12 12:28:16 +05:30
Satya Bodapati
f166ec71b7 Bug#16752251 - INNODB DOESN'T REDO-LOG INSERT BUFFER MERGE OPERATION IF
IT IS DONE IN-PLACE

With change buffer enabled, InnoDB doesn't write a transaction log
record when it merges a record from the insert buffer to an secondary
index page if the insertion is performed as an update-in-place.

Fixed by logging the 'update-in-place' operation on secondary index
pages.

Approved by Marko. rb#2429
2013-09-11 16:57:02 +05:30
Satya Bodapati
9910b732a7 Merge fix for BUG#16752251 from mysql-5.1 to mysql-5.5 2013-09-11 17:02:18 +05:30
bin.x.su@oracle.com
7b66df16a1 Bug 16876388 - PLEASE BACKPORT BUG#16208542 TO 5.5
Straight forward backport.

Approved by Jimmy, rb#2656
2013-06-25 09:42:54 +08:00
Murthy Narkedimilli
cf2d852653 Fixing the bug 16919882 - WRONG FSF ADDRESS IN LICENSES HEADERS 2013-06-10 22:29:41 +02:00
Murthy Narkedimilli
8325f2cf78 Bug 16919882 - WRONG FSF ADDRESS IN LICENSES HEADERS 2013-06-11 01:13:07 +05:30
Annamalai Gurusami
78a9e05080 Merge from mysql-5.1 to mysql-5.5 2013-05-06 19:57:49 +05:30
Annamalai Gurusami
068e6673a0 Bug #16722314 FOREIGN KEY ID MODIFIED DURING EXPORT
Bug #16754901 PARS_INFO_FREE NOT CALLED IN DICT_CREATE_ADD_FOREIGN_TO_DICTIONARY

Problem:

There are two situations here.  The constraint name is explicitly
given by the user and the constraint name is automatically generated
by InnoDB.  In the case of generated constraint name, it is formed by
adding table name as prefix.  The table names are stored internally in
my_charset_filename.  In the case of constraint name explicitly given
by the user, it is stored in UTF8 format itself.  So, in some
situations the constraint name is in utf8 and in some situations it is
in my_charset_filename format.  Hence this problem.

Solution:

Always store the foreign key constraint name in UTF-8 even when
automatically generated.

Bug #16754901 PARS_INFO_FREE NOT CALLED IN DICT_CREATE_ADD_FOREIGN_TO_DICTIONARY

Problem:

There was a memory leak in the function dict_create_add_foreign_to_dictionary().
The allocated pars_info_t object is not freed in the error code path.

Solution:

Allocate the pars_info_t object after the error checking.

rb#2368 in review
2013-05-06 16:28:56 +05:30
Marko Mäkelä
3c50661f41 Bug#16720368 INNODB IGNORES *.IBD FILE BREAKAGE AT STARTUP
After a clean shutdown, InnoDB will not check the *.ibd file headers,
for maximum performance. This is unchanged before and after this
patch.

What this fix addresses is the case when crash recovery is
needed. Previously, InnoDB could load a corrupted tablespace file.

buf_page_is_corrupted(): Add the parameter check_lsn.

fil_check_first_page(): New function, to perform a consistency check
on the first page of a file. This can be overridden by setting
innodb_force_recovery.

fil_read_first_page(), fil_open_single_table_tablespace(),
fil_load_single_table_tablespace(): Invoke fil_check_first_page().

open_or_create_data_files(): Check the status of
fil_open_single_table_tablespace().

rb#2352 approved by Jimmy Yang
2013-04-30 13:39:50 +03:00
Annamalai Gurusami
7fbd770c7c Merge from mysql-5.1 to mysql-5.5 2013-03-29 22:11:33 +05:30
Annamalai Gurusami
b00e1446dd Bug #16244691 SERVER GONE AWAY ERROR OCCURS DEPENDING ON THE NUMBER OF
TABLE/KEY RELATIONS

The DICT_FK_MAX_RECURSIVE_LOAD was reduced from 250 to 33 in rb#2058.
But in optimized build, this recursive depth is still too deep and
resulted in stack overflow.  So reducing this depth to 20 now.
2013-03-29 22:01:10 +05:30
Annamalai Gurusami
9d7f333a62 Bug #16244691 SERVER GONE AWAY ERROR OCCURS DEPENDING ON THE NUMBER OF
TABLE/KEY RELATIONS

Problem:

When there are many tables, linked together through the foreign key
constraints, then loading one table will recursively open other tables.  This
can sometimes lead to thread stack overflow.  In such situations the server
will exit.

I see the stack overflow problem when the thread_stack is 196608 (the default
value for 32-bit systems).  I don't see the problem when the thread_stack is
set to 262144 (the default value for 64-bit systems).

Solution:

Currently, in InnoDB, there is a macro DICT_FK_MAX_RECURSIVE_LOAD which defines
the maximum number of tables that will be loaded recursively because of foreign
key relations.  This is currently set to 250.  We can reduce this number to 33
(anything more than 33 does not solve the problem for the default value).  We
can keep it small enough so that thread stack overflow does not happen for the
default values.  Reducing the DICT_FK_MAX_RECURSIVE_LOAD will not affect the
functionality of InnoDB.  The tables will eventually be loaded. 

rb#2058 approved by Marko
2013-03-28 10:42:42 +05:30
Annamalai Gurusami
28f26d3e86 Merge from mysql-5.1 to mysql-5.5 2013-03-28 10:25:23 +05:30
Annamalai Gurusami
ff20c67fe4 Bug #16244691 SERVER GONE AWAY ERROR OCCURS DEPENDING ON THE NUMBER OF
TABLE/KEY RELATIONS

Problem:

When there are many tables, linked together through the foreign key
constraints, then loading one table will recursively open other tables.  This
can sometimes lead to thread stack overflow.  In such situations the server
will exit.

I see the stack overflow problem when the thread_stack is 196608 (the default
value for 32-bit systems).  I don't see the problem when the thread_stack is
set to 262144 (the default value for 64-bit systems).

Solution:

Currently, in InnoDB, there is a macro DICT_FK_MAX_RECURSIVE_LOAD which defines
the maximum number of tables that will be loaded recursively because of foreign
key relations.  This is currently set to 250.  We can reduce this number to 33
(anything more than 33 does not solve the problem for the default value).  We
can keep it small enough so that thread stack overflow does not happen for the
default values.  Reducing the DICT_FK_MAX_RECURSIVE_LOAD will not affect the
functionality of InnoDB.  The tables will eventually be loaded. 

rb#2058 approved by Marko
2013-03-27 11:11:38 +05:30
Murthy Narkedimilli
d978016d93 Fix for Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 15:53:48 +01:00
Murthy Narkedimilli
d20a70fb55 Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 13:29:12 +01:00
Vasil Dimov
90b3eefb32 Fix Bug#16400412 UNNECESSARY DICT_UPDATE_STATISTICS DURING CONCURRENT
UPDATES

After checking that the table has changed too much in
row_update_statistics_if_needed() and calling dict_update_statistics(),
also check if the same condition holds after acquiring the table stats
latch. This is to avoid multiple threads concurrently entering and
executing the stats update code.

Approved by:	Marko (rb:2186)
2013-03-18 17:20:30 +02:00
Marko Mäkelä
7f9ddb849b Merge mysql-5.1 to mysql-5.5. 2013-03-12 13:57:02 +02:00
Annamalai Gurusami
86a4272a72 Merge from mysql-5.1 to mysql-5.5. 2013-02-12 15:35:56 +05:30
Annamalai Gurusami
b39370bc93 Bug #11753153 INNODB GENERATES SYMBOLS THAT ARE TOO LONG, INVALID DDL
FROM SHOW CREATE

Problem: The length of the internally generated foreign key name 
is not checked. 

Solution: The length of the internally generated foreign key name is
checked.  If it is greater than the allowed limit, an error message
is reported. Also, the constraint name is printed in the same manner
as the table name, using the system charset information.

rb://1969 approved by Marko.
2013-02-12 14:52:48 +05:30
kevin.lewis@oracle.com
f3bfae1b67 Bug#16263506 - INNODB; USE ABORT() ON ALL PLATFORMS INSTEAD OF
DEREFERENCING UT_DBG_NULL_PTR
The abort() call is standard C but InnoDB only uses it in GCC
environments.  UT_DBG_USE_ABORT is not defined the code crashed
by dereferencing a null pointer instead of calling abort().
Other code throughout MySQL including ndb, sql, mysys and other
places call abort() directly.

This bug also affects innodb.innodb_bug14147491.test which fails
randomly on windows because of this issue. 

Approved by marko in http://rb.no.oracle.com/rb/r/1936/
2013-02-06 13:49:56 -06:00
Yasufumi Kinoshita
b6095e5d68 Merge mysql-5.1 to mysql-5.5. 2013-01-23 15:00:46 +09:00
Marko Mäkelä
d82eaad5fe Bug#16138582 MTR_MEMO_RELEASE AND DYN_ARRAY TOGETHER ARE VERY INEFFICIENT
Get rid of O(n^2) scan in dyn array (mtr->memo) operations, accessing
the dyn array blocks directly.

dyn_array_get_last_block(), dyn_array_get_next_block(),
dyn_array_get_prev_block(): Define as a constness-preserving macro.

Add const qualifiers to many dyn_array functions.

mtr_memo_slot_release_func(): Renamed from mtr_memo_slot_release():
Make mtr_t* a debug-only parameter. Assume that slot->object != NULL.

mtr_memo_pop_all(): Access the dyn_array blocks directly, replacing
O(n^2) operation with O(n).

mtr_memo_release(): Access the dyn_array blocks directly, replacing
O(n^2) operation with O(n). This caused the performance problem.

rb#1540 approved by Jimmy Yang
2013-01-17 17:30:13 +02:00
Vasil Dimov
328430b4a0 Merge mysql-5.1 -> mysql-5.5 2012-12-18 16:52:58 +02:00
Bill Qu
f3eea3fd60 Approved by Jimmy and Inaam. rb#1576 2012-12-17 23:13:46 +08:00
Yasufumi Kinoshita
eb6a89b4d1 Bug#59354 : Bug #12659252 : ASSERT !OTHER_LOCK AT LOCK_REC_ADD_TO_QUEUE DURING A DELETE OPERATION
The converted implicit lock should wait for the prior conflicting lock if found.

rb://1437 approved by Marko
2012-11-28 17:07:02 +09:00
Yasufumi Kinoshita
47619514f5 Bug#59354 : Bug #12659252 : ASSERT !OTHER_LOCK AT LOCK_REC_ADD_TO_QUEUE DURING A DELETE OPERATION
The converted implicit lock should wait for the prior conflicting lock if found.

rb://1437 approved by Marko
2012-11-28 17:05:23 +09:00
Inaam Rana
482b418476 merge from 5.1 2012-11-16 09:06:27 -05:00
Marko Mäkelä
49b51dd221 Merge mysql-5.1 to mysql-5.5. 2012-11-15 20:38:04 +02:00
Yasufumi Kinoshita
4c423016fa Bug #14676111 WRONG PAGE_LEVEL WRITTEN FOR UPPER THAN FATHER PAGE AT BTR_LIFT_PAGE_UP()
btr_lift_page_up() writes wrong page number (different by -1) for upper than father page.
But in almost all of the cases, the father page should be root page, no upper
pages. It is very rare path.

In addition the leaf page should not be lifted unless the father page is root.
Because the branch pages should not become the leaf pages.

rb://1336 approved by Marko Makela.
2012-11-12 22:31:30 +09:00
Vasil Dimov
95264568e7 This is a backport of "WL#5674 InnoDB: report all deadlocks (Bug#1784)"
from MySQL 5.6 into MySQL 5.5

Will close Bug#14515889 BACKPORT OF INNODB DEADLOCK LOGGING TO 5.5

The original implementation is in
vasil.dimov@oracle.com-20101213120811-k2ldtnao2t6zrxfn

Approved by:	Jimmy (rb:1535)
2012-11-12 14:24:43 +02:00
Yasufumi Kinoshita
f1ae77fd73 Bug #14676111 WRONG PAGE_LEVEL WRITTEN FOR UPPER THAN FATHER PAGE AT BTR_LIFT_PAGE_UP()
btr_lift_page_up() writes wrong page number (different by -1) for upper than father page.
But in almost all of the cases, the father page should be root page, no upper
pages. It is very rare path.

In addition the leaf page should not be lifted unless the father page is root.
Because the branch pages should not become the leaf pages.

rb://1336 approved by Marko Makela.
2012-11-12 22:33:40 +09:00
Annamalai Gurusami
a2c3ba2446 Merging from mysql-5.1 to mysql-5.5. 2012-11-09 18:56:20 +05:30
Marko Mäkelä
5a847fa97b Merge mysql-5.1 to mysql-5.5. 2012-10-16 14:35:19 +03:00
Marko Mäkelä
5d9e863faf Merge mysql-5.1 to mysql-5.5.
Also, add debug check for trx_id sanity to row_upd_rec_sys_fields().
2012-10-08 16:18:54 +03:00
Marko Mäkelä
be509b41aa Bug#14731482 UPDATE OR DELETE CORRUPTS A RECORD WITH A LONG PRIMARY KEY
We did not allocate enough bits for index->trx_id_offset, causing an
UPDATE or DELETE of a table with a PRIMARY KEY longer than 1024 bytes
to corrupt the PRIMARY KEY.

dict_index_t: Allocate enough bits.

dict_index_build_internal_clust(): Check for overflow of
index->trx_id_offset. Trip a debug assertion when overflow occurs.

rb:1380 approved by Jimmy Yang
2012-10-08 16:01:50 +03:00
Annamalai Gurusami
91c8a65a80 Bug #13249921 ASSERT !BPAGE->FILE_PAGE_WAS_FREED, USUALLY IN
TRANSACTION ROLLBACK

Description:  During the rollback operation, a blob page 
is removed earlier than desired.  Consider following scenario:

1. create table t1(a int primary key,b blob) engine=innodb;
2. insert into t1 values (1,repeat('b',9000));
3. begin;
4. update t1 set b=concat(b,'b');
5. update t1 set a=a+1;
6. insert into t1 values (1,repeat('b',9000));
7. rollback;

The update operation in line 5 produces 2 undo log record. The first
undo record (TRX_UNDO_DEL_MARK_REC) goes to trx->update_undo and the
second undo record (TRX_UNDO_INSERT_REC) goes to trx->insert_undo.
During rollback, they are executed out of order.

When the undo record TRX_UNDO_DEL_MARK_REC is applied/executed,
the blob ownership is also reset.  Because of this the blob page
is released earlier than desired.  This blob page must have been
freed only as part of applying/executing the undo record
TRX_UNDO_INSERT_REC.

This problem can be avoided by executing the undo records in
order.  This patch will make innodb to execute the undo records
in order.

rb://1125 approved by Marko.
2012-09-28 16:02:58 +05:30
Marko Mäkelä
aed6b87145 Bug#14636528 INNODB CHANGE BUFFERING IS NOT ENTIRELY CRASH-SAFE
Delete-mark change buffer records when resorting to a pessimistic
delete from the change buffer B-tree. Skip delete-marked records in
the change buffer merge and when estimating whether an operation can
be buffered. Without this fix, we could try to apply the same buffered
changes multiple times if the server was killed at the right moment.

In MySQL 5.5 and later: ibuf_get_volume_buffered_count_func(): Ignore
delete-marked (already processed) records.

ibuf_delete_rec(): Add a crash point before optimistic delete. If the
optimistic delete fails, flag the record processed before
mtr_commit().

ibuf_merge_or_delete_for_page(): Ignore delete-marked (already
processed) records.

Backport to 5.1: Rename btr_cur_del_unmark_for_ibuf() to
btr_cur_set_deleted_flag_for_ibuf() and add a parameter.

rb:1307 approved by Jimmy Yang
2012-09-19 22:35:38 +03:00
Annamalai Gurusami
dcb5011700 Merge from mysql-5.1 to mysql-5.5. 2012-09-28 16:42:31 +05:30
Marko Mäkelä
82842c4a21 Merge mysql-5.1 to mysql-5.5. 2012-09-19 22:55:26 +03:00