Skip to content

Commit

Permalink
Merge branch 'merge/merge-xtradb-5.5' into 5.5
Browse files Browse the repository at this point in the history
5.5.46-37.6
  • Loading branch information
vuvova committed Dec 9, 2015
2 parents 1a72c6f + 9457139 commit 142b725
Show file tree
Hide file tree
Showing 16 changed files with 318 additions and 50 deletions.
17 changes: 16 additions & 1 deletion storage/xtradb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -136,6 +136,18 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
)
CHECK_C_SOURCE_RUNS(
"#include<stdint.h>
int main()
{
unsigned char c;
__atomic_test_and_set(&c, __ATOMIC_ACQUIRE);
__atomic_clear(&c, __ATOMIC_RELEASE);
return(0);
}"
HAVE_IB_GCC_ATOMIC_TEST_AND_SET
)
ENDIF()

IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
Expand All @@ -145,6 +157,9 @@ ENDIF()
IF(HAVE_IB_GCC_ATOMIC_BUILTINS_64)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS_64=1)
ENDIF()
IF(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_TEST_AND_SET=1)
ENDIF()

IF(HAVE_IB_GCC_SYNC_SYNCHRONISE)
ADD_DEFINITIONS(-DHAVE_IB_GCC_SYNC_SYNCHRONISE=1)
Expand Down
47 changes: 40 additions & 7 deletions storage/xtradb/btr/btr0cur.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
Expand Down Expand Up @@ -318,7 +318,12 @@ btr_cur_latch_leaves(

ut_a(page_is_comp(get_block->frame)
== page_is_comp(page));
ut_a(btr_page_get_next(get_block->frame, mtr)

/* For fake_change mode we avoid a detailed validation
as it operate in tweaked format where-in validation
may fail. */
ut_a(sibling_mode == RW_NO_LATCH
|| btr_page_get_next(get_block->frame, mtr)
== page_get_page_no(page));
}
#endif /* UNIV_BTR_DEBUG */
Expand Down Expand Up @@ -2228,6 +2233,7 @@ btr_cur_optimistic_update(
ulint max_size;
ulint new_rec_size;
ulint old_rec_size;
ulint max_ins_size = 0;
dtuple_t* new_entry;
roll_ptr_t roll_ptr;
trx_t* trx;
Expand Down Expand Up @@ -2339,6 +2345,11 @@ btr_cur_optimistic_update(
: (old_rec_size
+ page_get_max_insert_size_after_reorganize(page, 1));

if (!page_zip) {
max_ins_size = page_get_max_insert_size_after_reorganize(
page, 1);
}

if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
&& (max_size >= new_rec_size))
|| (page_get_n_recs(page) <= 1))) {
Expand Down Expand Up @@ -2395,10 +2406,14 @@ btr_cur_optimistic_update(
rec = btr_cur_insert_if_possible(cursor, new_entry, 0/*n_ext*/, mtr);
ut_a(rec); /* <- We calculated above the insert would fit */

if (page_zip && !dict_index_is_clust(index)
if (!dict_index_is_clust(index)
&& page_is_leaf(page)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
if (page_zip) {
ibuf_update_free_bits_zip(block, mtr);
} else {
ibuf_update_free_bits_low(block, max_ins_size, mtr);
}
}

/* Restore the old explicit lock state on the record */
Expand Down Expand Up @@ -2507,6 +2522,7 @@ btr_cur_pessimistic_update(
ulint n_reserved;
ulint n_ext;
ulint* offsets = NULL;
ulint max_ins_size = 0;

*big_rec = NULL;

Expand Down Expand Up @@ -2659,6 +2675,11 @@ btr_cur_pessimistic_update(
/* skip CHANGE, LOG */
err = DB_SUCCESS;
goto return_after_reservations;
}

if (!page_zip) {
max_ins_size = page_get_max_insert_size_after_reorganize(
page, 1);
}

/* Store state of explicit locks on rec on the page infimum record,
Expand Down Expand Up @@ -2706,10 +2727,15 @@ btr_cur_pessimistic_update(
big_rec_vec != NULL && (flags & BTR_KEEP_POS_FLAG),
mtr);

if (page_zip && !dict_index_is_clust(index)
if (!dict_index_is_clust(index)
&& page_is_leaf(page)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
if (page_zip) {
ibuf_update_free_bits_zip(block, mtr);
} else {
ibuf_update_free_bits_low(block, max_ins_size,
mtr);
}
}

err = DB_SUCCESS;
Expand Down Expand Up @@ -4016,7 +4042,14 @@ btr_estimate_number_of_different_key_vals(

page = btr_cur_get_page(&cursor);

SRV_CORRUPT_TABLE_CHECK(page, goto exit_loop;);
DBUG_EXECUTE_IF("ib_corrupt_page_while_stats_calc",
page = NULL;);

SRV_CORRUPT_TABLE_CHECK(page,
{
mtr_commit(&mtr);
goto exit_loop;
});

rec = page_rec_get_next(page_get_infimum_rec(page));

Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/dict/dict0crea.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ dict_create_index_step(
>= DICT_TF_FORMAT_ZIP);

node->index = dict_index_get_if_in_cache_low(index_id);
ut_a(err == DB_SUCCESS ? node->index != NULL : node->index == NULL);
ut_a((node->index == 0) == (err != DB_SUCCESS));

if (err != DB_SUCCESS) {

Expand Down
88 changes: 84 additions & 4 deletions storage/xtradb/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,19 @@ thd_supports_xa(
return(THDVAR((THD*) thd, support_xa));
}

/******************************************************************//**
Check the status of fake changes mode (innodb_fake_changes)
@return true if fake change mode is enabled. */
extern "C" UNIV_INTERN
ibool
thd_fake_changes(
/*=============*/
void* thd) /*!< in: thread handle, or NULL to query
the global innodb_supports_xa */
{
return(THDVAR((THD*) thd, fake_changes));
}

/******************************************************************//**
Returns the lock wait timeout for the current connection.
@return the lock wait timeout, in seconds */
Expand Down Expand Up @@ -1800,7 +1813,15 @@ innobase_trx_init(
trx->check_unique_secondary = !thd_test_options(
thd, OPTION_RELAXED_UNIQUE_CHECKS);

trx->fake_changes = THDVAR(thd, fake_changes);
/* Transaction on start caches the fake_changes state and uses it for
complete transaction lifetime.
There are some APIs that doesn't need an active transaction object
but transaction object are just use as a cache object/data carrier.
Before using transaction object for such APIs refresh the state of
fake_changes. */
if (trx->state == TRX_NOT_STARTED) {
trx->fake_changes = thd_fake_changes(thd);
}

#ifdef EXTENDED_SLOWLOG
if (thd_log_slow_verbosity(thd) & (1ULL << SLOG_V_INNODB)) {
Expand Down Expand Up @@ -3620,12 +3641,26 @@ innobase_commit(
/* No-op in XtraDB */
trx_search_latch_release_if_reserved(trx);

/* If fake-changes mode = ON then allow
SELECT (they are read-only) and
CREATE ... SELECT * from table (Well this doesn't open up DDL for InnoDB
as ha_innobase::create will return appropriate error if fake-change = ON
but if create is trying to use other SE and SELECT is executing on
InnoDB table then we allow SELECT to proceed.
Ideally, statement like this should be marked CREATE_SELECT like
INSERT_SELECT but unfortunately it doesn't). */
if (UNIV_UNLIKELY(trx->fake_changes
&& (thd_sql_command(thd) != SQLCOM_SELECT
&& thd_sql_command(thd) != SQLCOM_CREATE_TABLE)
&& (all || (!thd_test_options(thd,
OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))))) {

innobase_rollback(hton, thd, all); /* rollback implicitly */
thd->stmt_da->reset_diagnostics_area(); /* because debug assertion code complains, if something left */
/* rollback implicitly */
innobase_rollback(hton, thd, all);

/* because debug assertion code complains, if something left */
thd->stmt_da->reset_diagnostics_area();

DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
/* Transaction is deregistered only in a commit or a rollback. If
Expand Down Expand Up @@ -12714,6 +12749,46 @@ innodb_change_buffering_update(
*static_cast<const char*const*>(save);
}

#ifdef UNIV_DEBUG
/*************************************************************//**
Check if it is a valid value of innodb_track_changed_pages.
Changed pages tracking is not working correctly without initialization
procedure on server startup. The function allows to temporary
disable tracking, but only if the feature was enabled on startup.
This function is registered as a callback with MySQL.
@return 0 for valid innodb_track_changed_pages */
static
int
innodb_track_changed_pages_validate(
THD* thd, /*!< in: thread handle */
struct st_mysql_sys_var* var, /*!< in: pointer to system
variable */
void* save, /*!< out: immediate result
for update function */
struct st_mysql_value* value) /*!< in: incoming bool */
{
static bool enabled_on_startup = false;
long long intbuf = 0;

if (value->val_int(value, &intbuf)) {
/* The value is NULL. That is invalid. */
return 1;
}

if (srv_track_changed_pages || enabled_on_startup) {
enabled_on_startup = true;
*reinterpret_cast<ulong*>(save)
= static_cast<ulong>(intbuf);
return 0;
}

if (intbuf == srv_track_changed_pages)
return 0;

return 1;
}
#endif

#ifndef DBUG_OFF
static char* srv_buffer_pool_evict;

Expand Down Expand Up @@ -13424,7 +13499,12 @@ provide a testcase sync facility */
static MYSQL_SYSVAR_BOOL(track_changed_pages, srv_track_changed_pages,
track_changed_pages_flags,
"Track the redo log for changed pages and output a changed page bitmap",
NULL, NULL, FALSE);
#ifdef UNIV_DEBUG
innodb_track_changed_pages_validate,
#else
NULL,
#endif
NULL, FALSE);

static MYSQL_SYSVAR_ULONGLONG(max_bitmap_file_size, srv_max_bitmap_file_size,
PLUGIN_VAR_RQCMDARG,
Expand Down
10 changes: 10 additions & 0 deletions storage/xtradb/include/ha_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ thd_supports_xa(
void* thd); /*!< in: thread handle (THD*), or NULL to query
the global innodb_supports_xa */

/******************************************************************//**
Check the status of fake changes mode (innodb_fake_changes)
@return true if fake change mode is enabled. */

ibool
thd_fake_changes(
/*=============*/
void* thd); /*!< in: thread handle, or NULL to query
the global innodb_supports_xa */

/******************************************************************//**
Returns the lock wait timeout for the current connection.
@return the lock wait timeout, in seconds */
Expand Down
11 changes: 8 additions & 3 deletions storage/xtradb/include/os0file.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ log. */
#define OS_FILE_READ_ONLY 333
#define OS_FILE_READ_WRITE 444
#define OS_FILE_READ_ALLOW_DELETE 555 /* for ibbackup */
#define OS_FILE_READ_WRITE_CACHED 666 /* OS_FILE_READ_WRITE but never
O_DIRECT. Only for
os_file_create_simple_no_error_handling
currently. */

/* Options for file_create */
#define OS_FILE_AIO 61
Expand Down Expand Up @@ -505,9 +509,10 @@ os_file_create_simple_no_error_handling_func(
OS_FILE_CREATE if a new file is created
(if exists, error) */
ulint access_type,/*!< in: OS_FILE_READ_ONLY,
OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file */
OS_FILE_READ_WRITE, OS_FILE_READ_ALLOW_DELETE
(used by a backup program reading the file), or
OS_FILE_READ_WRITE_CACHED (disable O_DIRECT if
it would be enabled otherwise). */
ibool* success);/*!< out: TRUE if succeed, FALSE if error */
/****************************************************************//**
Tries to disable OS caching on an opened file descriptor. */
Expand Down
Loading

0 comments on commit 142b725

Please sign in to comment.