Skip to content

Commit 55fab3d

Browse files
author
Jan Lindström
committed
Fixed issue on atomic writes on startup, removed incorrect assert.
Fixed issue on file space extend when posix_fallocate is used. Merged second iteration of multi-threaded flush code.
1 parent 8c5d5bc commit 55fab3d

File tree

11 files changed

+513
-1143
lines changed

11 files changed

+513
-1143
lines changed

mysql-test/suite/sys_vars/r/innodb_monitor_disable_basic.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ buffer_pool_bytes_dirty disabled
3737
buffer_pool_pages_free disabled
3838
buffer_pages_created disabled
3939
buffer_pages_written disabled
40+
buffer_index_pages_written disabled
4041
buffer_pages_read disabled
4142
buffer_data_reads disabled
4243
buffer_data_written disabled
@@ -160,6 +161,13 @@ compress_pages_compressed disabled
160161
compress_pages_decompressed disabled
161162
compression_pad_increments disabled
162163
compression_pad_decrements disabled
164+
compress_saved disabled
165+
compress_trim_sect512 disabled
166+
compress_trim_sect4096 disabled
167+
compress_pages_page_compressed disabled
168+
compress_page_compressed_trim_op disabled
169+
compress_page_compressed_trim_op_saved disabled
170+
compress_pages_page_decompressed disabled
163171
index_splits disabled
164172
index_merges disabled
165173
adaptive_hash_searches disabled

storage/innobase/buf/buf0flu.cc

Lines changed: 39 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Created 11/11/1995 Heikki Tuuri
4646
#include "ibuf0ibuf.h"
4747
#include "log0log.h"
4848
#include "os0file.h"
49+
#include "os0sync.h"
4950
#include "trx0sys.h"
5051
#include "srv0mon.h"
5152
#include "mysql/plugin.h"
@@ -1934,11 +1935,16 @@ buf_flush_LRU(
19341935
/* JAN: TODO: */
19351936
/*******************************************************************//**/
19361937
extern int is_pgcomp_wrk_init_done(void);
1937-
extern int pgcomp_flush_work_items(int buf_pool_inst, int *pages_flushed,
1938-
int flush_type, int min_n, unsigned long long lsn_limit);
1938+
extern int pgcomp_flush_work_items(
1939+
int buf_pool_inst,
1940+
int *pages_flushed,
1941+
enum buf_flush flush_type,
1942+
int min_n,
1943+
lsn_t lsn_limit);
19391944

19401945
#define MT_COMP_WATER_MARK 50
19411946

1947+
#ifdef UNIV_DEBUG
19421948
#include <time.h>
19431949
int timediff(struct timeval *g_time, struct timeval *s_time, struct timeval *d_time)
19441950
{
@@ -1959,8 +1965,15 @@ int timediff(struct timeval *g_time, struct timeval *s_time, struct timeval *d_t
19591965

19601966
return 0;
19611967
}
1968+
#endif
1969+
1970+
static os_fast_mutex_t pgcomp_mtx;
1971+
1972+
void pgcomp_init(void)
1973+
{
1974+
os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &pgcomp_mtx);
1975+
}
19621976

1963-
static pthread_mutex_t pgcomp_mtx = PTHREAD_MUTEX_INITIALIZER;
19641977
/*******************************************************************//**
19651978
Multi-threaded version of buf_flush_list
19661979
*/
@@ -1983,7 +1996,10 @@ pgcomp_buf_flush_list(
19831996
{
19841997
ulint i;
19851998
bool success = true;
1999+
#ifdef UNIV_DEBUG
19862000
struct timeval p_start_time, p_end_time, d_time;
2001+
#endif
2002+
int cnt_flush[MTFLUSH_MAX_WORKER];
19872003

19882004
if (n_processed) {
19892005
*n_processed = 0;
@@ -2001,96 +2017,34 @@ pgcomp_buf_flush_list(
20012017
#ifdef UNIV_DEBUG
20022018
gettimeofday(&p_start_time, 0x0);
20032019
#endif
2004-
if(is_pgcomp_wrk_init_done() && (min_n > MT_COMP_WATER_MARK)) {
2005-
int cnt_flush[32];
2006-
2007-
//stack_trace();
2008-
pthread_mutex_lock(&pgcomp_mtx);
2009-
//gettimeofday(&p_start_time, 0x0);
2010-
//fprintf(stderr, "Calling into wrk-pgcomp [min:%lu]", min_n);
2011-
pgcomp_flush_work_items(srv_buf_pool_instances,
2012-
cnt_flush, BUF_FLUSH_LIST,
2013-
min_n, lsn_limit);
2014-
2015-
for (i = 0; i < srv_buf_pool_instances; i++) {
2016-
if (n_processed) {
2017-
*n_processed += cnt_flush[i];
2018-
}
2019-
if (cnt_flush[i]) {
2020-
MONITOR_INC_VALUE_CUMULATIVE(
2021-
MONITOR_FLUSH_BATCH_TOTAL_PAGE,
2022-
MONITOR_FLUSH_BATCH_COUNT,
2023-
MONITOR_FLUSH_BATCH_PAGES,
2024-
cnt_flush[i]);
2025-
2026-
}
2027-
}
2028-
2029-
pthread_mutex_unlock(&pgcomp_mtx);
2020+
os_fast_mutex_lock(&pgcomp_mtx);
2021+
pgcomp_flush_work_items(srv_buf_pool_instances,
2022+
cnt_flush, BUF_FLUSH_LIST,
2023+
min_n, lsn_limit);
2024+
os_fast_mutex_unlock(&pgcomp_mtx);
20302025

2031-
#ifdef UNIV_DEBUG
2032-
gettimeofday(&p_end_time, 0x0);
2033-
timediff(&p_end_time, &p_start_time, &d_time);
2034-
fprintf(stderr, "[1] [*n_processed: (min:%lu)%lu %llu usec]\n", (
2035-
min_n * srv_buf_pool_instances), *n_processed,
2036-
(unsigned long long)(d_time.tv_usec+(d_time.tv_sec*1000000)));
2037-
#endif
2038-
return(success);
2039-
}
2040-
/* Flush to lsn_limit in all buffer pool instances */
20412026
for (i = 0; i < srv_buf_pool_instances; i++) {
2042-
buf_pool_t* buf_pool;
2043-
ulint page_count = 0;
2044-
2045-
buf_pool = buf_pool_from_array(i);
2046-
2047-
if (!buf_flush_start(buf_pool, BUF_FLUSH_LIST)) {
2048-
/* We have two choices here. If lsn_limit was
2049-
specified then skipping an instance of buffer
2050-
pool means we cannot guarantee that all pages
2051-
up to lsn_limit has been flushed. We can
2052-
return right now with failure or we can try
2053-
to flush remaining buffer pools up to the
2054-
lsn_limit. We attempt to flush other buffer
2055-
pools based on the assumption that it will
2056-
help in the retry which will follow the
2057-
failure. */
2058-
success = false;
2059-
2060-
continue;
2061-
}
2062-
2063-
page_count = buf_flush_batch(
2064-
buf_pool, BUF_FLUSH_LIST, min_n, lsn_limit);
2065-
2066-
buf_flush_end(buf_pool, BUF_FLUSH_LIST);
2067-
2068-
buf_flush_common(BUF_FLUSH_LIST, page_count);
2069-
20702027
if (n_processed) {
2071-
*n_processed += page_count;
2028+
*n_processed += cnt_flush[i];
20722029
}
2073-
2074-
if (page_count) {
2030+
if (cnt_flush[i]) {
20752031
MONITOR_INC_VALUE_CUMULATIVE(
20762032
MONITOR_FLUSH_BATCH_TOTAL_PAGE,
20772033
MONITOR_FLUSH_BATCH_COUNT,
20782034
MONITOR_FLUSH_BATCH_PAGES,
2079-
page_count);
2035+
cnt_flush[i]);
20802036
}
20812037
}
2082-
2083-
#if UNIV_DEBUG
2038+
#ifdef UNIV_DEBUG
20842039
gettimeofday(&p_end_time, 0x0);
20852040
timediff(&p_end_time, &p_start_time, &d_time);
2086-
2087-
fprintf(stderr, "[2] [*n_processed: (min:%lu)%lu %llu usec]\n", (
2088-
min_n * srv_buf_pool_instances), *n_processed,
2089-
(unsigned long long)(d_time.tv_usec+(d_time.tv_sec*1000000)));
2041+
fprintf(stderr, "%s: [1] [*n_processed: (min:%lu)%lu %llu usec]\n",
2042+
__FUNCTION__, (min_n * srv_buf_pool_instances), *n_processed,
2043+
(unsigned long long)(d_time.tv_usec+(d_time.tv_sec*1000000)));
20902044
#endif
20912045
return(success);
20922046
}
2093-
#endif
2047+
20942048
/* JAN: TODO: END: */
20952049

20962050
/*******************************************************************//**
@@ -2292,18 +2246,21 @@ ulint
22922246
pgcomp_buf_flush_LRU_tail(void)
22932247
/*====================*/
22942248
{
2249+
#ifdef UNIV_DEBUG
22952250
struct timeval p_start_time, p_end_time, d_time;
2251+
#endif
22962252
ulint total_flushed=0, i=0;
22972253
int cnt_flush[32];
22982254

2299-
#if UNIV_DEBUG
2255+
#ifdef UNIV_DEBUG
23002256
gettimeofday(&p_start_time, 0x0);
23012257
#endif
2302-
assert(is_pgcomp_wrk_init_done());
2258+
ut_ad(is_pgcomp_wrk_init_done());
23032259

2304-
pthread_mutex_lock(&pgcomp_mtx);
2260+
os_fast_mutex_lock(&pgcomp_mtx);
23052261
pgcomp_flush_work_items(srv_buf_pool_instances,
23062262
cnt_flush, BUF_FLUSH_LRU, srv_LRU_scan_depth, 0);
2263+
os_fast_mutex_unlock(&pgcomp_mtx);
23072264

23082265
for (i = 0; i < srv_buf_pool_instances; i++) {
23092266
if (cnt_flush[i]) {
@@ -2317,8 +2274,6 @@ pgcomp_buf_flush_LRU_tail(void)
23172274
}
23182275
}
23192276

2320-
pthread_mutex_unlock(&pgcomp_mtx);
2321-
23222277
#if UNIV_DEBUG
23232278
gettimeofday(&p_end_time, 0x0);
23242279
timediff(&p_end_time, &p_start_time, &d_time);
@@ -2894,6 +2849,7 @@ buf_flush_validate(
28942849
}
28952850

28962851
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
2852+
#endif /* !UNIV_HOTBACKUP */
28972853

28982854

28992855
#ifdef UNIV_DEBUG

storage/innobase/fil/fil0fil.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,6 @@ fil_space_create(
12801280
DBUG_EXECUTE_IF("fil_space_create_failure", return(false););
12811281

12821282
ut_a(fil_system);
1283-
ut_a(fsp_flags_is_valid(flags));
12841283

12851284
/* Look for a matching tablespace and if found free it. */
12861285
do {

storage/innobase/include/dict0dict.ic

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,10 @@ dict_tf_set(
859859
if (awrites != ATOMIC_WRITES_DEFAULT) {
860860
*flags |= (atomic_writes << DICT_TF_POS_ATOMIC_WRITES);
861861
ut_ad(dict_tf_get_atomic_writes(*flags) == awrites);
862+
}
863+
864+
if (awrites == ATOMIC_WRITES_ON ||
865+
(awrites == ATOMIC_WRITES_DEFAULT && srv_use_atomic_writes )) {
862866
*flags |= (1 << DICT_TF_POS_ATOMIC_BLOBS);
863867
}
864868

storage/innobase/include/srv0srv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ extern my_bool srv_use_atomic_writes;
257257
/* If this flag IS TRUE, then we use lz4 to compress/decompress pages */
258258
extern my_bool srv_use_lz4;
259259

260+
/* Number of flush threads */
261+
#define MTFLUSH_MAX_WORKER 64
262+
extern ulint srv_mtflush_threads;
263+
260264
#ifdef __WIN__
261265
extern ibool srv_use_native_conditions;
262266
#endif /* __WIN__ */

0 commit comments

Comments
 (0)