Commit graph

5260 commits

Author SHA1 Message Date
Annamalai Gurusami
8ea80ecfeb Bug #19929435 DROP DATABASE HANGS WITH MALFORMED TABLE
Note: Backporting the patch from mysql-5.6.

Problem:

A CREATE TABLE with an invalid table name is detected
at SQL layer. So the table name is reset to an empty
string.  But the storage engine is called with this
empty table name.  The table name is specified as
"database/table".  So, in the given scenario we get
only "database/".

Solution:

Within InnoDB, detect this error and report it to
higher layer.

rb#9274 approved by jimmy.
2015-09-22 06:21:13 +02:00
Marko Mäkelä
adf12e6e17 Adapt to WL#8845 Implement an InnoDB redo log format version identifier
recv_find_max_checkpoint(): Amend the error message to give advice
about downgrading. The 5.7.9 redo log format was intentionally changed
so that older MySQL versions will not find a valid redo log checkpoint.
2015-09-11 12:06:51 +03:00
Aditya A
608efca4c4 Bug #21025880 DUPLICATE UK VALUES IN READ-COMMITTED (AGAIN)
PROBLEM

Whenever we insert in unique secondary index we take shared
locks on all possible duplicate record present in the table.
But while during a replace on the unique secondary index ,
we take exclusive and locks on the all duplicate record.
When the records are deleted, they are first delete marked
and later purged by the purge thread. While purging the
record we call the lock_update_delete() which in turn calls
lock_rec_inherit_to_gap() to inherit locks of the deleted
records. In repeatable read mode we inherit all the locks
from the record to the next record  but in the read commited
mode we skip inherting them as gap type locks. We make a
exception here if the lock on the records is  in shared mode
,we assume that it is set during insert for unique secondary
index and needs to be inherited to stop constraint violation.
We didnt handle the case when exclusive locks are set during
replace, we skip inheriting locks of these records and hence
causing constraint violation.

FIX

While inheriting the locks,check whether the transaction is
allowed to do TRX_DUP_REPLACE/TRX_DUP_IGNORE, if true
inherit the locks.

[ Revewied by Jimmy #rb9709]
2015-08-12 19:17:26 +05:30
Shaohua Wang
f59d68eeae BUG#21102971 data corruption on arm64
The root cause is that x86 has a stronger memory model than the ARM
processors. And the GCC builtins didn't issue the correct fences when
setting/unsetting the lock word. In particular during the mutex release.

The solution is rewriting atomic TAS operations: replace '__sync_' by
'__atomic_' if possible.

Reviewed-by: Sunny Bains      <sunny.bains@oracle.com>
Reviewed-by: Bin Su           <bin.x.su@oracle.com>
Reviewed-by: Debarun Banerjee <debarun.banerjee@oracle.com>
Reviewed-by: Krunal Bauskar   <krunal.bauskar@oracle.com>
RB: 9782
RB: 9665
RB: 9783
2015-08-10 16:31:05 +08:00
Thirunarayanan Balathandayuthapani
18b2c77780 Merge branch 'mysql-5.1' into mysql-5.5 2015-07-29 18:27:39 +05:30
Thirunarayanan Balathandayuthapani
641ab6f368 Bug #20796566 ERROR: INSERT BUFFER INSERT FAIL CANNOT
INSERT INDEX RECORD

Problem:
=======

IBUF_BITMAP_FREE bit in ibuf bitmap array is used to indicate the free
space available in leaf page. IBUF_BITMAP_FREE bit indicates free
space more than actual existing free space for the leaf page.

Solution:
=========

Ibuf_bitmap_array is not updated for the secondary index leaf page when
insert operation is done by updating a delete marked existing
record in the index.

Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
RB: 9544
2015-07-29 18:24:20 +05:30
Christopher Powers
49667f0441 Bug#21374104 SETUP_TIMERS INITIALIZATION ASSUMES CYCLE TIMER IS ALWAYS AVAILABLE
For WAIT events, fall back to other timers if CYCLE is not available.
2015-07-10 20:42:33 +02:00
Annamalai Gurusami
92b4683d59 Bug #19138298 RECORD IN INDEX WAS NOT FOUND ON ROLLBACK, TRYING TO INSERT
Post push fix.  The function cmp_dtuple_rec() was used without a prototype
in the file row0purge.c.  Adding the include file rem0cmp.h to row0purge.c
to resolve this issue.

approved by Krunal over IM.
2015-06-22 12:49:32 +05:30
Annamalai Gurusami
db2ed27e0e Bug #20762798 FK DDL: CRASH IN DICT_FOREIGN_REMOVE_FROM_CACHE
Problem:

If we add a referential integrity constraint with a duplicate
name, an error occurs.  The foreign key object would not have
been added to the dictionary cache.  In the error path, there
is an attempt to remove this foreign key object. Since this
object is not there, the search returns a NULL result.
De-referencing the null object results in this crash.

Solution:

If the search to the foreign key object failed, then don't
attempt to access it.

rb#9309 approved by Marko.
2015-06-19 10:17:52 +05:30
Debarun Banerjee
e59914034a BUG#21065746 RQG_PARTN_PRUNING_VALGRIND FAILED IN REM0REC.CC
Problem :
---------
This is a regression of Bug#19138298. In purge_node_t::validate_pcur
we are trying to get offsets for all columns of clustered index from
stored record in persistent cursor. This would fail when stored record
is not having all fields of the index. The stored record stores only
fields that are needed to uniquely identify the entry.

Solution :
----------
1. Use pcur.old_n_fields to get fields that are stored
2. Add comment to note dependency between stored fields in purge node
ref and stored cursor.
3. Return if the cursor record is not already stored as it is not safe
to access cursor record directly without latch.

Reviewed-by: Marko Makela <marko.makela@oracle.com>

RB: 9139
2015-06-03 11:43:12 +05:30
Debarun Banerjee
4b8304a9a4 BUG#21126772 VALGRIND FAILURE IN ENGINES/FUNCS SUITE
Problem :
---------
This is a regression of bug-19138298. During purge, if
btr_pcur_restore_position fails, we set found_clust to FALSE
so that it can find a possible clustered index record in future
calls for the same undo entry. This, however, overwrites the
old_rec_buf while initializing pcur again in next call.

The leak is reproducible in local environment and with the
test provided along with bug-19138298.

Solution :
----------
If btr_pcur_restore_position() fails close the cursor.

Reviewed-by: Marko Makela <Marko.Makela@oracle.com>
Reviewed-by: Annamalai Gurusami <Annamalai.Gurusami@oracle.com>

RB: 9074
2015-06-03 11:27:38 +05:30
Bin Su
b4daac21f5 Bug#21113036 - MYSQL/INNODB MIX BUFFERED AND DIRECT IO
As man page of open(2) suggested, we should open the same file in the same
mode, to have better performance. For some data files, we will first call
os_file_create_simple_no_error_handling_func() to open them, and then call
os_file_create_func() again. We have to make sure if DIRECT IO is specified,
these two functions should both open file with O_DIRECT.

Reviewed-by: Sunny Bains <sunny.bains@oracle.com>
RB: 8981
2015-05-21 11:52:17 +08:00
Annamalai Gurusami
e7b6e814be Bug #19138298 RECORD IN INDEX WAS NOT FOUND ON ROLLBACK, TRYING TO INSERT
Scenario:

1. The purge thread takes an undo log record and parses it and forms
   the record to be purged. We have the primary and secondary keys
   to locate the actual records.
2. Using the secondary index key, we search in the secondary index.
   One record is found.
3. Then it is checked if this record can be purged.  The answer is we
   can purge this record.  To determine this we look up the clustered
   index record.  Either there is no corresponding clustered index
   record, or the matching clustered index record is delete marked.
4. Then we check whether the secondary index record is delete marked.
   We find that it is not delete marked.  We report warning in optimized
   build and assert in debug build.

Problem:

In step 3, we report that the record is purgeable even though it is
not delete marked.  This is because of inconsistency between the
following members of purge_node_t structure - found_clust, ref and pcur.

Solution:

In the row_purge_reposition_pcur(), if the persistent cursor restore
fails, then reset the purge_node_t->found_clust member.  This will
keep the members of purge_node_t structure in a consistent state.

rb#8813 approved by Marko.
2015-05-09 13:24:01 +05:30
Sreeharsha Ramanavarapu
d2a5d9716a Bug# 19573096: LOADING CORRUPTED GEOMETRY DATA INTO A
MYISAM TABLE CAUSES THE SERVER TO CRASH

Backport to mysql-5.1
2015-04-10 08:45:57 +05:30
Marko Mäkelä
25323de2a4 Bug#20816223 InnoDB crash on shutdown
if XA PREPARE transactions hold explicit locks.

innobase_shutdown_for_mysql(): Call trx_sys_close() before lock_sys_close()
(and dict_close()) so that trx_free_prepared() will see all locks intact.

RB: 8561
Reviewed-by: Vasil Dimov <vasil.dimov@oracle.com>
2015-04-09 08:13:07 +03:00
aditya
232d8bbdb1 Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE WRONG FOR PARTITIONED TABLES
PROBLEM

Create time is calculated as last status change time of .frm file.
The first problem was that innodb was passing file name as
"table_name#po#p0.frm" to the stat() call which calculates the create time.
Since there is no frm file with this name create_time will be stored as NULL.
The second problem is ha_partition::info() updates stats for create time
when HA_STATUS_CONST flag was set ,where as innodb calculates this statistic
when HA_STATUS_TIME is set,which causes create_time to be set as NULL.

Fix
Pass proper .frm name to stat() call and calculate create time when
HA_STATUS_CONST flag is set.
2015-04-06 12:27:12 +05:30
Thirunarayanan Balathandayuthapani
f8eacccf2a Bug#20422680 BUF_POOL_WATCH_SET WOULD CRASH TRYING
TO USE A SECOND WATCH PAGE PER INSTANCE

Description:
	BUF_POOL_WATCH_SIZE is also initialized to number of purge threads.
so BUF_POOL_WATCH_SIZE will never be lesser than number of purge threads.
From the code, there is no scope for purge thread to skip buf_pool_watch_unset.
So there can be at most one buffer pool watch active per purge thread.
In other words, there is no chance for purge thread instance to hold a watch
when setting another watch.

Solution:
	Adding code comments to clarify the issue.

Reviewed-by: Marko Mäkelä <marko.makela@oracle.com>
Approved via Bug page.
2015-03-24 14:09:18 +05:30
Sreeharsha Ramanavarapu
b7bdea944d Bug# 19573096: LOADING CORRUPTED GEOMETRY DATA INTO A
MYISAM TABLE CAUSES THE SERVER TO CRASH

Issue:
-----
During index maintanence, R-tree node might need a split.
In some cases the square of mbr could be calculated to
infinite (as in this case) or to NaN. This is currently
not handled. This is specific to MyISAM.

SOLUTION:
---------
If the calculated value in "mbr_join_square" is infinite or
NaN, set it to max double value.

Initialization of output parameters of "pick_seeds" is
required if calculation is infinite (or negative infinite).

Similar to the fix made for INNODB as part of Bug#19533996.
2015-03-23 08:49:26 +05:30
Sreeharsha Ramanavarapu
96974ea7ca Revert "Bug #19573096: LOADING CORRUPTED GEOMETRY DATA INTO A"
This reverts commit c7de768ec20f5167cff2c69a255d95ca2eded46a.
2015-03-11 16:07:49 +05:30
Thirunarayanan Balathandayuthapani
48869fceba Bug #20417397 MYSQL SHOW ENGINE INNODB STATUS SHOWING NEGATIVE
RESERVATION AND SIGNAL COUNT

Problem:
	Reservation and Signal count value shows negative value for show engine
innodb statement.

Solution:
	This is happening due to counter overflow error. Reservation and Signal
count values are defined as unsigned long but these variables are converted to
long while printing it. Change Reservation and Signal count values as unsigned
long datatype while printing it.

Reviewed-by: Marko Mäkelä <marko.makela@oracle.com>
Approved in bug page.
2015-03-11 15:17:35 +05:30
Sreeharsha Ramanavarapu
54d23eceb7 Bug #19573096: LOADING CORRUPTED GEOMETRY DATA INTO A
MYISAM TABLE CAUSES THE SERVER TO CRASH

Issue:
-----
During index maintanence, R-tree node might need a split.
In some cases the square of mbr could be calculated to
infinite (as in this case) or to NaN. This is currently
not handled. This is specific to MyISAM.

SOLUTION:
---------
If the calculated value in "mbr_join_square" is infinite or
NaN, set it to max double value.

Initialization of output parameters of "pick_seeds" is
required if calculation is infinite (or negative infinite).

Similar to the fix made for INNODB as part of Bug#19533996.
2015-03-11 11:18:52 +05:30
Annamalai Gurusami
98b18c5971 Bug #20442523 CRASH WHEN CREATE TABLE VIOLATES FOREIGN KEY CONSTRAINT
Problem:

This is a coding mistake during error handling.  When the specified foreign
key constraint is wrong because of data type mismatch, the resulting
foreign key object will not have valid foreign->id (it will be NULL.)

Solution:

While removing the foreign key object from dictionary cache during error
handling, ensure that foreign->id is not null before using it.

rb#8204 approved by Sunny.
2015-03-03 17:57:08 +05:30
Mithun C Y
2e3c2cd362 Bug #20049521: CRASH IN MERGE_BUFFERS FILESORT.C WHEN INNODB WITH ORDER BY.
ISSUE:
------
There can be up to MERGEBUFF2 number of sorted merge chunks,
We need enough buffer space for at least one record from
each merge chunks. If estimates are wrong(very low) and we
allocate buffer space for less than MERGEBUFF2, then we will
have issue in merge_buffers, if actual number of rows to be
sorted is bigger than estimate and external filesort is
chosen.

SOLUTION:
---------
Set number of rows to sort to be at least MERGEBUFF2.
2015-02-25 11:44:19 +05:30
Arun Kuruvila
08526dfb01 Bug #12671631 CREATE TABLE .. LIKE .. FEDERATED TABLE
CRASHES WITH AUTO_INCREMENT COLUMN

Description:- Creating a federated table with AUTO_INCREMENT
column using LIKE clause results in a server crash.

Analysis:- Creating a federated table with AUTO_INCREMENT
column using LIKE clause results in a federated server
crash due to the uninitialized connection structure(mysql).
Also due to unassigned connection string for the remote
server, at the time of preparation of "create_info"
structure, the creation of any federated table using LIKE
clause fails with an error, "ERROR 1 (HY000): server name:
'' doesn't exist!". This  bug is not only with
AUTO_INCREMENT but in all creations of federated tables with
LIKE clause.

Fix :- In ha_federated::info(), "mysql->insert_id" assigned
to "stats.auto_increment_value" only when there is an
active connection. This fixes the crash issue. For creating
the federated table with LIKE clause, connection string is
assigned at the time of preparation of "create_info"
structure.
2015-01-28 09:43:34 +05:30
Thiru
901ce5314b Bug #20144839 AFTER UPDATING TO MYSQL 5.6.22 SERVER
CRASHES ON EVERY START ATTEMPT

Description:
------------
push_warning_printf function is used to print the warning message
to the client. So this function should not invoke while recovering
the server. Moreover current_thd is NULL while starting the server.

Solution:
---------
 - Avoiding the warning to be printed while recovery.
This patch already pushed in mysql-5.6.
2014-12-24 15:22:10 +05:30
Arun Kuruvila
a9b61b0029 Bug#17599258:- ERROR 1160 (08S01): GOT AN ERROR WRITING
COMMUNICATION PACKETS; FEDERATED TABLE

Description:- Execution of FLUSH TABLES on a federated
table which has been idle for wait_timeout (on the remote
server) + tcp_keepalive_time, fails with an error,
"ERROR 1160 (08S01): Got an error writing communication
packets."

Analysis:- During FLUSH TABLE execution the federated
table is closed which will inturn close the federated
connection. While closing the connection, federated server
tries to communincate with the remote server. Since the
connection was idle for wait_timeout(on the remote server)+
tcp_keepalive_time, the socket gets closed. So this
communication fails because of broken pipe and the error is
thrown. But federated connections are expected to reconnect
silently. And also it cannot reconnect because the 
"auto_reconnect" variable is set to 0 in "mysql_close()".

Fix:- Before closing the federated connection, in
"ha_federated_close()", a check is added which will verify
wheather the connection is alive or not. If the connection
is not alive, then "mysql->net.error" is set to 2 which
will indicate that the connetion is broken. Also the
setting of "auto_reconnect" variable to 0 is delayed and is
done after "COM_QUIT" command.
      
NOTE:- For reproducing this issue, "tcp_keepalive_time" has
to be set to a smaller value. This value is set in the
"/proc/sys/net/ipv4/tcp_keepalive_time" file in Unix
systems. So we need root permission for changing it, which
can't be done through mtr test. So submitting the patch
without mtr test.
2014-11-10 16:21:59 +05:30
Thirunarayanan B
821dfcd8d2 Bug #19815702 TIS620: CRASH WITH MULTI TABLE DELETE
Description:
  Using correct length when moving to next field in cmp_ref. The store
length already includes the length bytes of blobs, which is already considered
earlier for blob types.
	Approved by Mattias, Jimmy [rb-7088]
2014-11-04 17:40:29 +05:30
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
4274242655 Bug #19908343 SERVER CRASHES WHEN EXECUTING ALTER TABLE
Problem:

In the function dict_foreign_remove_from_cache(), the rb tree was updated
without actually verifying whether the given foreign key object is there in the
rb tree or not.  There can be an existing foreign key object with the same id 
in the rb tree, which must not be removed.  Such a scenario comes when an
attempt is made to add a foreign key object with a duplicate identifier.

Solution:

When the foreign key object is removed from the dictionary cache, ensure
that the foreign key object removed from the rbt is the correct one.

rb#7168 approved by Jimmy and Marko.
2014-10-29 16:53:53 +05:30
Marko Makela
352b6bc9a8 Bug#19584379 Reporting corruption may corrupt the innodb data dictionary
dict_set_corrupted(): Use the canonical way of searching for
less-than-equal (PAGE_CUR_LE) and then checking low_match.

The code that was introduced in MySQL 5.5.17 in
    Bug#11830883 SUPPORT "CORRUPTED" BIT FOR INNODB TABLES AND INDEXES
could position the cursor on the page supremum, and then attempt
to overwrite non-existing 7th field of the 1-field supremum record.

Approved by Jimmy Yang
2014-10-27 14:27:08 +02:00
Jon Olav Hauglid
8b64f82505 Bug#17633291: SET PROPER COMPILE OPTIONS FOR CLANG
Bug#17959689: MAKE GCC AND CLANG GIVE CONSISTENT COMPILATION WARNINGS
Bug#18313717: ENABLE -WERROR IN MAINTANER MODE WHEN COMPILING WITH CLANG
Bug#18510941: REMOVE CMAKE WORKAROUNDS FOR OLDER VERSIONS OF OS X/XCODE
  
Backport from mysql-5.6 to mysql-5.5
2014-10-13 09:52:28 +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
44fd241a22 Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN INNODB_STRICT_MODE = 1
Problem:

Creation of a table fails when innodb_strict_mode is enabled, but the same
table is created without any warning when innodb_strict_mode is enabled.

Solution:

If creation of a table fails with an error when innodb_strict_mode is
enabled, it must issue a warning when innodb_strict_mode is disabled.

rb#6723 approved by Krunal.
2014-09-17 10:42:31 +05:30
Praveenkumar Hulakund
cf4231a7f9 Bug#18790730 - CROSS-DATABASE FOREIGN KEY WITHOUT PERMISSIONS
CHECK.

Analysis:
----------
Issue here is, while creating or altering the InnoDB table,
if the foreign key defined on the table references a parent
table on which the user has no access privileges then the
table is created without reporting any error. 

Currently the privilege level REFERENCES_ACL is unused
and is not used for access evaluation while creating the
table with a foreign key constraint or adding the foreign
key constraint to a table. But when no privileges are granted
to user then also access evaluation on parent table is ignored.

Fix:
---------
For DMLs, irrelevant of the fact, support does not want any
changes to avoid permission checks on every operation.

So, as a fix, added a function "check_fk_parent_table_access" 
to check whether any of the SELECT_ACL, INSERT_ACL, UDPATE_ACL,
DELETE_ACL or REFERENCE_ACL privileges are granted for user
at table level. If none of them is granted then error is reported.
This function is called during the table creation and alter 
operation.
2014-09-10 10:50:17 +05:30
Murthy Narkedimilli
96748c37f7 Changing the copyright headers a bit to be complaint with the standards 2014-08-27 16:06:50 +02:00
Annamalai Gurusami
f97dfa81a5 Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE ADD FOREIGN KEY
Problem:

We maintain two rb trees in each dict_table_t.  The foreign_rbt must be in
sync with foreign_list.  The referenced_rbt must be in sync with
referenced_list. There is one function which checks this consistency and it
failed, resulting in an assert failure.

The root cause of the problem was identified that the search order was 
lost in the referenced_rbt.  This is because while renaming the table,
we didn't not refresh this referenced_rbt.

Solution:

When a foreign key is renamed, we must delete and re-insert into both
foreign_rbt and referenced_rbt.  

rb#6412 approved by Jimmy.
2014-08-25 16:25:07 +02:00
bin.x.su@oracle.com
d345978d27 Remove unstable test case innodb_bug18942294, approved by Jimmy over IM. 2014-08-06 09:51:20 +08:00
bin.x.su@oracle.com
95ec5bdd71 BUG#18942294 - SEGV IN DICT_FIND_TABLE_BY_SPACE TRYING TO MARK SPACE CORRUPT
IN RECOVERY

During redo log processing, the data dictionary is not available. We should
check it in dict_find_table_by_space() to prevent SEGV error.

rb#5678, approved by Jimmy.
2014-07-08 15:10:15 +08:00
Annamalai Gurusami
76e690fb37 Bug #19140907 DUPLICATES IN UNIQUE SECONDARY INDEX BECAUSE OF FIX OF BUG#68021
Problem:

When a unique secondary index is scanned for duplicate checking, gap locks
were not taken if the transaction had isolation level <= READ COMMITTED. 
This change was done while fixing Bug #16133801 UNEXPLAINABLE INNODB UNIQUE
INDEX LOCKS ON DELETE + INSERT WITH SAME VALUES (rb#2035). Because of this
the duplicate check logic failed, and resulted in duplicate values in unique
secondary index.

Solution:

When a unique secondary index is scanned for duplicate checking, gap locks
must be taken irrespective of the transaction isolation level.  This is
achieved by reverting rb#2035.

rb#5910 approved by Jimmy
2014-07-03 10:13:29 +05:30
Arun Kuruvila
dd31a2c27b Bug#18463911 : SERVER CRASHES ON CREATING A TEMP TABLE WITH
CERTAIN MAX_HEAP_TABLE_SIZE VALUES

Followup patch to fix failure on Window machine.
2014-06-26 10:08:55 +05:30
Arun Kuruvila
774095a59b Bug #18463911 : SERVER CRASHES ON CREATING A TEMP TABLE
WITH CERTAIN MAX_HEAP_TABLE_SIZE VALUES

Description:
When the  system variable 'max_heap_table_size'
is set to 20GB, the server crashes on creation of a
temporary tables or tables using MEMORY storage engine.

Analysis:
The variable 'max_record' determines the amount heap
allocated for the records of the table. This value
is determined using the 'max_heap_table_size' variable.
'records_in_block' in turn uses the max_records to
determine the number of records per block.

When the 'max_heap_table_size' is set to 20GB, then
the 'records_in_block' is calculated to a value of
2^28.

The size of the block determined by multiplying the
'records_in_block' and 'recbuffer' results in overflow
and hence the value becomes zero. As a result, zero bytes
of the heap is allocated for the table. This will
result in a server crash when the table is accessed.

Fix:
The variables 'records_in_block' and 'recbuffer' are
typecasted to 'unsigned long' while calculating the
size of the block.
2014-06-25 11:42:41 +05:30
Gopal Shankar
e107c24f1c Bug#18776592 INNODB: FAILING ASSERTION: PRIMARY_KEY_NO == -1 ||
PRIMARY_KEY_NO == 0 

This bug is a backport of the following revision of 5.6 source tree:
# committer: Gopal Shankar <gopal.shankar@oracle.com>
# branch nick: priKey56
# timestamp: Wed 2013-05-29 11:11:46 +0530
# message:
#   Bug#16368875 INNODB: FAILING ASSERTION:
2014-06-25 09:50:17 +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
Venkata Sidagam
b9c03d41e4 Bug #18045646 LOCAL USER CAN RUN ARBITRARY CODE IN THE CONTEXT OF THE MYSQL SERVER
Description: Using the temporary file vulnerability an
attacker can create a file with arbitrary content at a
location of his choice. This can be used to create the
file /var/lib/mysql/my.cnf, which will be read as a
configuration file by MySQL, because it is located in the
home directory of the mysql user. With this configuration
file, the attacker can specify his own plugin_dir variable,
which then allows him to load arbitrary code via
"INSTALL PLUGIN...".

Analysis: While creating the ".TMD" file we are not checking
if the file is already exits or not in mi_repair() function.
And we are truncating if the ".TMD" file exits and going ahead
This is creating the security breach.

Fix: We need to use O_EXCL flag along with O_RDWR and O_TRUNC
which will make sure if any user creates ".TMD" file, will
fails the repair table with "cannot create ".TMD" file error".
Actually we are initialing "param.tmpfile_createflag" member
with O_RDWR | O_TRUNC | O_EXCL in myisamchk_init(). And we
are modifying it in ha_myisam::repair() to O_RDWR | O_TRUNC.
So, we need to remove the line which is modifying the
"param.tmpfile_createflag".
2014-05-08 14:41:01 +05:30
Arun Kuruvila
e12156e7b6 Description: When we execute a correlated subquery on an
archive table which is using an auto increment column, the
server hangs. In order to recover the mysqld process, it
has to be terminated abnormally using SIGKILL. The problem
is observed in mysql-5.5.
Bug #18065452 "PREPARING" STATE HOGS CPU WITH ARCHIVE
               + SUBQUERY

Analysis: This happens because the server is trapped inside
an infinite loop in the function,
"subselect_indexsubquery_engine::exec()". This function
resolves the correlated suquery by doing an index lookup
for the appropriate engine. In  case of archive engine,
after reaching the end of records, "table->status" is not
set to STATUS_NOT_FOUND. As a result the loop is not 
terminated.

Fix: The "table->status" is set to STATUS_NOT_FOUND when
the end of records is reached.
2014-04-10 11:10:31 +05:30
Thirunarayanan B
5e9a285164 Bug #17858679 TOO MANY TIMES OF MEMSET DECREASE
THE PERFORMANCE UNDER HEAVY INSERT
	Fixing the build problem in 5.5.
2014-04-01 11:36:58 +05:30
Thirunarayanan B
cacd22428c Bug #17858679 TOO MANY TIMES OF MEMSET DECREASE
THE PERFORMANCE UNDER HEAVY INSERT
Problem:
	There are three memset call to allocate memory for system fields
in each insert.

Solution:
	Instead of calling it in 3 times, we can combine it into
one memset call. It will reduce the CPU usage under heavy insert.

	Approved by Marko rb-4916
2014-04-01 10:46:13 +05:30
Satya Bodapati
30d5c84b7d Bug#18124788 - COMPRESSED TABLES REGRESSION FROM 5.6.13
After incrementing the number of pending uncompression operations,
buffer pool zip mutex can be released immediately.

Approved by Vasil. rb#4514
2014-02-28 12:45:53 +05:30
Murthy Narkedimilli
42bfa90874 Updated/added copyright header. Added line "use is subject to license terms"
to copyright header.
2014-02-17 18:19:04 +05:30
Thirunarayanan B
255e450651 Bug #18010711 UNIQUE PREFIX INDEX ON BINARY COLUMN:
FAILING ASSERTION: FLEN == LEN

Problem:
       Broken invariant triggered when building a unique index on a
binary column and the input data contains duplicate keys. This was broken
in debug builds only.

Fix:
       Fixed length of the binary datatype can be greater than length of
the shorter prefix on which index is being created.
2014-02-17 13:45:34 +05:30