Skip to content

Commit e4957de

Browse files
committed
Merge branch 'merge-xtradb-5.5' into 5.5
2 parents 02be50a + 6010a27 commit e4957de

File tree

11 files changed

+179
-50
lines changed

11 files changed

+179
-50
lines changed

storage/xtradb/btr/btr0btr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ btr_corruption_report(
7676
buf_block_get_zip_size(block),
7777
BUF_PAGE_PRINT_NO_CRASH);
7878
}
79-
buf_page_print(buf_block_get_frame_fast(block), 0, 0);
79+
buf_page_print(buf_nonnull_block_get_frame(block), 0, 0);
8080
}
8181

8282
#ifndef UNIV_HOTBACKUP
@@ -1077,7 +1077,7 @@ btr_get_size(
10771077
SRV_CORRUPT_TABLE_CHECK(root,
10781078
{
10791079
mtr_commit(mtr);
1080-
return(0);
1080+
return(ULINT_UNDEFINED);
10811081
});
10821082

10831083
if (flag == BTR_N_LEAF_PAGES) {

storage/xtradb/handler/ha_innodb.cc

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,19 @@ innobase_is_fake_change(
469469
THD* thd) __attribute__((unused)); /*!< in: MySQL thread handle of the user for
470470
whom the transaction is being committed */
471471

472+
/** Get the list of foreign keys referencing a specified table
473+
table.
474+
@param thd The thread handle
475+
@param path Path to the table
476+
@param f_key_list[out] The list of foreign keys
477+
478+
@return error code or zero for success */
479+
static
480+
int
481+
innobase_get_parent_fk_list(
482+
THD* thd,
483+
const char* path,
484+
List<FOREIGN_KEY_INFO>* f_key_list);
472485

473486
/******************************************************************//**
474487
Maps a MySQL trx isolation level code to the InnoDB isolation level code
@@ -10008,7 +10021,14 @@ ha_innobase::check(
1000810021

1000910022
prebuilt->select_lock_type = LOCK_NONE;
1001010023

10011-
if (!row_check_index_for_mysql(prebuilt, index, &n_rows)) {
10024+
bool check_result
10025+
= row_check_index_for_mysql(prebuilt, index, &n_rows);
10026+
DBUG_EXECUTE_IF(
10027+
"dict_set_index_corrupted",
10028+
if (!(index->type & DICT_CLUSTERED)) {
10029+
check_result = false;
10030+
});
10031+
if (!check_result) {
1001210032
innobase_format_name(
1001310033
index_name, sizeof index_name,
1001410034
index->name, TRUE);
@@ -10344,6 +10364,73 @@ get_foreign_key_info(
1034410364
return(pf_key_info);
1034510365
}
1034610366

10367+
/** Get the list of foreign keys referencing a specified table
10368+
table.
10369+
@param thd The thread handle
10370+
@param path Path to the table
10371+
@param f_key_list[out] The list of foreign keys */
10372+
static
10373+
void
10374+
fill_foreign_key_list(THD* thd,
10375+
const dict_table_t* table,
10376+
List<FOREIGN_KEY_INFO>* f_key_list)
10377+
{
10378+
ut_ad(mutex_own(&dict_sys->mutex));
10379+
10380+
for (dict_foreign_t* foreign
10381+
= UT_LIST_GET_FIRST(table->referenced_list);
10382+
foreign != NULL;
10383+
foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) {
10384+
10385+
FOREIGN_KEY_INFO* pf_key_info
10386+
= get_foreign_key_info(thd, foreign);
10387+
if (pf_key_info) {
10388+
f_key_list->push_back(pf_key_info);
10389+
}
10390+
}
10391+
}
10392+
10393+
/** Get the list of foreign keys referencing a specified table
10394+
table.
10395+
@param thd The thread handle
10396+
@param path Path to the table
10397+
@param f_key_list[out] The list of foreign keys
10398+
10399+
@return error code or zero for success */
10400+
static
10401+
int
10402+
innobase_get_parent_fk_list(
10403+
THD* thd,
10404+
const char* path,
10405+
List<FOREIGN_KEY_INFO>* f_key_list)
10406+
{
10407+
ut_a(strlen(path) <= FN_REFLEN);
10408+
char norm_name[FN_REFLEN + 1];
10409+
normalize_table_name(norm_name, path);
10410+
10411+
trx_t* parent_trx = check_trx_exists(thd);
10412+
parent_trx->op_info = "getting list of referencing foreign keys";
10413+
trx_search_latch_release_if_reserved(parent_trx);
10414+
10415+
mutex_enter(&dict_sys->mutex);
10416+
10417+
dict_table_t* table
10418+
= dict_table_get_low(norm_name,
10419+
static_cast<dict_err_ignore_t>(
10420+
DICT_ERR_IGNORE_INDEX_ROOT
10421+
| DICT_ERR_IGNORE_CORRUPT));
10422+
if (!table) {
10423+
mutex_exit(&dict_sys->mutex);
10424+
return(HA_ERR_NO_SUCH_TABLE);
10425+
}
10426+
10427+
fill_foreign_key_list(thd, table, f_key_list);
10428+
10429+
mutex_exit(&dict_sys->mutex);
10430+
parent_trx->op_info = "";
10431+
return(0);
10432+
}
10433+
1034710434
/*******************************************************************//**
1034810435
Gets the list of foreign keys in this table.
1034910436
@return always 0, that is, always succeeds */
@@ -10392,9 +10479,6 @@ ha_innobase::get_parent_foreign_key_list(
1039210479
THD* thd, /*!< in: user thread handle */
1039310480
List<FOREIGN_KEY_INFO>* f_key_list) /*!< out: foreign key list */
1039410481
{
10395-
FOREIGN_KEY_INFO* pf_key_info;
10396-
dict_foreign_t* foreign;
10397-
1039810482
ut_a(prebuilt != NULL);
1039910483
update_thd(ha_thd());
1040010484

@@ -10403,16 +10487,7 @@ ha_innobase::get_parent_foreign_key_list(
1040310487
trx_search_latch_release_if_reserved(prebuilt->trx);
1040410488

1040510489
mutex_enter(&(dict_sys->mutex));
10406-
10407-
for (foreign = UT_LIST_GET_FIRST(prebuilt->table->referenced_list);
10408-
foreign != NULL;
10409-
foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) {
10410-
pf_key_info = get_foreign_key_info(thd, foreign);
10411-
if (pf_key_info) {
10412-
f_key_list->push_back(pf_key_info);
10413-
}
10414-
}
10415-
10490+
fill_foreign_key_list(thd, prebuilt->table, f_key_list);
1041610491
mutex_exit(&(dict_sys->mutex));
1041710492

1041810493
prebuilt->trx->op_info = "";
@@ -12817,16 +12892,14 @@ innodb_track_changed_pages_validate(
1281712892
for update function */
1281812893
struct st_mysql_value* value) /*!< in: incoming bool */
1281912894
{
12820-
static bool enabled_on_startup = false;
1282112895
long long intbuf = 0;
1282212896

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

12828-
if (srv_track_changed_pages || enabled_on_startup) {
12829-
enabled_on_startup = true;
12902+
if (srv_redo_log_thread_started) {
1283012903
*reinterpret_cast<ulong*>(save)
1283112904
= static_cast<ulong>(intbuf);
1283212905
return 0;

storage/xtradb/include/buf0buf.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,10 +1110,20 @@ buf_block_get_frame(
11101110
/*================*/
11111111
const buf_block_t* block) /*!< in: pointer to the control block */
11121112
__attribute__((pure));
1113-
# define buf_block_get_frame_fast(block) buf_block_get_frame(block)
1113+
1114+
/*********************************************************************//**
1115+
Gets a pointer to the memory frame of a block, where block is known not to be
1116+
NULL.
1117+
@return pointer to the frame */
1118+
UNIV_INLINE
1119+
buf_frame_t*
1120+
buf_nonnull_block_get_frame(
1121+
const buf_block_t* block) /*!< in: pointer to the control block */
1122+
__attribute__((pure));
1123+
11141124
#else /* UNIV_DEBUG */
11151125
# define buf_block_get_frame(block) (block ? (block)->frame : 0)
1116-
# define buf_block_get_frame_fast(block) (block)->frame
1126+
# define buf_nonnull_block_get_frame(block) ((block)->frame)
11171127
#endif /* UNIV_DEBUG */
11181128
/*********************************************************************//**
11191129
Gets the space id of a block.

storage/xtradb/include/buf0buf.ic

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,19 @@ buf_block_get_frame(
718718
{
719719
SRV_CORRUPT_TABLE_CHECK(block, return(0););
720720

721+
return(buf_nonnull_block_get_frame(block));
722+
}
723+
724+
/*********************************************************************//**
725+
Gets a pointer to the memory frame of a block, where block is known not to be
726+
NULL.
727+
@return pointer to the frame */
728+
UNIV_INLINE
729+
buf_frame_t*
730+
buf_nonnull_block_get_frame(
731+
/*========================*/
732+
const buf_block_t* block) /*!< in: pointer to the control block */
733+
{
721734
switch (buf_block_get_state(block)) {
722735
case BUF_BLOCK_ZIP_FREE:
723736
case BUF_BLOCK_ZIP_PAGE:
@@ -739,6 +752,7 @@ buf_block_get_frame(
739752
ok:
740753
return((buf_frame_t*) block->frame);
741754
}
755+
742756
#endif /* UNIV_DEBUG */
743757

744758
/*********************************************************************//**

storage/xtradb/include/srv0srv.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ extern os_event_t srv_checkpoint_completed_event;
7878
that the (slow) shutdown may proceed */
7979
extern os_event_t srv_redo_log_thread_finished_event;
8080

81+
/** Whether the redo log tracker thread has been started. Does not take into
82+
account whether the tracking is currently enabled (see srv_track_changed_pages
83+
for that) */
84+
extern my_bool srv_redo_log_thread_started;
85+
8186
/* If the last data file is auto-extended, we add this many pages to it
8287
at a time */
8388
#define SRV_AUTO_EXTEND_INCREMENT \
@@ -145,6 +150,9 @@ extern char* srv_doublewrite_file;
145150

146151
extern ibool srv_recovery_stats;
147152

153+
/** Whether the redo log tracking is currently enabled. Note that it is
154+
possible for the log tracker thread to be running and the tracking to be
155+
disabled */
148156
extern my_bool srv_track_changed_pages;
149157
extern ib_uint64_t srv_max_bitmap_file_size;
150158

storage/xtradb/include/univ.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ component, i.e. we show M.N.P as M.N */
6464
(INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
6565

6666
#ifndef PERCONA_INNODB_VERSION
67-
#define PERCONA_INNODB_VERSION 38.0
67+
#define PERCONA_INNODB_VERSION 38.3
6868
#endif
6969

70-
#define INNODB_VERSION_STR "5.5.49-MariaDB-" IB_TO_STR(PERCONA_INNODB_VERSION)
70+
#define INNODB_VERSION_STR "5.5.52-MariaDB-" IB_TO_STR(PERCONA_INNODB_VERSION)
7171

7272
#define REFMAN "http://dev.mysql.com/doc/refman/" \
7373
IB_TO_STR(MYSQL_MAJOR_VERSION) "." \

storage/xtradb/log/log0log.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,7 +3420,8 @@ logs_empty_and_mark_files_at_shutdown(void)
34203420
algorithm only works if the server is idle at shutdown */
34213421

34223422
srv_shutdown_state = SRV_SHUTDOWN_CLEANUP;
3423-
os_event_set(srv_shutdown_event);
3423+
3424+
srv_wake_purge_thread();
34243425
loop:
34253426
os_thread_sleep(100000);
34263427

@@ -3594,7 +3595,7 @@ logs_empty_and_mark_files_at_shutdown(void)
35943595
srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
35953596
/* Wake the log tracking thread which will then immediatelly
35963597
quit because of srv_shutdown_state value */
3597-
if (srv_track_changed_pages) {
3598+
if (srv_redo_log_thread_started) {
35983599
os_event_set(srv_checkpoint_completed_event);
35993600
os_event_wait(srv_redo_log_thread_finished_event);
36003601
}
@@ -3671,7 +3672,7 @@ logs_empty_and_mark_files_at_shutdown(void)
36713672
srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
36723673

36733674
/* Signal the log following thread to quit */
3674-
if (srv_track_changed_pages) {
3675+
if (srv_redo_log_thread_started) {
36753676
os_event_set(srv_checkpoint_completed_event);
36763677
}
36773678

@@ -3695,7 +3696,7 @@ logs_empty_and_mark_files_at_shutdown(void)
36953696

36963697
fil_flush_file_spaces(FIL_TABLESPACE);
36973698

3698-
if (srv_track_changed_pages) {
3699+
if (srv_redo_log_thread_started) {
36993700
os_event_wait(srv_redo_log_thread_finished_event);
37003701
}
37013702

storage/xtradb/log/log0online.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,21 +1813,21 @@ log_online_purge_changed_page_bitmaps(
18131813
lsn = IB_ULONGLONG_MAX;
18141814
}
18151815

1816-
if (srv_track_changed_pages) {
1816+
if (srv_redo_log_thread_started) {
18171817
/* User requests might happen with both enabled and disabled
18181818
tracking */
18191819
mutex_enter(&log_bmp_sys->mutex);
18201820
}
18211821

18221822
if (!log_online_setup_bitmap_file_range(&bitmap_files, 0,
18231823
IB_ULONGLONG_MAX)) {
1824-
if (srv_track_changed_pages) {
1824+
if (srv_redo_log_thread_started) {
18251825
mutex_exit(&log_bmp_sys->mutex);
18261826
}
18271827
return TRUE;
18281828
}
18291829

1830-
if (srv_track_changed_pages && lsn > log_bmp_sys->end_lsn) {
1830+
if (srv_redo_log_thread_started && lsn > log_bmp_sys->end_lsn) {
18311831
/* If we have to delete the current output file, close it
18321832
first. */
18331833
os_file_close(log_bmp_sys->out.file);
@@ -1858,7 +1858,7 @@ log_online_purge_changed_page_bitmaps(
18581858
}
18591859
}
18601860

1861-
if (srv_track_changed_pages) {
1861+
if (srv_redo_log_thread_started) {
18621862
if (lsn > log_bmp_sys->end_lsn) {
18631863
ib_uint64_t new_file_lsn;
18641864
if (lsn == IB_ULONGLONG_MAX) {
@@ -1869,9 +1869,7 @@ log_online_purge_changed_page_bitmaps(
18691869
new_file_lsn = log_bmp_sys->end_lsn;
18701870
}
18711871
if (!log_online_rotate_bitmap_file(new_file_lsn)) {
1872-
/* If file create failed, signal the log
1873-
tracking thread to quit next time it wakes
1874-
up. */
1872+
/* If file create failed, stop log tracking */
18751873
srv_track_changed_pages = FALSE;
18761874
}
18771875
}

storage/xtradb/log/log0recv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,7 @@ recv_recovery_from_checkpoint_start_func(
30223022
ib_uint64_t checkpoint_lsn;
30233023
ib_uint64_t checkpoint_no;
30243024
ib_uint64_t old_scanned_lsn;
3025-
ib_uint64_t group_scanned_lsn= 0;
3025+
ib_uint64_t group_scanned_lsn = 0;
30263026
ib_uint64_t contiguous_lsn;
30273027
#ifdef UNIV_LOG_ARCHIVE
30283028
ib_uint64_t archived_lsn;

storage/xtradb/mach/mach0data.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,18 @@ mach_parse_compressed(
5656
*val = flag;
5757
return(ptr + 1);
5858

59-
} else if (flag < 0xC0UL) {
59+
}
60+
61+
/* Workaround GCC bug
62+
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77673:
63+
the compiler moves mach_read_from_4 right to the beginning of the
64+
function, causing and out-of-bounds read if we are reading a short
65+
integer close to the end of buffer. */
66+
#if defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__clang__)
67+
asm volatile("": : :"memory");
68+
#endif
69+
70+
if (flag < 0xC0UL) {
6071
if (end_ptr < ptr + 2) {
6172
return(NULL);
6273
}

0 commit comments

Comments
 (0)