Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=10
MYSQL_VERSION_MINOR=11
MYSQL_VERSION_PATCH=12
MYSQL_VERSION_PATCH=13
SERVER_MATURITY=stable
4 changes: 3 additions & 1 deletion include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ extern my_bool my_use_large_pages;

int my_init_large_pages(void);
uchar *my_large_malloc(size_t *size, myf my_flags);
#if defined _WIN32 || defined HAVE_MMAP
#ifdef _WIN32
/* On Windows, use my_virtual_mem_reserve() and my_virtual_mem_commit(). */
#else
char *my_large_virtual_alloc(size_t *size);
#endif
void my_large_free(void *ptr, size_t size);
Expand Down
2 changes: 2 additions & 0 deletions include/my_virtual_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
extern "C" {
#endif

# ifdef _WIN32
char *my_virtual_mem_reserve(size_t *size);
# endif
char *my_virtual_mem_commit(char *ptr, size_t size);
void my_virtual_mem_decommit(char *ptr, size_t size);
void my_virtual_mem_release(char *ptr, size_t size);
Expand Down
12 changes: 11 additions & 1 deletion mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ select @@innodb_buffer_pool_size;
10485760
create table t1 (id int primary key, val int not null)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create table t2 (id int primary key, val int not null)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=$kbs;
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
INSERT INTO t1 SELECT seq*4,seq*4 FROM seq_1_to_262144;
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
INSERT INTO t2 SELECT seq*4,seq*4 FROM seq_1_to_16384;
set global innodb_buffer_pool_size = 7340032;
select count(val) from t1;
count(val)
262144
select count(val) from t2;
count(val)
16384
set global innodb_adaptive_hash_index=OFF;
set global innodb_buffer_pool_size = 24117248;
set global innodb_buffer_pool_size = 26214400;
Expand All @@ -29,7 +36,10 @@ select @@innodb_buffer_pool_size;
select count(val) from t1;
count(val)
262144
drop table t1;
select count(val) from t2;
count(val)
16384
drop table t1,t2;
SET GLOBAL innodb_max_purge_lag_wait = 0;
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
SET @save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;
Expand Down
11 changes: 8 additions & 3 deletions mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set global innodb_buffer_pool_size = 9437184;
set global innodb_buffer_pool_size = 10485760;

select @@innodb_buffer_pool_size;
let $kbs=`SELECT CAST(@@innodb_page_size / 1024 AS INT)`;

# fill buffer pool
--disable_query_log
Expand All @@ -29,9 +30,13 @@ SET GLOBAL innodb_read_only_compressed=OFF;
--enable_query_log
create table t1 (id int primary key, val int not null)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
evalp create table t2 (id int primary key, val int not null)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=$kbs;

SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
INSERT INTO t1 SELECT seq*4,seq*4 FROM seq_1_to_262144;
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
INSERT INTO t2 SELECT seq*4,seq*4 FROM seq_1_to_16384;

--disable_query_log
SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
Expand All @@ -42,6 +47,7 @@ SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
set global innodb_buffer_pool_size = 7340032;

select count(val) from t1;
select count(val) from t2;

set global innodb_adaptive_hash_index=OFF;

Expand All @@ -52,8 +58,9 @@ set global innodb_buffer_pool_size = 26214400;
select @@innodb_buffer_pool_size;

select count(val) from t1;
select count(val) from t2;

drop table t1;
drop table t1,t2;

SET GLOBAL innodb_max_purge_lag_wait = 0;
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
Expand All @@ -66,8 +73,6 @@ SELECT variable_value = 0
FROM information_schema.global_status
WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
--source include/wait_condition.inc
# this may occasionally be aborted on a heavily loaded builder
--error 0,ER_WRONG_USAGE
SET GLOBAL innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
SET GLOBAL innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
SET GLOBAL innodb_max_dirty_pages_pct = @save_pct;
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/rpl/t/rpl_semi_sync_ssl_stop.test
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1;

--connection master
--echo # Verify Semi-Sync is active
--let $status_var= Rpl_semi_sync_master_status
--let $status_var_value= ON
--let $status_var= Rpl_semi_sync_master_clients
--let $status_var_value= 1
--source include/wait_for_status_var.inc
SHOW STATUS LIKE 'Rpl_semi_sync_master_clients';

Expand All @@ -67,7 +67,7 @@ STOP SLAVE;
--echo # MDEV-36663: Verifying dump thread connection is killed..
# Prior to MDEV-36663 fixes, this would time out and
# Rpl_semi_sync_master_clients would remain 1.
--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.PROCESSLIST WHERE COMMAND = 'Binlog Dump'
--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.PROCESSLIST WHERE USER = 'replssl'
--source include/wait_condition.inc

--let $n_master_clients= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_master_clients', Value, 1)
Expand Down
46 changes: 3 additions & 43 deletions mysys/my_largepage.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ uchar *my_large_malloc(size_t *size, myf my_flags)
DBUG_RETURN(ptr);
}

#ifdef _WIN32
#ifndef _WIN32
/**
Special large pages allocator, with possibility to commit to allocating
more memory later.
Expand All @@ -434,37 +434,10 @@ char *my_large_virtual_alloc(size_t *size)
char *ptr;
DBUG_ENTER("my_large_virtual_alloc");

if (my_use_large_pages)
{
size_t s= *size;
s= MY_ALIGN(s, (size_t) my_large_page_size);
ptr= VirtualAlloc(NULL, s, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES,
PAGE_READWRITE);
if (ptr)
{
*size= s;
DBUG_RETURN(ptr);
}
}

DBUG_RETURN(VirtualAlloc(NULL, *size, MEM_RESERVE, PAGE_READWRITE));
}
#elif defined HAVE_MMAP
/**
Special large pages allocator, with possibility to commit to allocating
more memory later.
Every implementation returns a zero filled buffer here.
*/
char *my_large_mmap(size_t *size, int prot)
{
char *ptr;
DBUG_ENTER("my_large_virtual_alloc");

if (my_use_large_pages)
{
size_t large_page_size;
int page_i= 0;
prot= PROT_READ | PROT_WRITE;

while ((large_page_size= my_next_large_page_size(*size, &page_i)) != 0)
{
Expand All @@ -488,7 +461,7 @@ char *my_large_mmap(size_t *size, int prot)
OS_MAP_ANON;

size_t aligned_size= MY_ALIGN(*size, (size_t) large_page_size);
ptr= mmap(NULL, aligned_size, prot, mapflag, -1, 0);
ptr= mmap(NULL, aligned_size, PROT_READ | PROT_WRITE, mapflag, -1, 0);
if (ptr == (void*) -1)
{
ptr= NULL;
Expand All @@ -511,10 +484,7 @@ char *my_large_mmap(size_t *size, int prot)
}
}

ptr= mmap(NULL, *size, prot,
# ifdef MAP_NORESERVE
MAP_NORESERVE |
# endif
ptr= mmap(NULL, *size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | OS_MAP_ANON, -1, 0);
if (ptr == MAP_FAILED)
{
Expand All @@ -524,16 +494,6 @@ char *my_large_mmap(size_t *size, int prot)

DBUG_RETURN(ptr);
}

/**
Special large pages allocator, with possibility to commit to allocating
more memory later.
Every implementation returns a zero filled buffer here.
*/
char *my_large_virtual_alloc(size_t *size)
{
return my_large_mmap(size, PROT_READ | PROT_WRITE);
}
#endif

/**
Expand Down
12 changes: 3 additions & 9 deletions mysys/my_virtual_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@

We try to respect use_large_pages setting, on Windows and Linux
*/
#ifndef _WIN32
char *my_large_mmap(size_t *size, int prot);
#endif

#ifdef _WIN32
char *my_virtual_mem_reserve(size_t *size)
{
#ifdef _WIN32
DWORD flags= my_use_large_pages
? MEM_LARGE_PAGES | MEM_RESERVE | MEM_COMMIT
: MEM_RESERVE;
Expand All @@ -53,10 +49,8 @@ char *my_virtual_mem_reserve(size_t *size)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_ERROR_LOG), *size);
}
return ptr;
#else
return my_large_mmap(size, PROT_NONE);
#endif
}
#endif

#if defined _WIN32 && !defined DBUG_OFF
static my_bool is_memory_committed(char *ptr, size_t size)
Expand Down Expand Up @@ -88,7 +82,7 @@ char *my_virtual_mem_commit(char *ptr, size_t size)
}
#else
if (my_use_large_pages)
/* my_large_mmap() already created a read/write mapping. */;
/* my_large_virtual_alloc() already created a read/write mapping. */;
else
{
# ifdef _AIX
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/btr/btr0sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ ATTRIBUTE_COLD void btr_search_enable(bool resize)
}

btr_search_x_lock_all();
ulint hash_size = buf_pool.curr_size() / sizeof(void *) / 64;
ulint hash_size = buf_pool.curr_pool_size() / sizeof(void *) / 64;

if (btr_search_sys.parts[0].heap) {
ut_ad(btr_search_enabled);
Expand Down
13 changes: 4 additions & 9 deletions storage/innobase/buf/buf0buddy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ void buf_buddy_free_low(void* buf, ulint i) noexcept
buf_buddy_add_to_free(reinterpret_cast<buf_buddy_free_t*>(buf), i);
}

/** Reallocate a ROW_FORMAT=COMPRESSED page frame during buf_pool_t::resize().
/** Reallocate a ROW_FORMAT=COMPRESSED page frame during buf_pool_t::shrink().
@param bpage page descriptor covering a ROW_FORMAT=COMPRESSED page
@param block uncompressed block for storage
@return block
Expand Down Expand Up @@ -672,10 +672,9 @@ buf_block_t *buf_buddy_shrink(buf_page_t *bpage, buf_block_t *block) noexcept
bpage->zip.data= static_cast<page_zip_t*>(dst);
buf_pool.buddy_stat[i].relocated++;

for (;;)
while (i < BUF_BUDDY_SIZES)
{
MEM_UNDEFINED(src, BUF_BUDDY_LOW << i);
ut_ad(i < BUF_BUDDY_SIZES);
/* Try to combine adjacent blocks. */
buf_buddy_free_t *buddy= reinterpret_cast<buf_buddy_free_t*>
(buf_buddy_get(static_cast<byte*>(src), BUF_BUDDY_LOW << i));
Expand All @@ -684,20 +683,16 @@ buf_block_t *buf_buddy_shrink(buf_page_t *bpage, buf_block_t *block) noexcept
{
ut_ad(!buf_pool.contains_zip(src, BUF_BUDDY_LOW_SHIFT + i));
buf_buddy_add_to_free(static_cast<buf_buddy_free_t*>(src), i);
break;
return block;
}

/* The buddy is free: recombine */
buf_buddy_remove_from_free(buddy, i);
i++;
src= ut_align_down(src, BUF_BUDDY_LOW << i);
if (i == BUF_BUDDY_SIZES)
{
buf_buddy_block_free(src);
break;
}
}

buf_buddy_block_free(src);
return block;
}

Expand Down
11 changes: 11 additions & 0 deletions storage/innobase/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,11 @@ bool buf_pool_t::create() noexcept
retry:
{
NUMA_MEMPOLICY_INTERLEAVE_IN_SCOPE;
#ifdef _WIN32
memory_unaligned= my_virtual_mem_reserve(&size);
#else
memory_unaligned= my_large_virtual_alloc(&size);
#endif
}

if (!memory_unaligned)
Expand Down Expand Up @@ -1370,13 +1374,17 @@ bool buf_pool_t::create() noexcept
#ifdef UNIV_PFS_MEMORY
PSI_MEMORY_CALL(memory_alloc)(mem_key_buf_buf_pool, actual_size, &owner);
#endif
#ifdef _WIN32
if (!my_virtual_mem_commit(memory, actual_size))
{
my_virtual_mem_release(memory_unaligned, size_unaligned);
memory= nullptr;
memory_unaligned= nullptr;
goto oom;
}
#else
update_malloc_size(actual_size, 0);
#endif

#ifdef HAVE_LIBNUMA
if (srv_numa_interleave)
Expand Down Expand Up @@ -1788,6 +1796,9 @@ ATTRIBUTE_COLD buf_pool_t::shrink_status buf_pool_t::shrink(size_t size)
goto next;
}

if (UT_LIST_GET_LEN(free) + UT_LIST_GET_LEN(LRU) < usable_size() / 20)
return SHRINK_ABORT;

mysql_mutex_lock(&flush_list_mutex);

if (LRU_warned && !UT_LIST_GET_FIRST(free))
Expand Down
5 changes: 4 additions & 1 deletion storage/innobase/buf/buf0lru.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ static void buf_LRU_check_size_of_non_data_objects() noexcept

auto s= UT_LIST_GET_LEN(buf_pool.free) + UT_LIST_GET_LEN(buf_pool.LRU);

if (s < curr_size / 20)
if (s >= curr_size / 20);
else if (buf_pool.is_shrinking())
buf_pool.LRU_warn();
else
{
sql_print_error("[FATAL] InnoDB: Over 95 percent of the buffer pool is"
" occupied by lock heaps"
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/dict/dict0dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ void dict_sys_t::create() noexcept
UT_LIST_INIT(table_LRU, &dict_table_t::table_LRU);
UT_LIST_INIT(table_non_LRU, &dict_table_t::table_LRU);

const ulint hash_size = buf_pool.curr_size()
const ulint hash_size = buf_pool.curr_pool_size()
/ (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);

table_hash.create(hash_size);
Expand Down Expand Up @@ -4399,7 +4399,7 @@ void dict_sys_t::resize() noexcept
table_id_hash.free();
temp_id_hash.free();

const ulint hash_size = buf_pool.curr_size()
const ulint hash_size = buf_pool.curr_pool_size()
/ (DICT_POOL_PER_TABLE_HASH * UNIV_WORD_SIZE);
table_hash.create(hash_size);
table_id_hash.create(hash_size);
Expand Down
1 change: 0 additions & 1 deletion storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4075,7 +4075,6 @@ static int innodb_init_params()
#else
ut_ad(srv_file_flush_method <= SRV_O_DIRECT_NO_FSYNC);
#endif
srv_lock_table_size = 5 * buf_pool.curr_size();
DBUG_RETURN(0);
}

Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/buf0buddy.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ inline void buf_buddy_free(void* buf, ulint size) noexcept
}

ATTRIBUTE_COLD MY_ATTRIBUTE((nonnull, warn_unused_result))
/** Reallocate a ROW_FORMAT=COMPRESSED page frame during buf_pool_t::resize().
/** Reallocate a ROW_FORMAT=COMPRESSED page frame during buf_pool_t::shrink().
@param bpage page descriptor covering a ROW_FORMAT=COMPRESSED page
@param block uncompressed block for storage
@return block
Expand Down
Loading