Skip to content

Commit 118cfcf

Browse files
committed
Merge 10.11 into 11.4
2 parents f5b5de9 + 8fb0942 commit 118cfcf

File tree

17 files changed

+66
-84
lines changed

17 files changed

+66
-84
lines changed

include/my_sys.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ extern my_bool my_use_large_pages;
178178

179179
int my_init_large_pages(void);
180180
uchar *my_large_malloc(size_t *size, myf my_flags);
181-
#if defined _WIN32 || defined HAVE_MMAP
181+
#ifdef _WIN32
182+
/* On Windows, use my_virtual_mem_reserve() and my_virtual_mem_commit(). */
183+
#else
182184
char *my_large_virtual_alloc(size_t *size);
183185
#endif
184186
void my_large_free(void *ptr, size_t size);

include/my_virtual_mem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
extern "C" {
2525
#endif
2626

27+
# ifdef _WIN32
2728
char *my_virtual_mem_reserve(size_t *size);
29+
# endif
2830
char *my_virtual_mem_commit(char *ptr, size_t size);
2931
void my_virtual_mem_decommit(char *ptr, size_t size);
3032
void my_virtual_mem_release(char *ptr, size_t size);

mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ select @@innodb_buffer_pool_size;
1212
10485760
1313
create table t1 (id int primary key, val int not null)
1414
ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
15+
create table t2 (id int primary key, val int not null)
16+
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=$kbs;
1517
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
1618
INSERT INTO t1 SELECT seq*4,seq*4 FROM seq_1_to_262144;
19+
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
20+
INSERT INTO t2 SELECT seq*4,seq*4 FROM seq_1_to_16384;
1721
set global innodb_buffer_pool_size = 7340032;
1822
select count(val) from t1;
1923
count(val)
2024
262144
25+
select count(val) from t2;
26+
count(val)
27+
16384
2128
set global innodb_adaptive_hash_index=OFF;
2229
set global innodb_buffer_pool_size = 24117248;
2330
set global innodb_buffer_pool_size = 26214400;
@@ -29,7 +36,10 @@ select @@innodb_buffer_pool_size;
2936
select count(val) from t1;
3037
count(val)
3138
262144
32-
drop table t1;
39+
select count(val) from t2;
40+
count(val)
41+
16384
42+
drop table t1,t2;
3343
SET GLOBAL innodb_max_purge_lag_wait = 0;
3444
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
3545
SET @save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set global innodb_buffer_pool_size = 9437184;
2121
set global innodb_buffer_pool_size = 10485760;
2222

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

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

3336
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
3437
INSERT INTO t1 SELECT seq*4,seq*4 FROM seq_1_to_262144;
38+
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
39+
INSERT INTO t2 SELECT seq*4,seq*4 FROM seq_1_to_16384;
3540

3641
--disable_query_log
3742
SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
@@ -42,6 +47,7 @@ SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
4247
set global innodb_buffer_pool_size = 7340032;
4348

4449
select count(val) from t1;
50+
select count(val) from t2;
4551

4652
set global innodb_adaptive_hash_index=OFF;
4753

@@ -52,8 +58,9 @@ set global innodb_buffer_pool_size = 26214400;
5258
select @@innodb_buffer_pool_size;
5359

5460
select count(val) from t1;
61+
select count(val) from t2;
5562

56-
drop table t1;
63+
drop table t1,t2;
5764

5865
SET GLOBAL innodb_max_purge_lag_wait = 0;
5966
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
@@ -66,8 +73,6 @@ SELECT variable_value = 0
6673
FROM information_schema.global_status
6774
WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
6875
--source include/wait_condition.inc
69-
# this may occasionally be aborted on a heavily loaded builder
70-
--error 0,ER_WRONG_USAGE
7176
SET GLOBAL innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
7277
SET GLOBAL innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
7378
SET GLOBAL innodb_max_dirty_pages_pct = @save_pct;

mysql-test/suite/rpl/t/rpl_semi_sync_ssl_stop.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1;
4949

5050
--connection master
5151
--echo # Verify Semi-Sync is active
52-
--let $status_var= Rpl_semi_sync_master_status
53-
--let $status_var_value= ON
52+
--let $status_var= Rpl_semi_sync_master_clients
53+
--let $status_var_value= 1
5454
--source include/wait_for_status_var.inc
5555
SHOW STATUS LIKE 'Rpl_semi_sync_master_clients';
5656

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

7373
--let $n_master_clients= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_master_clients', Value, 1)

mysys/my_largepage.c

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ uchar *my_large_malloc(size_t *size, myf my_flags)
423423
DBUG_RETURN(ptr);
424424
}
425425

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

437-
if (my_use_large_pages)
438-
{
439-
size_t s= *size;
440-
s= MY_ALIGN(s, (size_t) my_large_page_size);
441-
ptr= VirtualAlloc(NULL, s, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES,
442-
PAGE_READWRITE);
443-
if (ptr)
444-
{
445-
*size= s;
446-
DBUG_RETURN(ptr);
447-
}
448-
}
449-
450-
DBUG_RETURN(VirtualAlloc(NULL, *size, MEM_RESERVE, PAGE_READWRITE));
451-
}
452-
#elif defined HAVE_MMAP
453-
/**
454-
Special large pages allocator, with possibility to commit to allocating
455-
more memory later.
456-
Every implementation returns a zero filled buffer here.
457-
*/
458-
char *my_large_mmap(size_t *size, int prot)
459-
{
460-
char *ptr;
461-
DBUG_ENTER("my_large_virtual_alloc");
462-
463437
if (my_use_large_pages)
464438
{
465439
size_t large_page_size;
466440
int page_i= 0;
467-
prot= PROT_READ | PROT_WRITE;
468441

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

490463
size_t aligned_size= MY_ALIGN(*size, (size_t) large_page_size);
491-
ptr= mmap(NULL, aligned_size, prot, mapflag, -1, 0);
464+
ptr= mmap(NULL, aligned_size, PROT_READ | PROT_WRITE, mapflag, -1, 0);
492465
if (ptr == (void*) -1)
493466
{
494467
ptr= NULL;
@@ -511,10 +484,7 @@ char *my_large_mmap(size_t *size, int prot)
511484
}
512485
}
513486

514-
ptr= mmap(NULL, *size, prot,
515-
# ifdef MAP_NORESERVE
516-
MAP_NORESERVE |
517-
# endif
487+
ptr= mmap(NULL, *size, PROT_READ | PROT_WRITE,
518488
MAP_PRIVATE | OS_MAP_ANON, -1, 0);
519489
if (ptr == MAP_FAILED)
520490
{
@@ -524,16 +494,6 @@ char *my_large_mmap(size_t *size, int prot)
524494

525495
DBUG_RETURN(ptr);
526496
}
527-
528-
/**
529-
Special large pages allocator, with possibility to commit to allocating
530-
more memory later.
531-
Every implementation returns a zero filled buffer here.
532-
*/
533-
char *my_large_virtual_alloc(size_t *size)
534-
{
535-
return my_large_mmap(size, PROT_READ | PROT_WRITE);
536-
}
537497
#endif
538498

539499
/**

mysys/my_virtual_mem.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@
3434
3535
We try to respect use_large_pages setting, on Windows and Linux
3636
*/
37-
#ifndef _WIN32
38-
char *my_large_mmap(size_t *size, int prot);
39-
#endif
40-
37+
#ifdef _WIN32
4138
char *my_virtual_mem_reserve(size_t *size)
4239
{
43-
#ifdef _WIN32
4440
DWORD flags= my_use_large_pages
4541
? MEM_LARGE_PAGES | MEM_RESERVE | MEM_COMMIT
4642
: MEM_RESERVE;
@@ -53,10 +49,8 @@ char *my_virtual_mem_reserve(size_t *size)
5349
my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_ERROR_LOG), *size);
5450
}
5551
return ptr;
56-
#else
57-
return my_large_mmap(size, PROT_NONE);
58-
#endif
5952
}
53+
#endif
6054

6155
#if defined _WIN32 && !defined DBUG_OFF
6256
static my_bool is_memory_committed(char *ptr, size_t size)
@@ -88,7 +82,7 @@ char *my_virtual_mem_commit(char *ptr, size_t size)
8882
}
8983
#else
9084
if (my_use_large_pages)
91-
/* my_large_mmap() already created a read/write mapping. */;
85+
/* my_large_virtual_alloc() already created a read/write mapping. */;
9286
else
9387
{
9488
# ifdef _AIX

storage/innobase/btr/btr0sea.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ ATTRIBUTE_COLD void btr_search_enable(bool resize)
276276
}
277277

278278
btr_search_x_lock_all();
279-
ulint hash_size = buf_pool.curr_size() / sizeof(void *) / 64;
279+
ulint hash_size = buf_pool.curr_pool_size() / sizeof(void *) / 64;
280280

281281
if (btr_search_sys.parts[0].heap) {
282282
ut_ad(btr_search_enabled);

storage/innobase/buf/buf0buddy.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void buf_buddy_free_low(void* buf, ulint i) noexcept
637637
buf_buddy_add_to_free(reinterpret_cast<buf_buddy_free_t*>(buf), i);
638638
}
639639

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

675-
for (;;)
675+
while (i < BUF_BUDDY_SIZES)
676676
{
677677
MEM_UNDEFINED(src, BUF_BUDDY_LOW << i);
678-
ut_ad(i < BUF_BUDDY_SIZES);
679678
/* Try to combine adjacent blocks. */
680679
buf_buddy_free_t *buddy= reinterpret_cast<buf_buddy_free_t*>
681680
(buf_buddy_get(static_cast<byte*>(src), BUF_BUDDY_LOW << i));
@@ -684,20 +683,16 @@ buf_block_t *buf_buddy_shrink(buf_page_t *bpage, buf_block_t *block) noexcept
684683
{
685684
ut_ad(!buf_pool.contains_zip(src, BUF_BUDDY_LOW_SHIFT + i));
686685
buf_buddy_add_to_free(static_cast<buf_buddy_free_t*>(src), i);
687-
break;
686+
return block;
688687
}
689688

690689
/* The buddy is free: recombine */
691690
buf_buddy_remove_from_free(buddy, i);
692691
i++;
693692
src= ut_align_down(src, BUF_BUDDY_LOW << i);
694-
if (i == BUF_BUDDY_SIZES)
695-
{
696-
buf_buddy_block_free(src);
697-
break;
698-
}
699693
}
700694

695+
buf_buddy_block_free(src);
701696
return block;
702697
}
703698

storage/innobase/buf/buf0buf.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,11 @@ bool buf_pool_t::create() noexcept
13341334
retry:
13351335
{
13361336
NUMA_MEMPOLICY_INTERLEAVE_IN_SCOPE;
1337+
#ifdef _WIN32
13371338
memory_unaligned= my_virtual_mem_reserve(&size);
1339+
#else
1340+
memory_unaligned= my_large_virtual_alloc(&size);
1341+
#endif
13381342
}
13391343

13401344
if (!memory_unaligned)
@@ -1368,13 +1372,17 @@ bool buf_pool_t::create() noexcept
13681372
#ifdef UNIV_PFS_MEMORY
13691373
PSI_MEMORY_CALL(memory_alloc)(mem_key_buf_buf_pool, actual_size, &owner);
13701374
#endif
1375+
#ifdef _WIN32
13711376
if (!my_virtual_mem_commit(memory, actual_size))
13721377
{
13731378
my_virtual_mem_release(memory_unaligned, size_unaligned);
13741379
memory= nullptr;
13751380
memory_unaligned= nullptr;
13761381
goto oom;
13771382
}
1383+
#else
1384+
update_malloc_size(actual_size, 0);
1385+
#endif
13781386

13791387
#ifdef HAVE_LIBNUMA
13801388
if (srv_numa_interleave)
@@ -1786,6 +1794,9 @@ ATTRIBUTE_COLD buf_pool_t::shrink_status buf_pool_t::shrink(size_t size)
17861794
goto next;
17871795
}
17881796

1797+
if (UT_LIST_GET_LEN(free) + UT_LIST_GET_LEN(LRU) < usable_size() / 20)
1798+
return SHRINK_ABORT;
1799+
17891800
mysql_mutex_lock(&flush_list_mutex);
17901801

17911802
if (LRU_warned && !UT_LIST_GET_FIRST(free))

0 commit comments

Comments
 (0)