Commit graph

1223 commits

Author SHA1 Message Date
Marko Mäkelä
8a94d55e69 Bug#12612184 Race condition after btr_cur_pessimistic_update()
btr_cur_compress_if_useful(), btr_compress(): Add the parameter ibool
adjust. If adjust=TRUE, adjust the cursor position after compressing
the page.

btr_lift_page_up(): Return a pointer to the father page.

BTR_KEEP_POS_FLAG: A new flag for btr_cur_pessimistic_update().

btr_cur_pessimistic_update(): If *big_rec != NULL and flags &
BTR_KEEP_POS_FLAG, keep the cursor positioned on the updated record.
Also, do not release the index tree x-lock if *big_rec != NULL.

btr_cur_mtr_commit_and_start(): Commits and restarts a
mini-transaction so that it will retain an x-lock on index->lock and
the page of the cursor. This is invoked when
btr_cur_pessimistic_update() returns *big_rec != NULL.

In all callers of btr_cur_pessimistic_update() that do not pass
BTR_KEEP_POS_FLAG, assert that *big_rec == NULL.

btr_cur_compress(): Unused function [in the built-in MySQL 5.1], remove.

page_rec_get_nth(): Return the nth record on the page (an inverse
function of page_rec_get_n_recs_before()). Refactored from
page_get_middle_rec().

page_get_middle_rec(): Invoke page_rec_get_nth().

page_cur_insert_rec_zip_reorg(): Make use of the page directory
shortcuts in page_rec_get_nth() instead of scanning the whole list of
records.

row_ins_clust_index_entry_by_modify(): Pass BTR_KEEP_POS_FLAG to
btr_cur_pessimistic_update().

row_ins_index_entry_low(): If row_ins_clust_index_entry_by_modify()
returns a big_rec, invoke btr_cur_mtr_commit_and_start() in order to
commit and start the mini-transaction without releasing the x-locks on
index->lock and the cursor page, and write the big_rec. Releasing the
page latch in mtr_commit() caused a race condition.

row_upd_clust_rec(): Pass BTR_KEEP_POS_FLAG to
btr_cur_pessimistic_update(). If it returns a big_rec, invoke
btr_cur_mtr_commit_and_start() in order to commit and start the
mini-transaction without releasing the x-locks on index->lock and the
cursor page, and write the big_rec. Releasing the page latch in
mtr_commit() caused a race condition.

sync_thread_add_level(): Add the parameter ibool relock. When TRUE,
bypass the latching order rules.

rw_lock_add_debug_info(): For nested X-lock requests, pass relock=TRUE
to sync_thread_add_level().

rb:678 approved by Jimmy Yang
2011-06-16 10:27:21 +03:00
Marko Mäkelä
2a48b14270 Introduce UNIV_BLOB_NULL_DEBUG for temporarily hiding Bug#12650861.
Some ut_a(!rec_offs_any_null_extern()) assertion failures are indicating
genuine BLOB bugs, others are bogus failures when rolling back incomplete
transactions at crash recovery. This needs more work, and until I get a
chance to work on it, other testing must not be disrupted by this.
2011-06-15 10:16:59 +03:00
Marko Mäkelä
c8419facb5 Disable a debug assertion that was added to track down Bug#12612184.
row_build(): The record may contain null BLOB pointers when the server
is rolling back an insert that was interrupted by a server crash.
2011-06-09 21:50:41 +03:00
Marko Mäkelä
6d20340c72 BLOB instrumentation for Bug#12612184 Race condition in row_upd_clust_rec()
If UNIV_DEBUG or UNIV_BLOB_LIGHT_DEBUG is enabled, add
!rec_offs_any_null_extern() assertions, ensuring that records do not
contain null pointers to externally stored columns in inappropriate
places.

btr_cur_optimistic_update(): Assert !rec_offs_any_null_extern().
Incomplete records must never be updated or deleted. This assertion
will cover also the pessimistic route.

row_build(): Assert !rec_offs_any_null_extern(). Search tuples must
never be built from incomplete index entries.

row_rec_to_index_entry(): Assert !rec_offs_any_null_extern() unless
ROW_COPY_DATA is requested. ROW_COPY_DATA is used for
multi-versioning, and therefore it might be valid to copy the most
recent (uncommitted) version while it contains a null pointer to
off-page columns.

row_vers_build_for_consistent_read(),
row_vers_build_for_semi_consistent_read(): Assert !rec_offs_any_null_extern()
on all versions except the most recent one.

trx_undo_prev_version_build(): Assert !rec_offs_any_null_extern() on
the previous version.

rb:682 approved by Sunny Bains
2011-06-09 13:31:15 +03:00
Dmitry Lenev
d076be2a32 Fix for bug #11762012 - "54553: INNODB ASSERTS IN
HA_INNOBASE::UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK".

Attempt to update an InnoDB temporary table under LOCK TABLES
led to assertion failure in both debug and production builds
if this temporary table was explicitly locked for READ. The 
same scenario works fine for MyISAM temporary tables.

The assertion failure was caused by discrepancy between lock 
that was requested on the rows of temporary table at LOCK TABLES
time and by update operation. Since SQL-layer requested a 
read-lock at LOCK TABLES time InnoDB engine assumed that upcoming
statements which are going to be executed under LOCK TABLES will 
only read table and therefore should acquire only S-lock.
An update operation broken this assumption by requesting X-lock.

Possible approaches to fixing this problem are:

1) Skip locking of temporary tables as locking doesn't make any
   sense for connection-local objects.
2) Prohibit changing of temporary table locked by LOCK TABLES ... 
   READ.

Unfortunately both of these approaches have drawbacks which make 
them unviable for stable versions of server.

So this patch takes another approach and changes code in such way
that LOCK TABLES for a temporary table will always request write
lock. In 5.1 version of this patch switch from read lock to write
lock is done inside of InnoDBs handler methods as doing it on 
SQL-layer causes compatibility troubles with FLUSH TABLES WITH
READ LOCK.
2011-05-26 17:14:47 +04:00
Marko Mäkelä
13520f4ae5 Merge mysql-5.1 to mysql-5.5. 2011-06-30 13:23:34 +03:00
Marko Mäkelä
70e94927d4 Merge mysql-5.1 to mysql-5.5. 2011-06-29 16:53:16 +03:00
Marko Mäkelä
83c985898b Merge mysql-5.1 to mysql-5.5. 2011-06-29 10:04:00 +03:00
Marko Mäkelä
37282cc6bd Bug#12699505 Memory leak in row_create_index_for_mysql()
DB_COL_APPEARS_TWICE_IN_INDEX: Remove. This condition is already
checked and reported by MySQL before passing the index definition to
the storage engine.

row_create_index_for_mysql(): Remove the redundant check for
DB_COL_APPEARS_TWICE_IN_INDEX. When enforcing the column prefix index
limit, invoke dict_mem_index_free(index) to plug the memory leak. In
the loop, use index->n_def instead of dict_index_get_n_fields(index),
because the latter would be 0 for indexes that have not been copied to
the data dictionary cache.

innodb-use-sys-malloc.test:

Add test cases for attempting to trigger the error checks in
row_create_index_for_mysql(). Before MySQL 5.5 and WL#5743, the leak
is only reproducible if ha_innobase::max_supported_key_part_length()
returned a higher limit than the one used in
row_create_index_for_mysql().

In MySQL 5.5 and later, the leak is reproducible with
innodb_large_prefix=true.

rb:688 approved by Jimmy Yang
2011-06-28 15:28:21 +03:00
Marko Mäkelä
e232ed0990 Merge mysql-5.1 to mysql-5.5. 2011-06-28 12:03:55 +03:00
Marko Mäkelä
f2a5309418 Merge mysql-5.1 to mysql-5.5.
This patch was already pushed to mysql-5.5 by Inaam Rana.
2011-06-23 15:57:25 +03:00
Inaam Rana
4b26365c1d Fix a merge error introduced in:
revision-id: inaam.rana@oracle.com-20110617202919-b7p0u0ekj5a9u9nu
2011-06-20 00:37:36 -04:00
Inaam Rana
33f3864e62 merge from mysql-5.1
Bug 12635227 - 61188: DROP TABLE EXTREMELY SLOW
2011-06-17 16:29:19 -04:00
Vasil Dimov
c551dd9cee Merge mysql-5.1 -> mysql-5.5 2011-06-16 16:14:16 +03:00
Marko Mäkelä
d73998eb87 Merge mysql-5.1 to mysql-5.5. 2011-06-16 15:13:24 +03:00
Marko Mäkelä
7540b1a7d5 Merge mysql-5.1 to mysql-5.5. 2011-06-16 12:07:49 +03:00
Marko Mäkelä
3015542b1a Merge mysql-5.1 to mysql-5.5. 2011-06-15 10:30:19 +03:00
Marko Mäkelä
cfb1f299a4 Merge mysql-5.1 to mysql-5.5. 2011-06-09 22:03:16 +03:00
Marko Mäkelä
b1fc801ad1 Merge mysql-5.1 to mysql-5.5. 2011-06-09 13:59:02 +03:00
Marko Mäkelä
e91652afb8 Non-functional change: Unbreak the Hot Backup build.
page_rec_write_field(): Omit the definition if UNIV_HOTBACKUP is defined.
2011-06-06 16:24:01 +03:00
Vasil Dimov
6ae5b07b2a Increment InnoDB version from 1.1.7 to 1.1.8
InnoDB 1.1.7 was released with MySQL 5.5.13
2011-06-03 13:47:46 +03:00
Jon Olav Hauglid
f21fd6e40f Bug#11853126 RE-ENABLE CONCURRENT READS WHILE CREATING
SECONDARY INDEX IN INNODB

The patches for Bug#11751388 and Bug#11784056 enabled concurrent
reads while creating secondary indexes in InnoDB. However, they
introduced a regression. This regression occured if ALTER TABLE
failed after the index had been added, for example during the
lock upgrade needed to update .FRM. If this happened, InnoDB
and the server got out of sync with regards to which indexes
actually existed. Therefore the patch for Bug#11815600 again
disabled concurrent reads.

This patch re-enables concurrent reads. The original regression
is fixed by splitting the ADD INDEX operation into two parts.
First the new index is created but not made active. This is
done while concurrent reads are allowed. The second part of
the operation makes the index active (or reverts the change).
This is done after lock upgrade, which prevents the original
regression.

In order to implement this change, the patch changes the storage
API for in-place index creation. handler::add_index() is split
into two functions, handler_add_index() and
handler::final_add_index(). The former for creating indexes without
making them visible and the latter for commiting (i.e. making
visible) new indexes or reverting the changes.

Large parts of this patch were written by Marko Mäkelä.

Test case added to innodb_mysql_lock.test.
2011-06-01 10:06:55 +02:00
Jimmy Yang
bd708b4240 Implement worklog #5743 InnoDB: Lift the limit of index key prefixes.
With this change, the index prefix column length lifted from 767 bytes
to 3072 bytes if "innodb_large_prefix" is set to "true".

rb://603 approved by Marko
2011-05-31 02:12:32 -07:00
Marko Mäkelä
942cd5fd18 Bug#12606344 - ADD VALGRIND DIAGNOSTICS TO MTR_START, MTR_COMMIT
mtr_start(): Declare the mtr memory area uninitialized in Valgrind
before initializing the fields.

mtr_commit(): Declare everything uninitialized except
mtr->start_lsn, mtr->end_lsn and mtr->state.
2011-05-31 10:55:29 +03:00
Marko Mäkelä
63c6303657 Bug#12584374 LOCK_VALIDATE TRIPS ASSERTION !BLOCK->PAGE.FILE_PAGE_WAS_FREE
Fix a deadlock in the initial patch. lock_validate() must not hold the
lock system mutex while s-latching a block, because some functions,
such as lock_rec_convert_impl_to_expl(), may be already holding an x-latch
on the block that lock_validate() is interested in while attempting to
acquire the lock system mutex.

This deadlock was not caught by UNIV_SYNC_DEBUG because of
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK).
2011-05-24 23:08:22 +03:00
Marko Mäkelä
5b25a69ee3 Bug#12584374 LOCK_VALIDATE TRIPS ASSERTION !BLOCK->PAGE.FILE_PAGE_WAS_FREED
lock_clust_rec_some_has_impl(), row_get_rec_trx_id(),
lock_rec_queue_validate(), lock_table_other_has_incompatible(),
lock_table_has_to_wait_in_queue(), lock_table_queue_validate():
Add const qualifiers.

row_get_trx_id_offset(): Add const qualifiers. Keep the parameter rec
only in UNIV_DEBUG builds. Inline the function.

lock_rec_validate_page(): Take the buffer block as a parameter, to
avoid a buf_page_get_gen() call in most cases.

lock_rec_validate_page_low(): A version of lock_rec_validate_page()
that assumes that the lock system mutexes are already being held.

lock_rec_get_next_on_page_const(): A const variant of
lock_rec_get_next_on_page().

lock_validate(): Do not release the lock system mutex while
buffer-fixing the block for the lock_rec_validate_page() call.
Releasing the mutex apparently caused the assertion failure.

rb:665 approved by Sunny Bains
2011-05-24 14:11:21 +03:00
Marko Mäkelä
b2270aedd6 Backport an InnoDB Bug #58815 (Bug #11765812) work-around from mysql-trunk:
------------------------------------------------------------
revno 2876.244.305
revision id marko.makela@oracle.com-20110413082211-e6ouhjz5rmqxcqap
parent  marko.makela@oracle.com-20110413075948-kvytmc37ye1nt7d9
committer  Marko Mäkelä <marko.makela@oracle.com>
branch nick 5.6-innodb
timestamp Wed 2011-04-13 11:22:11 +0300
message:
  Suppress the Bug #58815 (Bug #11765812) assertion failure.

  buf_page_get_gen(): Introduce BUF_GET_POSSIBLY_FREED for suppressing the
  check that the file page must not have been freed.

  btr_estimate_n_rows_in_range_on_level(): Pass BUF_GET_POSSIBLY_FREED and
  explain in the comments why this is needed and why it should be mostly
  harmless to ignore the problem. If InnoDB had always initialized all
  unused fields in data files, no problem would exist.

  This change does not fix the bug, it just "shoots the messenger".

  rb:647 approved by Jimmy Yang
2011-05-24 11:41:31 +03:00
Vasil Dimov
c72506c072 Merge mysql-5.5-innodb -> mysql-5.5 2011-05-22 23:12:46 +03:00
Marko Mäkelä
262668e314 Fix a bogus UNIV_SYNC_DEBUG failure in the fix of Bug #59641
or Oracle Bug #11766513.

trx_undo_free_prepared(): Do not acquire or release trx->rseg->mutex.
This code is invoked in the single-threaded part of shutdown, therefore
a mutex is not needed.
2011-05-18 15:05:08 +03:00
Marko Mäkelä
2646dd96eb Bug#12543706 - innodb-fast-shutdown=2: Assert
node->modification_counter == node->flush_counter

This bug (an assertion failure during a crash-like shutdown)
was introduced by the fix of
Bug#12323643 Clean up the InnoDB thread shutdown and assertions (WL#5136).

fil_node_close_file(): Relax the failing assertion
when innodb_fast_shutdown=2.
2011-05-17 15:15:55 +03:00
Marko Mäkelä
fd33784f71 A non-functional change related to Bug#11830883
page_rec_write_field(): Renamed from page_rec_write_index_page_no()
and inlined.
2011-05-09 11:12:26 +03:00
Jimmy Yang
5b32b2a2fe Merge from mysql-5.1-innodb to mysql-5.5-innodb 2011-05-04 03:47:30 -07:00
Jimmy Yang
ce2ed6197c Fix bug #11796673 address backward compatibility on index with
large prefix (>=768). Table with such large prefix index will not
be loaded into memory (for its metadata), unless innodb_force_recovery
is on.

rb://604 Approved by Marko
2011-05-04 03:06:21 -07:00
Mikael Ronstrom
b444c4f2d3 merge 2011-05-04 11:08:07 +02:00
Jimmy Yang
6ff930c46e Fix bug #12424282 - INNODB PERFORMANCE SCHEMA: Double accounting for OS_AIO_SYNC
I/O in os_aio_func.

Approved by Sunny Bains
2011-05-04 00:09:48 -07:00
kevin.lewis@oracle.com
6593ca560b Bug#60309 - Bug#12356829: MYSQL 5.5.9 FOR MAC OSX HAS BUG WITH FOREIGN KEY CONSTRAINTS
The innoDB global variable srv_lower_case_table_names is set to the value of lower_case_table_names declared in mysqld.h server in ha_innodb.cc.  Since this variable can change at runtime, it is reset for each handler call to ::create, ::open, ::rename_table & ::delete_table.

But it is possible for tables to be implicitly opened before an explicit handler call is made when an engine is first started or restarted.  I was able to reproduce that with the testcase in this patch on a version of InnoDB from 2 weeks ago.  It seemed like the change buffer entries for the secondary key was getting put into pages after the restart.  (But I am not sure, I did not write down the call stack while it was reproducing.)  In the current code, the implicit open, which is actually a call to dict_load_foreigns(), does not occur with this testcase.

The change is to replace srv_lower_case_table_names by an interface function in innodb.cc that retrieves the server global variable when it is needed.
2011-04-26 12:55:52 -05:00
Vasil Dimov
208b98d548 Merge mysql-5.5-innodb -> mysql-5.5 2011-04-21 08:34:21 +03:00
Marko Mäkelä
dcb5aa6627 Clarify a comment. 2011-04-20 11:29:10 +03:00
Marko Mäkelä
3af2c9a30f Remove a debug printout that is no longer needed. 2011-04-20 10:10:54 +03:00
Mikael Ronström
50b5f456c1 Merge 5.5, step 3 2011-04-15 15:58:30 +02:00
Mikael Ronström
7b079a3a7e Merge 5.5 2011-04-15 15:46:11 +02:00
Marko Mäkelä
1ef8d5fc34 Bug #12329920 ASSERT UT_ERROR IN SYNC_THREAD_LEVELS_NONEMPTY_TRX
SRV_CONC_FORCE_EXIT_INNODB

This is a bogus UNIV_SYNC_DEBUG assertion failure that I introduced
when introducing assertions for checking that InnoDB is not holding
any mutexes or rw-locks when returning control to MySQL.

srv_suspend_mysql_thread(): Release dict_operation_lock before
invoking srv_conc_force_exit_innodb(), which would now check that the
thread is not holding any mutexes or rw-locks.  After resuming, check
sync_thread_levels_nonempty_trx() and do srv_conc_force_enter_innodb()
before reacquiring the dict_operation_lock.

rb:646 approved by Sunny Bains
2011-04-12 09:22:43 +03:00
Marko Mäkelä
cdba023d9a Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-04-11 17:03:32 +03:00
Marko Mäkelä
d0b1a6466c Bug #11760042 - 52409: Assertion failure: long semaphore wait
In ha_innobase::create(), we check some things while holding an
exclusive lock on the data dictionary. Defer the locking and the
creation of transactions until after the checks have passed. The
THDVAR could hang due to a mutex wait (see Bug #11750569 - 41163:
deadlock in mysqld: LOCK_global_system_variables and LOCK_open), and
we want to avoid waiting while holding InnoDB mutexes.

innobase_index_name_is_reserved(): Replace the parameter trx_t with
THD, so that the test can be performed before starting an InnoDB
transaction. We only needed trx->mysql_thd.

ha_innobase::create(): Create transaction and lock the data dictionary
only after passing the basic tests.

create_table_def(): Move the IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS
check to ha_innobase::create(). Assign to srv_lower_case_table_names
while holding dict_sys->mutex.

ha_innobase::delete_table(), ha_innobase::rename_table(),
innobase_rename_table(): Assign srv_lower_case_table_names as late as
possible. Here, the variable is not necessarily protected by
dict_sys->mutex.

ha_innobase::add_index(): Invoke innobase_index_name_is_reserved() and
innobase_check_index_keys() before allocating anything.

rb:618 approved by Jimmy Yang
2011-04-11 16:40:28 +03:00
Vasil Dimov
1c3087bbc9 Increment InnoDB version from 1.1.6 to 1.1.7
InnoDB 1.1.6 was released with MySQL 5.5.11
2011-04-08 10:23:46 +03:00
Marko Mäkelä
1a0dde9206 Bug #11766513 - 59641: Prepared XA transaction in system after hard crash
causes future shutdown hang

InnoDB would hang on shutdown if any XA transactions exist in the
system in the PREPARED state. This has been masked by the fact that
MySQL would roll back any PREPARED transaction on shutdown, in the
spirit of Bug #12161 Xa recovery and client disconnection.

[mysql-test-run] do_shutdown_server: Interpret --shutdown_server 0 as
a request to kill the server immediately without initiating a
shutdown procedure.

xid_cache_insert(): Initialize XID_STATE::rm_error in order to avoid a
bogus error message on XA ROLLBACK of a recovered PREPARED transaction.

innobase_commit_by_xid(), innobase_rollback_by_xid(): Free the InnoDB
transaction object after rolling back a PREPARED transaction.

trx_get_trx_by_xid(): Only consider transactions whose
trx->is_prepared flag is set. The MySQL layer seems to prevent
attempts to roll back connected transactions that are in the PREPARED
state from another connection, but it is better to play it safe. The
is_prepared flag was introduced in the InnoDB Plugin.

trx_n_prepared: A new counter, counting the number of InnoDB
transactions in the PREPARED state.

logs_empty_and_mark_files_at_shutdown(): On shutdown, allow
trx_n_prepared transactions to exist in the system.

trx_undo_free_prepared(), trx_free_prepared(): New functions, to free
the memory objects of PREPARED transactions on shutdown. This is not
needed in the built-in InnoDB, because it would collect all allocated
memory on shutdown. The InnoDB Plugin needs this because of
innodb_use_sys_malloc.

trx_sys_close(): Invoke trx_free_prepared() on all remaining
transactions.
2011-04-07 21:12:54 +03:00
Sunanda Menon
c913579fcc Merge from mysql-5.5.11-release 2011-04-07 08:59:07 +02:00
Marko Mäkelä
3c5f4c30d7 Non-functional change: move a printout
from innobase_shutdown_for_mysql() to
logs_empty_and_mark_files_at_shutdown()
where the rest of the logic is located.
2011-04-06 10:34:49 +03:00
Marko Mäkelä
af7d9929fa Enable __attribute__((cold)) only for GCC 4.3 and later.
This attribute was introduced in bzr revision-id
marko.makela@oracle.com-20110405073758-b8y733yvkqum940i
and caused older GCC versions to emit warnings.
2011-04-06 09:22:36 +03:00
Marko Mäkelä
30f785bc11 Remove unused functions.
os_thread_get_curr(), os_thread_get_priority(), os_thread_set_priority(),
os_thread_get_last_error(): Remove.
2011-04-05 13:58:37 +03:00
Marko Mäkelä
5530926e72 Bug 12323643 - CLEAN UP THE INNODB THREAD SHUTDOWN AND ASSERTIONS (WL#5136)
On shutdown, do not exit threads in os_event_wait(). This method of
exiting was only used by the I/O handler threads. Exit them on a
higher level.

os_event_wait_low(), os_event_wait_time_low(): Do not exit on shutdown.

os_thread_exit(), ut_dbg_assertion_failed(), ut_print_timestamp(): Add
attribute cold, so that GCC knows that these functions are rarely
invoked and can be optimized for size.

os_aio_linux_collect(): Return on shutdown.

os_aio_linux_handle(), os_aio_simulated_handle(), os_aio_windows_handle():
Set *message1 = *message2 = NULL and return TRUE on shutdown.

fil_aio_wait(): Return on shutdown.

logs_empty_and_mark_files_at_shutdown(): Even in very fast shutdown
(innodb_fast_shutdown=2), allow the background threads to exit, but
skip the flushing and log checkpointing.

innobase_shutdown_for_mysql(): Always wait for all the threads to exit.

rb:633 approved by Sunny Bains
2011-04-05 10:37:58 +03:00
Marko Mäkelä
272fa443f8 Bug 12323643 - CLEAN UP THE INNODB THREAD SHUTDOWN AND ASSERTIONS (WL#5136)
Remove most references to thread id in InnoDB. Three references
remain: the current holder of a mutex, and the current x-lock holder
of a rw-lock, and some references in UNIV_SYNC_DEBUG checks. This
allows MySQL to change the thread associated to a client connection.

Tighten the UNIV_SYNC_DEBUG checks, trying to ensure that no InnoDB
mutex or x-lock is being held when returning control to MySQL. The
only semaphore that may be held is the btr_search_latch in shared mode.

sync_thread_levels_empty_except_dict(): A wrapper for
sync_thread_levels_empty_gen(TRUE).

sync_thread_levels_nonempty_trx(): Check that the current thread is
not holding any InnoDB semaphores, except btr_search_latch if
trx->has_search_latch.

sync_thread_levels_empty(): Unused function; remove.

trx_t: Remove mysql_thread_id and mysql_process_no.

srv_slot_t: Remove id and handle.

row_search_for_mysql(), srv_conc_enter_innodb(),
srv_conc_force_enter_innodb(), srv_conc_force_exit_innodb(),
srv_conc_exit_innodb(), srv_suspend_mysql_thread: Assert
!sync_thread_levels_nonempty_trx().

rb:634 approved by Sunny Bains
2011-04-05 10:18:43 +03:00
Vasil Dimov
1c6f766624 Merge mysql-5.5-innodb -> mysql-5.5 2011-04-04 09:12:11 +03:00
Marko Mäkelä
a120b650d2 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-03-30 14:52:26 +03:00
Marko Mäkelä
4ffb26de4b Bug#11877216 InnoDB too eager to commit suicide on a busy server
sync_array_print_long_waits(): Return the longest waiting thread ID
and the longest waited-for lock. Only if those remain unchanged
between calls in srv_error_monitor_thread(), increment
fatal_cnt. Otherwise, reset fatal_cnt.

Background: There is a built-in watchdog in InnoDB whose purpose is to
kill the server when some thread is stuck waiting for a mutex or
rw-lock. Before this fix, the logic was flawed.

The function sync_array_print_long_waits() returns TRUE if it finds a
lock wait that exceeds 10 minutes (srv_fatal_semaphore_wait_threshold).
The function srv_error_monitor_thread() will kill the server if this
happens 10 times in a row (fatal_cnt reaches 10), checked every 30
seconds. This is wrong, because this situation does not mean that the
server is hung. If the server is very busy for a little over 15
minutes, it will be killed.

Consider this example. Thread T1 is waiting for mutex M. Some time
later, threads T2..Tn start waiting for the same mutex M. If T1 keeps
waiting for 600 seconds, fatal_cnt will be incremented to 1. So far,
so good. Now, if M is granted to T1, the server was obviously not
stuck. But, T2..Tn keeps waiting, and their wait time will be longer
than 600 seconds. If 5 minutes later, some Tn has still been waiting
for more than 10 minutes for the mutex M, the server can be killed,
even though it is not stuck.

rb:622 approved by Jimmy Yang
2011-03-30 14:25:58 +03:00
Vasil Dimov
88650f36f4 Merge mysql-5.1-innodb -> mysql-5.5-innodb 2011-03-28 12:05:02 +03:00
Marko Mäkelä
538e7d1655 Bug#11766305 - 59392: Remove thr0loc.c and ibuf_inside() [part 4 of 4]
ibuf_inside(), ibuf_enter(), ibuf_exit(): Add the parameter mtr. The
flag is no longer kept in the thread-local storage but in the
mini-transaction (mtr->inside_ibuf).

mtr_start(): Clean up the comment and remove the unused return value.
mtr_commit(): Assert !ibuf_inside(mtr) in debug builds.

ibuf_mtr_start(): Like mtr_start(), but sets the flag.
ibuf_mtr_commit(), ibuf_btr_pcur_commit_specify_mtr(): Wrappers that
assert ibuf_inside().

buf_page_get_zip(), buf_page_init_for_read(),
buf_read_ibuf_merge_pages(), fil_io(), ibuf_free_excess_pages(),
ibuf_contract_ext(): Remove assertions on ibuf_inside(), because a
mini-transaction is not available.

buf_read_ahead_linear(): Add the parameter inside_ibuf.

ibuf_restore_pos(): When this function returns FALSE, it commits mtr
and must therefore do ibuf_exit(mtr).

ibuf_delete_rec(): This function commits mtr and must therefore do
ibuf_exit(mtr).

ibuf_rec_get_page_no(), ibuf_rec_get_space(), ibuf_rec_get_info(),
ibuf_rec_get_op_type(), ibuf_build_entry_from_ibuf_rec(),
ibuf_rec_get_volume(), ibuf_get_merge_page_nos(),
ibuf_get_volume_buffered_count(), ibuf_get_entry_counter_low(): Add
the parameter mtr in debug builds, for asserting ibuf_inside(mtr).

rb:585 approved by Sunny Bains
2011-03-24 14:00:14 +02:00
MySQL Build Team
a12b2a2e45 Per Jon Olav, change needed for Bug#11784056 2011-03-22 16:52:03 +01:00
Sunanda Menon
5dc4f1ef42 merge 2011-03-22 14:34:04 +01:00
Marko Mäkelä
76ec2da660 Bug#11766305 - 59392: Remove thr0loc.c and ibuf_inside() [part 3]
Remove the slot_no member of struct thr_local_struct.

enum srv_thread_type: Remove unused thread types.
srv_get_thread_type(): Unused function, remove.

thr_local_get_slot_no(), thr_local_set_slot_no(): Remove.

srv_thread_type_validate(), srv_slot_get_type(): New functions, for debugging.

srv_table_reserve_slot(): Return the srv_slot_t* directly. Do not create
thread-local storage.

srv_suspend_thread(): Get the srv_slot_t* as parameter. Return void;
the caller knows slot->event already.

srv_thread_has_reserved_slot(), srv_release_threads(): Assert
srv_thread_type_validate(type).

srv_init(): Use mem_zalloc() instead of mem_alloc(). Replace
srv_table_get_nth_slot(), because it now asserts that the kernel_mutex
is being held.

srv_master_thread(), srv_purge_thread(): Remember the slot from
srv_table_reserve_slot().

rb:629 approved by Inaam Rana
2011-03-22 13:39:16 +02:00
Marko Mäkelä
72ec03c2bd Bug#11766305 - 59392: Remove thr0loc.c and ibuf_inside() [part 2]
Add some const qualifiers to accessor and validator functions.

btr_pcur_get_up_match(), btr_pcur_get_low_match(): Add const qualifiers.

btr_pcur_get_page(), btr_pcur_get_block(), btr_pcur_get_rec(),
rec_get_start(), rec_get_end(): Define as constness-preserving macros.
In debug builds, discard the const qualifier.

page_rec_validate(), page_simple_validate_old(), page_simple_validate_new(),
page_dir_slot_check(), page_validate(): Add const qualifiers.

rb:626 approved by Sunny Bains
2011-03-21 09:56:38 +02:00
Marko Mäkelä
30a28cfbc5 Bug#11766305 - 59392: Remove thr0loc.c and ibuf_inside() [part 1]
Remove unused member mtr from btr_pcur_struct.

rb:624 approved by Sunny Bains
2011-03-21 09:27:58 +02:00
Marko Mäkelä
9a4dd4adf9 Remove trailing white space. 2011-03-15 15:24:51 +02:00
Marko Mäkelä
aacf9a8031 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-03-15 12:26:53 +02:00
Jon Olav Hauglid
9b30e2e29c Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
KEY NO 0 FOR TABLE IN ERROR LOG 

With the changes made by the patches for Bug#11751388 and
Bug#11784056, concurrent reads are allowed while secondary
indexes are created in InnoDB. This means that the metadata
lock on the affected table is not upgraded to exclusive
until the .FRM is updated at the end of ALTER TABLE processing.

The problem was that if this lock upgrade failed for some
reason (e.g. timeout), the index information in the server
and inside InnoDB would be out of sync. This would happen
since the add index operation already was committed inside 
InnoDB but the table metadata inside the server had not been
updated yet.

This patch fixes the problem by (for now) reverting the
effects of the patches for Bug#11751388 and Bug#11784056.
Concurrent reads will now again be blocked during creation
of secondary indexes in InnoDB.

Test case added to innodb_mysql_lock.test.
2011-03-09 16:06:13 +01:00
kevin.lewis@oracle.com
d072bb0d7f Bug#60196 / Bug#11831040
Setting lowercase_table_names to 2 on Windows causing Foreign Key problems

This problem was exposed by the fix for Bug#55222.  There was a codepath in dict0load.c,
dict_load_foreigns() that made sure the table name matched case sensitive in order to
load a referenced table into the dictionary as needed.  If an engine is rebooted which
accesses a table with foreign keys, and lower_case_table_names=2, then the table with
foreign keys will get an error when it is changed (insert/updated/delete).
Once the referenced tables are loaded into the dictionary cache by a select statement
on those tables, the same change would succeed because the affected code path would
not get followed.
2011-03-07 09:42:07 -06:00
Jon Olav Hauglid
c171d99ded Bug #11784056 ENABLE CONCURRENT READS WHILE CREATING
NON-PRIMARY UNIQUE INDEX USING INNODB

This patch adds the HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE
capability flag to InnoDB, indicating that concurrent reads
can be allowed while non-primary unique indexes are created.

This is an follow-up to Bug #11751388 which enabled concurrent
reads when creating non-primary non-unique indexes.

Test case added to innodb_mysql_sync.test.
2011-03-07 14:30:49 +01:00
Mikael Ronstrom
9718c52b47 merge 2011-03-04 12:35:24 +01:00
Vasil Dimov
c3b8964687 Merge mysql-5.5 -> mysql-5.5-innodb 2011-03-02 11:00:48 +02:00
Marko Mäkelä
97bbde6664 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-02-28 15:39:07 +02:00
Vasil Dimov
7bb633e7c9 Use plugin_author also for the InnoDB SE plugin
Move the const variable plugin_author to a common header file that is
being included by both ha_innodb.cc and i_s.cc
2011-02-28 11:07:22 +02:00
Vasil Dimov
e4e154e92b Change InnoDB plugins author to Oracle Corporation 2011-02-28 11:02:24 +02:00
Vasil Dimov
47741182d6 Non-functional change: use plugin_author instead of hardcoded string.
plugin_author is currently defined as "Innobase Oy" so this change is
a no-op.
2011-02-28 10:39:48 +02:00
Jimmy Yang
1e26073184 Include "ha_prototypes.h" to sync/sync0rw.c for innobase_basename(). 2011-02-25 03:21:02 -08:00
Vasil Dimov
3ce27deac3 Merge mysql-5.1-innodb -> mysql-5.5-innodb 2011-02-25 11:52:47 +02:00
Jimmy Yang
afe4b605a3 Fix Bug #11765975 __FILE__ macros expanded to full path instead of relative
in CMake builds

rb://600 approved by Sunny Bains
2011-02-25 00:33:13 -08:00
Vasil Dimov
2c9f4a23bb Merge mysql-5.5-innodb -> mysql-5.5 2011-02-23 19:33:41 +02:00
Sunny Bains
759d346e67 Revert the max value of innodb_purge_batch_size to 5000. 2011-02-23 17:56:37 +11:00
Sunny Bains
669c3e7110 Add ut0bh.h and ut0bh.c. 2011-02-23 17:48:15 +11:00
Sunny Bains
8d8ebc5b01 Remove ut0bh.h and ut0bh.c and re-add so that we can sync the file ids with
the trunk.
2011-02-23 17:44:11 +11:00
Sunny Bains
165ccf3be7 Add ut0bh.ic. 2011-02-23 07:24:34 +11:00
Sunny Bains
2cc164341a Remove ut0bh.ic from 5.5 and then re-add so that the file ids are the same
in 5.5 and trunk. First we remove the file in the commit.
2011-02-23 07:14:49 +11:00
Sunny Bains
83659a7fba Add files that were missed in bug# 11798085 commit. 2011-02-22 20:17:02 +11:00
Sunny Bains
9d6d1902e0 Bug #11766227: InnoDB purge lag much worse for 5.5.8 versus 5.1
Bug #11766501: Multiple RBS break the get rseg with mininum trx_t::no code during purge
      
Bug# 59291 changes:
      
Main problem is that truncating the UNDO log at the completion of every
trx_purge() call is expensive as the number of rollback segments is increased.
We truncate after a configurable amount of pages. The innodb_purge_batch_size
parameter is used to control when InnoDB does the actual truncate. The truncate
is done once after 128 (or TRX_SYS_N_RSEGS iterations). In other words we
truncate after purge 128 * innodb_purge_batch_size. The smaller the batch
size the quicker we truncate.
      
Introduce a new parameter that allows how many rollback segments to use for
storing REDO information. This is really step 1 in allowing complete control
to the user over rollback space management.
      
New parameters:
    i) innodb_rollback_segments = number of rollback_segments to use
       (default is now 128) dynamic parameter, can be changed anytime.
       Currently there is little benefit in changing it from the default.
      
Optimisations in the patch.
      
    i. Change the O(n) behaviour of trx_rseg_get_on_id() to O(log n)
       Backported from 5.6. Refactor some of the binary heap code.
       Create a new include/ut0bh.ic file.
      
    ii. Avoid truncating the rollback segments after every purge.
      
Related changes that were moved to a separate patch:
      
    i. Purge should not do any flushing, only wait for space to be free so that
       it only does purging of records unless it is held up by a long running
       transaction that is preventing it from progressing.
      
   ii. Give the purge thread preference over transactions when acquiring the
       rseg->mutex during commit. This to avoid purge blocking unnecessarily
       when getting the next rollback segment to purge.
      
Bug #11766501 changes:
      
Add the rseg to the min binary heap under the cover of the kernel mutex and
the binary heap mutex. This ensures the ordering of the min binary heap.
      
The two changes have to be committed together because they share the same
that fixes both issues.
      
rb://567 Approved by: Inaam Rana.
2011-02-22 16:04:08 +11:00
Vasil Dimov
60a8407231 Merge mysql-5.5-innodb -> mysql-5.5 2011-02-17 13:57:26 +02:00
Marko Mäkelä
53cfea3911 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-02-15 11:29:56 +02:00
Jimmy Yang
8586497e5d Merge from mysql-5.1-innodb to mysql-5.5-innodb 2011-02-14 02:17:51 -08:00
Mikael Ronström
80179eba3e merge 2011-02-10 18:15:19 +01:00
Vasil Dimov
4c5c1c5d0c Merge mysql-5.1-innodb -> mysql-5.5-innodb 2011-02-10 17:26:09 +02:00
Marko Mäkelä
adef5550eb Bug #59877 Wrong buffer pool selected in buf_read_ibuf_merge_pages() 2011-02-10 14:07:58 +02:00
Vasil Dimov
8a20a73a7c Increment InnoDB version from 1.1.5 to 1.1.6
InnoDB 1.1.5 was released with MySQL 5.5.9
2011-02-10 13:25:12 +02:00
Jimmy Yang
801d018411 Merge a fix for Bug #53756 ALTER TABLE ADD PRIMARY KEY affects crash recovery
This was already pushed to mysql-5.1-innodb some time ago
(revision id jimmy.yang@oracle.com-20100907054137-tpuior7hez4f5ghl)
but it was not merged to the 5.5 trees.
2011-02-10 00:58:23 -08:00
Jimmy Yang
77838ae2cd Fix Bug #59048 truncate table or create index could leave index->page
to be FIL_NULL

rb://545 approved by Sunny Bains
2011-02-09 01:15:06 -08:00
Vasil Dimov
2edb0150af Merge mysql-5.5-innodb -> mysql-5.5 2011-02-08 19:28:00 +02:00
Jonathan Perkin
d06e324e66 Merge from mysql-5.5.9-release 2011-02-08 14:59:03 +01:00
Marko Mäkelä
5dfcf7c745 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-02-08 13:39:24 +02:00
Inaam Rana
62ec6970d9 Bug #59472 increase AIO requests per IO thread limit to 256 from 32
rb://566
approved by: Sunny

When using native aio on linux each IO helper thread should be able to
handle upto 256 IO requests. The number 256 is the same which is used
for simulated aio as well. In case of windows where we also use native
aio this limit is 32 because of OS constraints. It seems that we are
using the limit of 32 for all the platforms where we are using native
aio. The fix is to use 256 on all platforms except windows (when native
aio is enabled on windows)
2011-02-07 18:43:00 -05:00
kevin.lewis@oracle.com
c8ac9f10c1 Bug#59699 - Hidden bug would cause a crash for unknown tablespace flags.
The bug would cause a crash of InnoDB if a non-standard or unknown table
flags existed in a SYS_TABLES record. This is important because the next
file version, Cheetah, will identify itself by expanding this field.  So
unless this is fixed, an older engine that tries to open a table in a
tablespace with a newer file version will crash instead of report an error
and refuse to open the table, as it should do.

Reviewed at RB://583.    Approved by Marko.
2011-02-04 08:59:30 -06:00
Marko Mäkelä
1129d230f7 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-02-02 15:58:01 +02:00
Vasil Dimov
428063064f Replay a lost change (fix for Bug#56947 InnoDB leaks memory... in 5.5)
This change was originally done in
marko.makela@oracle.com-20101011085943-50pskvsbbsujbukg
but was later lost during the merge process.
2011-02-01 18:28:41 +02:00
Marko Mäkelä
6268a3e437 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-31 10:23:38 +02:00
Vasil Dimov
102c39d344 Merge mysql-5.5-innodb -> mysql-5.5 2011-01-30 18:51:37 +02:00
Jimmy Yang
fe4e126849 Fix Bug #59390 row_merge_build_indexes() fails to register tmpfd for PFS
rb://582 approved by Marko
2011-01-28 01:38:21 -08:00
Jimmy Yang
5d2239e118 Merge from mysql-5.1-innodb to mysql-5.5-innodb 2011-01-28 01:10:40 -08:00
Jimmy Yang
a9f1c9f31b Fix Bug #59465 btr_estimate_number_of_different_key_vals use incorrect offset
for external_size
      
rb://581 approved by Marko
2011-01-28 00:50:10 -08:00
Marko Mäkelä
c9c4e4f880 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-27 13:30:59 +02:00
Marko Mäkelä
3db404c31f Bug#59440 Race condition in XA ROLLBACK and XA COMMIT after server restart
trx_get_trx_by_xid(): Invalidate trx->xid after a successful lookup,
so that subsequent callers will not find the same transaction.

The only callers of trx_get_trx_by_xid() will be invoking
innobase_commit_low() or innobase_rollback_trx(), and those code paths
should not depend on trx->xid.

rb://584 approved by Jimmy Yang
2011-01-27 13:27:29 +02:00
Marko Mäkelä
6f6ad4e8b2 ibuf_contract_ext(): Remove an #if 0 section of code
that refers to trx_sys_set_ibuf_format().
Change buffer format tagging was never implemented.
2011-01-27 10:12:00 +02:00
Jon Olav Hauglid
5e03579061 Bug #42230 during add index, cannot do queries on storage engines
that implement add_index

The problem was that ALTER TABLE blocked reads on an InnoDB table
while adding a secondary index, even if this was not needed. It is
only needed for the final step where the .frm file is updated.

The reason queries were blocked, was that ALTER TABLE upgraded the
metadata lock from MDL_SHARED_NO_WRITE (which blocks writes) to
MDL_EXCLUSIVE (which blocks all accesses) before index creation.

The way the server handles index creation, is that storage engines
publish their capabilities to the server and the server determines
which of the following three ways this can be handled: 1) build a
new version of the table; 2) change the existing table but with
exclusive metadata lock; 3) change the existing table but without
metadata lock upgrade.

For InnoDB and secondary index creation, option 3) should have been
selected. However this failed for two reasons. First, InnoDB did
not publish this capability properly.

Second, the ALTER TABLE code failed to made proper use of the
information supplied by the storage engine. A variable
need_lock_for_indexes was set accordingly, but was not later used.
This patch fixes this problem by only doing metadata lock upgrade
before index creation/deletion if this variable has been set.

This patch also changes some of the related terminology used 
in the code. Specifically the use of "fast" and "online" with
respect to ALTER TABLE. "Fast" was used to indicate that an
ALTER TABLE operation could be done without involving a
temporary table. "Fast" has been renamed "in-place" to more
accurately describe the behavior.

"Online" meant that the operation could be done without taking
a table lock. However, in the current implementation writes
are always prohibited during ALTER TABLE and an exclusive
metadata lock is held while updating the .frm, so ALTER TABLE
is not completely online. This patch replaces "online" with 
"in-place", with additional comments indicating if concurrent
reads are allowed during index creation/deletion or not.

An important part of this update of terminology is renaming
of the handler flags used by handlers to indicate if index
creation/deletion can be done in-place and if concurrent reads
are allowed. For example, the HA_ONLINE_ADD_INDEX_NO_WRITES
flag has been renamed to HA_INPLACE_ADD_INDEX_NO_READ_WRITE,
while HA_ONLINE_ADD_INDEX is now HA_INPLACE_ADD_INDEX_NO_WRITE.
Note that this is a rename to clarify current behavior, the
flag values have not changed and no flags have been removed or
added.

Test case added to innodb_mysql_sync.test.
2011-01-26 14:23:29 +01:00
Marko Mäkelä
e66716311a Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-26 10:02:52 +02:00
Sunny Bains
1ffb70a309 In sync_close() fix a bug introduced by the fix for Bug #59683 where we iterate
over the mutex list and free each mutex. When UNIV_MEM_DEBUG is defined, we
need skip the hash mutex.

It is a minor bug affecting only UNIV_SYNC_DEBUG builds, found by Michael.
2011-01-26 09:33:59 +11:00
Marko Mäkelä
71e435e461 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-25 12:35:35 +02:00
Marko Mäkelä
939088d37f Bug#59464 Race condition in row_vers_build_for_semi_consistent_read
row_vers_build_for_semi_consistent_read(): Dereference version_trx before
releasing kernel_mutex, but not thereafter.
2011-01-25 11:54:50 +02:00
Marko Mäkelä
29deba81b8 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-25 10:51:13 +02:00
Sunny Bains
2a0bcbc9bd Fix Bug #59683 :InnoDB latch deadlock detector/violation debug code is very slow
There are two main pain points, one is lookup by thread id for sync_thread_t
and the other is to do a lookup  by latch or level in sync_thread_t::levels.
Changed the sync_thread_t::levels lookup and reserve operation from O(N)
to O(1).

Pure lookups are still O(N), the main change for pure lookup is that we no
longer need to search up to SYNC_THREAD_N_LEVELS but only up to the number
of slots actually ever used ie. it is possible some were used in the past
but are now on the free list. If the in_use count drops to 0 we reset the
free list too.

Overload the sync_level_t::level field to track the free list. If
sync_thread_t::latch == NULL then sync_thread_t::level contains the ordinal
value of the previous free entry.

rb://580 Approved by Jimmy Yang.
2011-01-25 18:25:36 +11:00
Marko Mäkelä
761bc05d69 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-18 12:30:33 +02:00
Marko Mäkelä
fe09f9e21b Bug#59579 rw_lock_debug_print outputs to stderr
rw_lock_debug_print(): Add parameter FILE* for specifying the output stream.
rw_lock_list_print_info(): Invoke rw_lock_debug_print() on file, not stderr.
2011-01-18 12:25:13 +02:00
Marko Mäkelä
c344344ab4 Merge from mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-17 14:11:43 +02:00
Marko Mäkelä
30fbb1515b Non-functional changes.
Remove the unused data type dict_cluster_t.
Remove a bogus comment about latching order.
2011-01-17 14:06:48 +02:00
Jimmy Yang
c4c90d912a Merge from mysql-5.1-innodb to mysql-5.5-innodb 2011-01-14 23:24:47 -08:00
Jimmy Yang
669ce69483 Fix Bug#30423 "InnoDBs treatment of NULL in index stats causes bad
"rows examined" estimates". This change implements "innodb_stats_method"
with options of "nulls_equal", "nulls_unequal" and "null_ignored".
      
rb://553 approved by Marko
2011-01-14 09:02:28 -08:00
Mikael Ronstrom
f904d6eb7a Removed dependency no longer correct 2011-01-12 14:44:25 +01:00
Mikael Ronstrom
21850d2903 merge 2011-01-12 14:43:03 +01:00
Mikael Ronstrom
cb59b06c40 BUG#59392, removed thread local storage use in MySQL Threads by storing ibuf_inside indicator in MTR object instead 2011-01-12 14:31:17 +01:00
Marko Mäkelä
b95d0b3cd6 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2011-01-10 15:37:55 +02:00
Georgi Kodinov
7fd0c36b7b merge 2011-01-10 15:09:57 +02:00
Georgi Kodinov
23d1eef773 automerge 2011-01-07 15:30:54 +02:00
Vasil Dimov
c9d224afe0 Fix InnoDB style after mikael@dator8-20101217205840-i7ltx8m6z3uc42kh 2011-01-07 13:54:07 +02:00
Vasil Dimov
b192c11c08 Merge mysql-5.5 -> mysql-5.5-innodb 2011-01-07 13:49:06 +02:00
Jimmy Yang
e73cb16593 Merge from mysql-5.1-security to mysql-5.5-security 2011-01-07 00:00:36 -08:00
Jimmy Yang
a9c095a06d merge from mysql-5.1-innodb to mysql-5.5-innodb 2011-01-06 19:50:49 -08:00
Sunny Bains
dead1dc42a Fix Bug #58653 - Sporadic crash due to assertion failure 0 == space->n_pending_flushes
Check whether the master and purge thread are active after creating them. Do
not proceed until both threads have started. We do this by checking whether a
slot has been reserved by both the respective threads.
      
Add srv_thread_has_reserved_slot() returns slot no or ULINT_UNDEFINED.
      
rb://536 Approved by Jimmy
2011-01-06 21:41:30 +11:00
Vasil Dimov
91fc720350 Merge mysql-5.1-innodb -> mysql-5.5-innodb 2011-01-06 09:19:02 +02:00
Vasil Dimov
b9f2234890 (Builtin InnoDB) Fix Bug#59303 Correct URL in crash message
old URL: http://dev.mysql.com/doc/refman/5.1/en/forcing-recovery.html
new URL: http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html

Notice that there is a redirect from the old URL to the new URL, so visiting
the old URL does not give "page not found" error.
2011-01-06 09:05:45 +02:00
Jimmy Yang
e5b7551e43 merge from mysql-5.1-innodb to mysql-5.5-innodb 2011-01-05 05:47:15 -08:00
Jimmy Yang
7a9120a119 Fix Bug #59197 double quote in field comment prevents foreign key
constraint creation

rb://557 Approved by Sunny Bains
2011-01-04 22:44:12 -08:00
Jimmy Yang
0f412ffb59 Fix Bug #59157 valgrind conditional jump warning from dict_load_foreign.
This is 5.1 built-in specific as the dict_table_t strcture is allocated
with mem_heap_zalloc since 5.1 plugin.

Approved by Sunny Bains
2011-01-04 22:31:46 -08:00
Mikael Ronstrom
c1986098bf merge 2011-01-04 18:46:01 +01:00
Vasil Dimov
99e5d278a3 PS-instrument the array of latches (rw locks) dict_table_stats_latches[].
This adds 64 new rows to performance_schema.rwlock_instances.

This patch will make perfschema.binlog_mix perfschema.binlog_row tests fail,
but they will be fixed by http://lists.mysql.com/commits/127862

Approved by:	Jimmy (rb://554)
2011-01-04 11:46:20 +02:00
Calvin Sun
cc79797ea5 Fix a build error on Windows, introduced by revision-id:
marko.makela@oracle.com-20101221112722-1yxxzzgqtem8bcm7

The fix was suggested by Jimmy.
2010-12-27 23:01:39 -06:00
Marko Mäkelä
85d668b45c Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-12-21 14:05:10 +02:00
Mikael Ronstrom
2a294a1989 BUG#59013, make partition handler not miss HA_STATUS_NO_LOCK, add HA_STATUS_VARIABLE_EXTRA to remove InnoDB bottleneck 2010-12-17 21:58:40 +01:00
Georgi Kodinov
24a40d0b77 merge 2010-12-17 15:10:40 +02:00
Vasil Dimov
a79cd543ce Increment InnoDB version from 1.1.4 to 1.1.5
InnoDB 1.1.4 was released with MySQL 5.5.8
2010-12-16 09:53:07 +02:00
kevin.lewis@oracle.com
9fef50565e 55222 - Previous patch had a bug in unused code which was reactivated in
mysql-trunk-innodb in rev revno: 3367  Tue 2010-12-07 02:25:25-0800.
The crash happens only when lower_case_table_names=2, such as on MacOS,
when running the new testcase innodb-system-table-view.  Specifically,
it crashes when any query is made against the INFORMATION_SCHEMA.
INNODB_SYS_FOREIGN table.  The function dict_process_sys_foreign_rec()
is only used for displaying SYS_FOREIGN records so it does not need a
lookup version of those names to be allocated. In this patch, those new
function calls are deleted.
2010-12-09 10:42:35 -06:00
Jimmy Yang
e2131e678f Merge from mysql-5.1-innodb to mysql-5.5-innodb. 2010-12-09 01:32:53 -08:00
Jimmy Yang
19a2f5cd21 Fix Bug #58643 InnoDB: too long table name
rb://531 approved by Sunny Bains
2010-12-05 18:42:23 -08:00
Vasil Dimov
219138f652 Cherry pick vasil.dimov@oracle.com-20101201140708-fsc5xlu9bkpov6pv
from mysql-trunk-innodb. The same problem also exists in 5.5.

  X revision-id: vasil.dimov@oracle.com-20101201140708-fsc5xlu9bkpov6pv
  X committer: Vasil Dimov <vasil.dimov@oracle.com>
  X branch nick: mysql-trunk-innodb
  X timestamp: Wed 2010-12-01 16:07:08 +0200
  X message:
  X   Fix Bug#58432 innodb.innodb_bug56143 fails under valgrind
  X   
  X   Use a longer timeout for semaphore waits if (possibly) running under
  X   Valgrind.
  X   
  X   Approved by:	Marko (via IRC)
2010-12-03 09:35:53 +02:00
Vasil Dimov
d331e48556 Define MYSQL_(MAJOR|MINOR)_VERSION the way things are defined in CMake
instead of hacking a custom ADD_DEFINITIONS().

Approved by:	Kent Boortz (via IRC)
2010-12-02 12:04:10 +02:00
Marko Mäkelä
5166f9d5c2 Merge from mysql-5.5-innodb to local. 2010-12-02 10:55:27 +02:00
Vasil Dimov
deade71e23 Use "rep; nop" in InnoDB if it is available and "pause" is not 2010-12-02 10:36:45 +02:00
Marko Mäkelä
aeb23e24fe Fix UNIV_MEM_DEBUG compilation failure caused by Bug#58226 fix.
To fix Bug#58226 (speed up UNIV_DEBUG), among other things we no longer
disable the inlining of the functions that are defined in InnoDB .ic files.
Inside UNIV_MEM_DEBUG, there was an implicit type conversion from void*
that is all right in C, but not in C++. Now that inlining was enabled,
the C++ compiler would see the code and complain.

Approved by Jimmy Yang on IRC.
2010-12-02 10:32:27 +02:00
Marko Mäkelä
019cbc1795 Bug#58212 Possible deadlock in change buffer in debug builds
ibuf_page(): Renamed to ibuf_page_low(). Add the parameters file, line
so that the latch diagnostics will be more meaningful.
In debug builds, add the parameter ibool x_latch. When x_latch=FALSE,
do not x-latch the page, but only buffer-fix it for reading the bit.
In UNIV_SYNC_DEBUG, display a message if an insert buffer bitmap page
was already latched. (The message should be displayed in those cases
where the code would have previously failed.)

ibuf_page(): A wrapper macro for ibuf_page_low(). Pass x_latch=TRUE.

ibuf_bitmap_page_get_bits(): Renamed to ibuf_bitmap_page_get_bits_low().
In UNIV_DEBUG, add the parameter latch_mode.
Remove the parameter mtr unless UNIV_DEBUG is defined.

ibuf_bitmap_page_get_bits(): A wrapper macro for
ibuf_bitmap_page_get_bits_low(). Pass latch_type=MTR_MEMO_PAGE_X_FIX.

buf_page_get_gen(): Use ibuf_page_low(x_latch=FALSE) in the debug assertion.
This avoids the possible deadlock.
2010-12-01 15:09:02 +02:00
Marko Mäkelä
ac8847655e Bug#58226 Some InnoDB debug checks consume too much CPU time
Do not disable InnoDB inlining when UNIV_DEBUG is defined. The
inlining is now solely controlled by the preprocessor symbol
UNIV_MUST_NOT_INLINE and by any compiler options.

mtr_memo_contains(): Add an explicit type conversion from void*, so
that the function can be compiled by a C++ compiler. Previously, this
function was never seen by the C++ compiler, because it is only
present in UNIV_DEBUG builds and InnoDB inlining used to be disabled.

buf_flush_validate_skip(): A wrapper that skips most calls of
buf_flush_validate_low(). Invoked by debug assertions in
buf_flush_insert_into_flush_list() and buf_flush_remove().

fil_validate_skip(): A wrapper that skips most calls of
fil_validate(). Invoked by debug assertions in fil_io() and fil_io_wait().

os_aio_validate_skip(): A wrapper that skips most calls of
os_aio_validate(). Invoked by debug assertions in
os_aio_func(), os_aio_windows_handle() and os_aio_simulated_handle.

os_get_os_version(): Only include this function if __WIN__ is defined.

sync_array_deadlock_step(): Slight optimizations. This function is a
major CPU consumer in UNIV_SYNC_DEBUG builds.
2010-12-01 10:43:33 +02:00
Marko Mäkelä
ba874a7d9d Fix a compilation error that was introduced in the Bug #55222 fix
(bzr revision id kevin.lewis@oracle.com-20101130182552-hfydggaeeys3tjqx).
2010-12-01 10:36:54 +02:00
Marko Mäkelä
2ed5c7d1d2 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-12-01 10:09:32 +02:00
kevin.lewis@oracle.com
dd143b8900 Fix compiler warning for Bug#55222 patch. 2010-11-30 20:13:02 -06:00
kevin.lewis@oracle.com
a53845ca45 Bug#55222 - RB://517 - Approved by Sunny
InnoDB does not attempt to handle lower_case_table_names == 2 when looking
up foreign table names and referenced table name.  It turned that server
variable into a boolean and ignored the possibility of it being '2'.  

The setting lower_case_table_names == 2 means that it should be stored and
displayed in mixed case as given, but compared internally in lower case.
Normally the server deals with this since it stores table names.  But
InnoDB stores referential constraints for the server, so it needs to keep
track of both lower case and given names.

This solution creates two table name pointers for each foreign and referenced
table name.  One to display the name, and one to look it up.  Both pointers
point to the same allocated string unless this setting is 2.  So the overhead
added is not too much.

Two functions are created in dict0mem.c to populate the ..._lookup versions
of these pointers.  Both dict_mem_foreign_table_name_lookup_set() and
dict_mem_referenced_table_name_lookup_set() are called 5 times each.
2010-11-30 12:25:52 -06:00
kevin.lewis@oracle.com
234a67bb9f RB://518 approved by Jimmy Yang and Sunny bains
Code cleanup after changes for Bug 56628.  The general approach for 
InnoDB is to make a reference to each enum value whenever it is used in a
switch statement.  In addition, no default case should be used for switch 
statements on enum types.  This assures that if there is ever any change 
in the enum values, the switch will need to change to reflect it since a 
compiler warning will occur.  In this case, the enum row_type is declared 
in handler.h and could be changed for another storage engine.  If so, a 
warning will occur in the InnoDB build.  

Other changes;
* This patch uses 2 macros to help consolidate warning messages that
   need to occur twice in the single switch for row_format.
* Using row_format as the variable name to distinguish it from the enum
  type.
* Function declaration format correction.
2010-11-30 10:06:11 -06:00
Sunny Bains
e07c6806a3 Merge from mysql-5.1-security to mysql-5.5-security. 2010-11-30 21:44:06 +11:00
Sunny Bains
42116cfe28 Fix Bug# 58459 - assert slot->in_use == FALSE while starting purge thread.
Fix a race condition in srv_master_thread(). We need to acquire the kernel
mutex before calling srv_table_reserve_slot(). Add a mutex_own() assertion
in srv_table_reserve_slot().
2010-11-30 16:51:40 +11:00
Vasil Dimov
e301078998 Make output from innobase_start_or_create_for_mysql() consistent
Prefix all printed lines with a timestamp and write one space between
the timestamp and "InnoDB:".
2010-11-29 14:53:09 +02:00
Vasil Dimov
24d1b3ef88 Fix pointers to documentation
Do not print pointer to the 5.1 documentation from within MySQL 5.5.

Instead of hardcoding the MySQL version, use the MAJOR_VERSION and
MINOR_VERSION CMake variables defined at top-level.
2010-11-29 14:50:26 +02:00
Vasil Dimov
ab710966a5 Merge mysql-5.5-bugteam -> mysql-5.5-innodb 2010-11-29 09:08:23 +02:00
Jimmy Yang
1a83ee844b Fix Bug #58461 InnoDB should show aggregated result for multiple
buffer pool instance.

rb://526 approved by Sunny Bains
2010-11-28 17:43:55 -08:00
Georgi Kodinov
c5987223db merge 2010-11-26 14:51:48 +02:00
Vasil Dimov
e8cdc991cd Fix the PAUSE instruction handling in InnoDB
Previously HAVE_IB_PAUSE_INSTRUCTION was never defined and thus InnoDB
never used the PAUSE instruction on non-windows even if it was available.
Probably the check was never migrated from autotools'
storage/innobase/plug.in to storage/innobase/CMakeLists.txt.

Since the check for PAUSE is done at top-level configure.cmake we can
use the result from there (HAVE_PAUSE_INSTRUCTION) instead of rolling
InnoDB's own HAVE_IB_PAUSE_INSTRUCTION (the check is identical anyway).
2010-11-26 10:54:12 +02:00
Sunny Bains
96bab278a4 Merge from mysql-5.1-innodb to mysql-5.5-innodb. Test was adjusted. 2010-11-24 14:36:00 +11:00
Vasil Dimov
070bf07b3a Fix Bug#57739 Scary messages in error log
Silence a warning about old table name when InnoDB tests whether the
format has changed using a nonexistent table name.

Reviewed by:	bar@mysql.com, marko.makela@oracle.com
2010-11-22 16:08:51 +02:00
Ramil Kalimullin
cc5263b223 Manual merge from mysql-5.5-bugteam. 2010-11-22 14:47:28 +03:00
Ramil Kalimullin
0628752fe9 Manual-merge from mysql-5.1-bugteam. 2010-11-22 12:21:10 +03:00
Davi Arnaut
f6deb00a56 WL#5665: Removal of the autotools-based build system
The autotools-based build system has been superseded and
is being removed in order to ease the maintenance burden on
developers tweaking and maintaining the build system.

In order to support tools that need to extract the server
version, a new file that (only) contains the server version,
called VERSION, is introduced. The file contents are human
and machine-readable. The format is:

MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=8
MYSQL_VERSION_EXTRA=-rc

The CMake based version extraction in cmake/mysql_version.cmake
is changed to extract the version from this file. The configure
to CMake wrapper is retained for backwards compatibility and to
support the BUILD/ scripts. Also, a new a makefile target
show-dist-name that prints the server version is introduced.
2010-11-20 12:47:50 -02:00
Vasil Dimov
fe136f1599 Fix Bug#58279 Incorrect enabling of UNIV_DEBUG in debug builds
Checking "IF(WITH_DEBUG)" does not work for multi-configuration CMake
generators like VS or XCode. See
http://forge.mysql.com/wiki/CMake#Debug-only_options
2010-11-19 15:45:18 +02:00
Ramil Kalimullin
aab0c52976 Manual-merge from 5.5-bugfixing. 2010-11-18 15:01:50 +03:00
Jimmy Yang
f4cec49456 Fix Bug #16290 Unclear error message when adding foreign key constraint
rb://502 approved by Sunny Bains
2010-11-14 23:08:04 -08:00
Marko Mäkelä
a56c2e382d Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-11 15:13:52 +02:00
Vasil Dimov
0fe7ef2847 Merge mysql-5.1-innodb -> mysql-5.5-innodb 2010-11-11 13:25:35 +02:00
Marko Mäkelä
46b8fd922a Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-11 12:22:27 +02:00
Vasil Dimov
6dee4b50af Increment InnoDB version from 1.1.3 to 1.1.4
InnoDB 1.1.3 was released with MySQL 5.5.7-rc
2010-11-11 08:50:41 +02:00
Jimmy Yang
956ada2e2d Merge from mysql-5.1-innodb to mysql-5.5-innodb 2010-11-10 21:51:00 -08:00
Jimmy Yang
f5c5d23a20 Port fix for Bug #48026 to 5.1 built-in and plugin: Log start and end
of InnoDB buffer pool initialization to the error log
2010-11-10 21:27:10 -08:00
Vasil Dimov
22075c8fee Merge mysql-5.5-innodb from bk-internal into my local repo 2010-11-10 10:52:45 +02:00
Vasil Dimov
f97201dcb9 Merge mysql-5.1-bugteam -> mysql-5.1-innodb 2010-11-08 16:46:26 +02:00
Vasil Dimov
4117327019 Merge mysql-5.5-bugteam -> mysql-5.5-innodb 2010-11-08 16:44:59 +02:00
kevin.lewis@oracle.com
f0cc2b6200 Bug57960 - In ha_innodb.cc, get_foreign_key_info() make sure the
referenced_table name uses the actual length of the table name.
2010-11-04 10:18:05 -05:00
Marko Mäkelä
cd4c9520fc Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-04 15:20:28 +02:00
Georgi Kodinov
7e2fa49edf merge 2010-11-03 16:09:17 +02:00
Marko Mäkelä
515c24480e Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-03 14:51:15 +02:00
Marko Mäkelä
bf770f3615 rw_lock_debug_print(): Output the thread ID in unsigned format. 2010-11-03 14:38:36 +02:00
Vasil Dimov
927b4a1281 Merge mysql-5.1-innodb -> mysql-5.5-innodb 2010-11-03 12:07:16 +02:00
Marko Mäkelä
18d38d4890 Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-03 11:25:14 +02:00
Sunny Bains
2c0e21aca4 Merge from mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-03 14:14:44 +11:00
kevin.lewis@oracle.com
8cf52ba106 In this patch, existing tests innodb_bug54679.test and innodb_bug56632.test are
removed and replaced by the comprehensive innodb-create-options.test.
It uses the rules listed in the comments at the top of that test.
  
This patch introduces these differences from previous behavior;
1)  KEY_BLOCK_SIZE=0 is allowed by Innodb in both strict and non-strict mode
with no errors or warnings. It was previously used by the server to set 
KEY_BLOCK_SIZE to undefined.  (Bug#56628)
2)  An explicit valid non-DEFAULT ROW_FORMAT always takes priority over a
valid KEY_BLOCK_SIZE. (bug#56632)
3)  Automatic use of COMPRESSED row format is only done if the ROW_FORMAT
is DEFAULT or unspecified.
4)  ROW_FORMAT=FIXED is prevented in strict mode.

This patch also includes various formatting changes for consistency with
InnoDB coding standards.

Related Bugs
Bug#54679: ALTER TABLE causes compressed row_format to revert to compact
Bug#56628: ALTER TABLE .. KEY_BLOCK_SIZE=0 produces untrue warning or unnecessary error
Bug#56632: ALTER TABLE implicitly changes ROW_FORMAT to COMPRESSED
2010-11-02 16:54:23 -05:00
kevin.lewis@oracle.com
64d07bf74c Merge 2010-11-02 10:04:16 -05:00
kevin.lewis@oracle.com
e0efcfe807 Bug#57904 - Only one INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS was displayed
per table from Innodb
2010-11-02 10:03:14 -05:00
Marko Mäkelä
290925226b Merge mysql-5.1-innodb to mysql-5.5-innodb. 2010-11-02 09:34:09 +02:00
Jon Olav Hauglid
a4a11329fc Backport from mysql-trunk-bugfixing of:
------------------------------------------------------------
revno: 3309
committer: Tor Didriksen <tor.didriksen@oracle.com>
branch nick: trunk-bugfixing
timestamp: Mon 2010-11-01 08:58:27 +0100
message:
  Bug#45288: pb2 returns a lot of compilation warnings
  
  DBG build broken on binary-werror-linux-x86_64-tar-gz
  storage/innobase/os/os0sync.c:659: warning: 'timed_out' may be used uninitialized in this function
2010-11-01 14:12:59 +01:00
Marko Mäkelä
e5ad4e2055 Start preprocessor directive from column 1. 2010-11-01 10:49:28 +02:00
Marko Mäkelä
a576cd5cfb Bug #57579 blobs cause a thread to wait for itself endlessly
btr_estimate_n_rows_in_range_on_level(): Always do mtr_commit(),
so that the page will not remain pinned indefinitely.
2010-11-01 10:18:33 +02:00
Georgi Kodinov
97a06e4d9a merge 2010-10-29 15:25:18 +03:00