Skip to content

Commit d76eba6

Browse files
committed
5.6.28-76.1
1 parent 1e270d5 commit d76eba6

File tree

16 files changed

+447
-119
lines changed

16 files changed

+447
-119
lines changed

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: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,9 +2209,10 @@ Clears up tail of the LRU lists:
22092209
* Put replaceable pages at the tail of LRU to the free list
22102210
* Flush dirty pages at the tail of LRU to the disk
22112211
The depth to which we scan each buffer pool is controlled by dynamic
2212-
config parameter innodb_LRU_scan_depth. */
2212+
config parameter innodb_LRU_scan_depth.
2213+
@return number of pages flushed */
22132214
UNIV_INTERN
2214-
void
2215+
ulint
22152216
buf_flush_LRU_tail(void)
22162217
/*====================*/
22172218
{
@@ -2313,6 +2314,7 @@ buf_flush_LRU_tail(void)
23132314
MONITOR_LRU_BATCH_PAGES,
23142315
total_flushed);
23152316
}
2317+
return(total_flushed);
23162318
}
23172319

23182320
/*********************************************************************//**
@@ -2608,19 +2610,24 @@ static
26082610
void
26092611
page_cleaner_adapt_lru_sleep_time(
26102612
/*==============================*/
2611-
ulint* lru_sleep_time) /*!< in/out: desired page cleaner thread sleep
2613+
ulint* lru_sleep_time, /*!< in/out: desired page cleaner thread sleep
26122614
time for LRU flushes */
2615+
ulint lru_n_flushed) /*!< in: number of flushed in previous batch */
2616+
26132617
{
26142618
ulint free_len = buf_get_total_free_list_length();
26152619
ulint max_free_len = srv_LRU_scan_depth * srv_buf_pool_instances;
26162620

2617-
if (free_len < max_free_len / 100) {
2621+
if (free_len < max_free_len / 100 && lru_n_flushed) {
26182622

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

2623-
/* Free lists filled more than 20%, sleep a bit more */
2629+
/* Free lists filled more than 20%
2630+
or no pages flushed in previous batch, sleep a bit more */
26242631
*lru_sleep_time += 50;
26252632
if (*lru_sleep_time > srv_cleaner_max_lru_time)
26262633
*lru_sleep_time = srv_cleaner_max_lru_time;
@@ -2826,6 +2833,7 @@ DECLARE_THREAD(buf_flush_lru_manager_thread)(
28262833
{
28272834
ulint next_loop_time = ut_time_ms() + 1000;
28282835
ulint lru_sleep_time = srv_cleaner_max_lru_time;
2836+
ulint lru_n_flushed = 1;
28292837

28302838
#ifdef UNIV_PFS_THREAD
28312839
pfs_register_thread(buf_lru_manager_thread_key);
@@ -2852,11 +2860,11 @@ DECLARE_THREAD(buf_flush_lru_manager_thread)(
28522860

28532861
page_cleaner_sleep_if_needed(next_loop_time);
28542862

2855-
page_cleaner_adapt_lru_sleep_time(&lru_sleep_time);
2863+
page_cleaner_adapt_lru_sleep_time(&lru_sleep_time, lru_n_flushed);
28562864

28572865
next_loop_time = ut_time_ms() + lru_sleep_time;
28582866

2859-
buf_flush_LRU_tail();
2867+
lru_n_flushed = buf_flush_LRU_tail();
28602868
}
28612869

28622870
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
@@ -1590,10 +1590,13 @@ dict_table_rename_in_cache(
15901590
to preserve the original table name
15911591
in constraints which reference it */
15921592
{
1593+
dberr_t err;
15931594
dict_foreign_t* foreign;
15941595
dict_index_t* index;
15951596
ulint fold;
15961597
char old_name[MAX_FULL_NAME_LEN + 1];
1598+
os_file_type_t ftype;
1599+
ibool exists;
15971600

15981601
ut_ad(mutex_own(&(dict_sys->mutex)));
15991602

@@ -1631,8 +1634,6 @@ dict_table_rename_in_cache(
16311634
.ibd file and rebuild the .isl file if needed. */
16321635

16331636
if (dict_table_is_discarded(table)) {
1634-
os_file_type_t type;
1635-
ibool exists;
16361637
char* filepath;
16371638

16381639
ut_ad(table->space != TRX_SYS_SPACE);
@@ -1651,7 +1652,7 @@ dict_table_rename_in_cache(
16511652
fil_delete_tablespace(table->space, BUF_REMOVE_ALL_NO_WRITE);
16521653

16531654
/* Delete any temp file hanging around. */
1654-
if (os_file_status(filepath, &exists, &type)
1655+
if (os_file_status(filepath, &exists, &ftype)
16551656
&& exists
16561657
&& !os_file_delete_if_exists(innodb_file_temp_key,
16571658
filepath)) {
@@ -1663,8 +1664,6 @@ dict_table_rename_in_cache(
16631664
mem_free(filepath);
16641665

16651666
} else if (table->space != TRX_SYS_SPACE) {
1666-
char* new_path = NULL;
1667-
16681667
if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)) {
16691668
ut_print_timestamp(stderr);
16701669
fputs(" InnoDB: Error: trying to rename a"
@@ -1678,34 +1677,43 @@ dict_table_rename_in_cache(
16781677
}
16791678

16801679
return(DB_ERROR);
1680+
}
16811681

1682-
} else if (DICT_TF_HAS_DATA_DIR(table->flags)) {
1683-
char* old_path;
1684-
1685-
old_path = fil_space_get_first_path(table->space);
1682+
char* new_path = NULL;
1683+
char* old_path = fil_space_get_first_path(table->space);
16861684

1685+
if (DICT_TF_HAS_DATA_DIR(table->flags)) {
16871686
new_path = os_file_make_new_pathname(
16881687
old_path, new_name);
16891688

1690-
mem_free(old_path);
1691-
1692-
dberr_t err = fil_create_link_file(
1693-
new_name, new_path);
1694-
1689+
err = fil_create_link_file(new_name, new_path);
16951690
if (err != DB_SUCCESS) {
16961691
mem_free(new_path);
1692+
mem_free(old_path);
16971693
return(DB_TABLESPACE_EXISTS);
16981694
}
1695+
} else {
1696+
new_path = fil_make_ibd_name(new_name, false);
1697+
}
1698+
1699+
/* New filepath must not exist. */
1700+
err = fil_rename_tablespace_check(
1701+
table->space, old_path, new_path, false);
1702+
if (err != DB_SUCCESS) {
1703+
mem_free(old_path);
1704+
mem_free(new_path);
1705+
return(err);
16991706
}
17001707

17011708
ibool success = fil_rename_tablespace(
17021709
old_name, table->space, new_name, new_path);
17031710

1711+
mem_free(old_path);
1712+
mem_free(new_path);
1713+
17041714
/* If the tablespace is remote, a new .isl file was created
17051715
If success, delete the old one. If not, delete the new one. */
1706-
if (new_path) {
1707-
1708-
mem_free(new_path);
1716+
if (DICT_TF_HAS_DATA_DIR(table->flags)) {
17091717
fil_delete_link_file(success ? old_name : new_name);
17101718
}
17111719

0 commit comments

Comments
 (0)