Skip to content

Commit 17a792a

Browse files
committed
Merge branch 'merge-xtradb-5.6' into 10.0
2 parents c8fcaf8 + d76eba6 commit 17a792a

File tree

18 files changed

+447
-123
lines changed

18 files changed

+447
-123
lines changed

mysql-test/suite/innodb/t/tmpdir.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--source include/have_innodb.inc
22
--source include/count_sessions.inc
33

4-
if (`select plugin_auth_version <= "5.6.26-MariaDB-76.0" from information_schema.plugins where plugin_name='innodb'`)
4+
if (`select plugin_auth_version <= "5.6.28-MariaDB-76.1" from information_schema.plugins where plugin_name='innodb'`)
55
{
6-
--skip Not fixed in XtraDB as of 5.6.26-MariaDB-76.0 or earlier
6+
--skip Not fixed in XtraDB as of 5.6.28-MariaDB-76.1 or earlier
77
}
88

99
--echo #

mysql-test/suite/sys_vars/t/innodb_tmpdir_basic.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--source include/have_innodb.inc
22

3-
if (`select plugin_auth_version <= "5.6.26-MariaDB-76.0" from information_schema.plugins where plugin_name='innodb'`)
3+
if (`select plugin_auth_version <= "5.6.28-MariaDB-76.1" from information_schema.plugins where plugin_name='innodb'`)
44
{
5-
--skip Not fixed in XtraDB as of 5.6.26-MariaDB-76.0 or earlier
5+
--skip Not fixed in XtraDB as of 5.6.28-MariaDB-76.1 or earlier
66
}
77

88
SET @start_global_value = @@global.innodb_tmpdir;

storage/xtradb/btr/btr0btr.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2012, Facebook Inc.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -2143,7 +2143,7 @@ the tuple. It is assumed that mtr contains an x-latch on the tree.
21432143
NOTE that the operation of this function must always succeed,
21442144
we cannot reverse it: therefore enough free disk space must be
21452145
guaranteed to be available before this function is called.
2146-
@return inserted record */
2146+
@return inserted record or NULL if run out of space */
21472147
UNIV_INTERN
21482148
rec_t*
21492149
btr_root_raise_and_insert(
@@ -2204,6 +2204,11 @@ btr_root_raise_and_insert(
22042204
level = btr_page_get_level(root, mtr);
22052205

22062206
new_block = btr_page_alloc(index, 0, FSP_NO_DIR, level, mtr, mtr);
2207+
2208+
if (new_block == NULL && os_has_said_disk_full) {
2209+
return(NULL);
2210+
}
2211+
22072212
new_page = buf_block_get_frame(new_block);
22082213
new_page_zip = buf_block_get_page_zip(new_block);
22092214
ut_a(!new_page_zip == !root_page_zip);
@@ -2980,7 +2985,7 @@ function must always succeed, we cannot reverse it: therefore enough
29802985
free disk space (2 pages) must be guaranteed to be available before
29812986
this function is called.
29822987
2983-
@return inserted record */
2988+
@return inserted record or NULL if run out of space */
29842989
UNIV_INTERN
29852990
rec_t*
29862991
btr_page_split_and_insert(
@@ -3094,9 +3099,18 @@ btr_page_split_and_insert(
30943099
}
30953100
}
30963101

3102+
DBUG_EXECUTE_IF("disk_is_full",
3103+
os_has_said_disk_full = true;
3104+
return(NULL););
3105+
30973106
/* 2. Allocate a new page to the index */
30983107
new_block = btr_page_alloc(cursor->index, hint_page_no, direction,
30993108
btr_page_get_level(page, mtr), mtr, mtr);
3109+
3110+
if (new_block == NULL && os_has_said_disk_full) {
3111+
return(NULL);
3112+
}
3113+
31003114
new_page = buf_block_get_frame(new_block);
31013115
new_page_zip = buf_block_get_page_zip(new_block);
31023116
btr_page_create(new_block, new_page_zip, cursor->index,

storage/xtradb/btr/btr0cur.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,10 @@ btr_cur_pessimistic_insert(
17331733
flags, cursor, offsets, heap, entry, n_ext, mtr);
17341734
}
17351735

1736+
if (*rec == NULL && os_has_said_disk_full) {
1737+
return(DB_OUT_OF_FILE_SPACE);
1738+
}
1739+
17361740
ut_ad(page_rec_get_next(btr_cur_get_rec(cursor)) == *rec);
17371741

17381742
if (!(flags & BTR_NO_LOCKING_FLAG)) {

storage/xtradb/buf/buf0flu.cc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,7 @@ Clears up tail of the LRU lists:
22022202
* Flush dirty pages at the tail of LRU to the disk
22032203
The depth to which we scan each buffer pool is controlled by dynamic
22042204
config parameter innodb_LRU_scan_depth.
2205-
@return total pages flushed */
2205+
@return number of pages flushed */
22062206
UNIV_INTERN
22072207
ulint
22082208
buf_flush_LRU_tail(void)
@@ -2306,7 +2306,6 @@ buf_flush_LRU_tail(void)
23062306
MONITOR_LRU_BATCH_PAGES,
23072307
total_flushed);
23082308
}
2309-
23102309
return(total_flushed);
23112310
}
23122311

@@ -2610,19 +2609,24 @@ static
26102609
void
26112610
page_cleaner_adapt_lru_sleep_time(
26122611
/*==============================*/
2613-
ulint* lru_sleep_time) /*!< in/out: desired page cleaner thread sleep
2612+
ulint* lru_sleep_time, /*!< in/out: desired page cleaner thread sleep
26142613
time for LRU flushes */
2614+
ulint lru_n_flushed) /*!< in: number of flushed in previous batch */
2615+
26152616
{
26162617
ulint free_len = buf_get_total_free_list_length();
26172618
ulint max_free_len = srv_LRU_scan_depth * srv_buf_pool_instances;
26182619

2619-
if (free_len < max_free_len / 100) {
2620+
if (free_len < max_free_len / 100 && lru_n_flushed) {
26202621

2621-
/* Free lists filled less than 1%, no sleep */
2622+
/* Free lists filled less than 1%
2623+
and iteration was able to flush, no sleep */
26222624
*lru_sleep_time = 0;
2623-
} else if (free_len > max_free_len / 5) {
2625+
} else if (free_len > max_free_len / 5
2626+
|| (free_len < max_free_len / 100 && lru_n_flushed == 0)) {
26242627

2625-
/* Free lists filled more than 20%, sleep a bit more */
2628+
/* Free lists filled more than 20%
2629+
or no pages flushed in previous batch, sleep a bit more */
26262630
*lru_sleep_time += 50;
26272631
if (*lru_sleep_time > srv_cleaner_max_lru_time)
26282632
*lru_sleep_time = srv_cleaner_max_lru_time;
@@ -2825,6 +2829,7 @@ DECLARE_THREAD(buf_flush_lru_manager_thread)(
28252829
{
28262830
ulint next_loop_time = ut_time_ms() + 1000;
28272831
ulint lru_sleep_time = srv_cleaner_max_lru_time;
2832+
ulint lru_n_flushed = 1;
28282833

28292834
#ifdef UNIV_PFS_THREAD
28302835
pfs_register_thread(buf_lru_manager_thread_key);
@@ -2851,11 +2856,11 @@ DECLARE_THREAD(buf_flush_lru_manager_thread)(
28512856

28522857
page_cleaner_sleep_if_needed(next_loop_time);
28532858

2854-
page_cleaner_adapt_lru_sleep_time(&lru_sleep_time);
2859+
page_cleaner_adapt_lru_sleep_time(&lru_sleep_time, lru_n_flushed);
28552860

28562861
next_loop_time = ut_time_ms() + lru_sleep_time;
28572862

2858-
buf_flush_LRU_tail();
2863+
lru_n_flushed = buf_flush_LRU_tail();
28592864
}
28602865

28612866
buf_lru_manager_is_active = false;

storage/xtradb/dict/dict0dict.cc

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,13 @@ dict_table_rename_in_cache(
16301630
to preserve the original table name
16311631
in constraints which reference it */
16321632
{
1633+
dberr_t err;
16331634
dict_foreign_t* foreign;
16341635
dict_index_t* index;
16351636
ulint fold;
16361637
char old_name[MAX_FULL_NAME_LEN + 1];
1638+
os_file_type_t ftype;
1639+
ibool exists;
16371640

16381641
ut_ad(mutex_own(&(dict_sys->mutex)));
16391642

@@ -1671,8 +1674,6 @@ dict_table_rename_in_cache(
16711674
.ibd file and rebuild the .isl file if needed. */
16721675

16731676
if (dict_table_is_discarded(table)) {
1674-
os_file_type_t type;
1675-
ibool exists;
16761677
char* filepath;
16771678

16781679
ut_ad(table->space != TRX_SYS_SPACE);
@@ -1691,7 +1692,7 @@ dict_table_rename_in_cache(
16911692
fil_delete_tablespace(table->space, BUF_REMOVE_ALL_NO_WRITE);
16921693

16931694
/* Delete any temp file hanging around. */
1694-
if (os_file_status(filepath, &exists, &type)
1695+
if (os_file_status(filepath, &exists, &ftype)
16951696
&& exists
16961697
&& !os_file_delete_if_exists(innodb_file_temp_key,
16971698
filepath)) {
@@ -1703,8 +1704,6 @@ dict_table_rename_in_cache(
17031704
mem_free(filepath);
17041705

17051706
} else if (table->space != TRX_SYS_SPACE) {
1706-
char* new_path = NULL;
1707-
17081707
if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) {
17091708
ut_print_timestamp(stderr);
17101709
fputs(" InnoDB: Error: trying to rename a"
@@ -1718,34 +1717,43 @@ dict_table_rename_in_cache(
17181717
}
17191718

17201719
return(DB_ERROR);
1720+
}
17211721

1722-
} else if (DICT_TF_HAS_DATA_DIR(table->flags)) {
1723-
char* old_path;
1724-
1725-
old_path = fil_space_get_first_path(table->space);
1722+
char* new_path = NULL;
1723+
char* old_path = fil_space_get_first_path(table->space);
17261724

1725+
if (DICT_TF_HAS_DATA_DIR(table->flags)) {
17271726
new_path = os_file_make_new_pathname(
17281727
old_path, new_name);
17291728

1730-
mem_free(old_path);
1731-
1732-
dberr_t err = fil_create_link_file(
1733-
new_name, new_path);
1734-
1729+
err = fil_create_link_file(new_name, new_path);
17351730
if (err != DB_SUCCESS) {
17361731
mem_free(new_path);
1732+
mem_free(old_path);
17371733
return(DB_TABLESPACE_EXISTS);
17381734
}
1735+
} else {
1736+
new_path = fil_make_ibd_name(new_name, false);
1737+
}
1738+
1739+
/* New filepath must not exist. */
1740+
err = fil_rename_tablespace_check(
1741+
table->space, old_path, new_path, false);
1742+
if (err != DB_SUCCESS) {
1743+
mem_free(old_path);
1744+
mem_free(new_path);
1745+
return(err);
17391746
}
17401747

17411748
ibool success = fil_rename_tablespace(
17421749
old_name, table->space, new_name, new_path);
17431750

1751+
mem_free(old_path);
1752+
mem_free(new_path);
1753+
17441754
/* If the tablespace is remote, a new .isl file was created
17451755
If success, delete the old one. If not, delete the new one. */
1746-
if (new_path) {
1747-
1748-
mem_free(new_path);
1756+
if (DICT_TF_HAS_DATA_DIR(table->flags)) {
17491757
fil_delete_link_file(success ? old_name : new_name);
17501758
}
17511759

0 commit comments

Comments
 (0)