Skip to content

Commit 921d87d

Browse files
author
Jan Lindström
committed
Fixed issue on xtradb shutdown merge error. Multi-threaded flush threads
where not shut down properly.
1 parent 862b034 commit 921d87d

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

storage/innobase/buf/buf0flu.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,10 @@ void pgcomp_init(void)
19731973
{
19741974
os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &pgcomp_mtx);
19751975
}
1976+
void pgcomp_deinit(void)
1977+
{
1978+
os_fast_mutex_free(&pgcomp_mtx);
1979+
}
19761980

19771981
/*******************************************************************//**
19781982
Multi-threaded version of buf_flush_list

storage/innobase/srv/srv0start.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,7 @@ extern void buf_flush_end(buf_pool_t* buf_pool, enum buf_flush flush_type);
14441444
extern void buf_flush_common(enum buf_flush flush_type, ulint page_count);
14451445
extern ulint buf_flush_batch(buf_pool_t* buf_pool, enum buf_flush flush_type, ulint min_n, lsn_t lsn_limit);
14461446
extern void pgcomp_init(void);
1447+
extern void pgcomp_deinit(void);
14471448

14481449
typedef enum wrk_status {
14491450
WRK_ITEM_SET=0, // wrk-item is set
@@ -3277,6 +3278,9 @@ innobase_shutdown_for_mysql(void)
32773278
fprintf(stderr, "%s:%d os_thread_count:%lu \n", __FUNCTION__, __LINE__, os_thread_count);
32783279
#endif
32793280

3281+
/* h. Remove the mutex */
3282+
pgcomp_deinit();
3283+
32803284
os_mutex_enter(os_sync_mutex);
32813285

32823286
if (os_thread_count == 0) {

storage/xtradb/buf/buf0flu.cc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,21 @@ buf_flush_wait_batch_end(
19311931
}
19321932

19331933
/* JAN: TODO: */
1934+
1935+
void buf_pool_enter_LRU_mutex(
1936+
buf_pool_t* buf_pool)
1937+
{
1938+
ut_ad(!mutex_own(&buf_pool->LRU_list_mutex));
1939+
mutex_enter(&buf_pool->LRU_list_mutex);
1940+
}
1941+
1942+
void buf_pool_exit_LRU_mutex(
1943+
buf_pool_t* buf_pool)
1944+
{
1945+
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
1946+
mutex_exit(&buf_pool->LRU_list_mutex);
1947+
}
1948+
19341949
/*******************************************************************//**
19351950
This utility flushes dirty blocks from the end of the LRU list and also
19361951
puts replaceable clean pages from the end of the LRU list to the free
@@ -2053,6 +2068,11 @@ void pgcomp_init(void)
20532068
os_fast_mutex_init(PFS_NOT_INSTRUMENTED, &pgcomp_mtx);
20542069
}
20552070

2071+
void pgcomp_deinit(void)
2072+
{
2073+
os_fast_mutex_free(&pgcomp_mtx);
2074+
}
2075+
20562076
/*******************************************************************//**
20572077
Multi-threaded version of buf_flush_list
20582078
*/
@@ -2096,11 +2116,11 @@ pgcomp_buf_flush_list(
20962116
#ifdef UNIV_DEBUG
20972117
gettimeofday(&p_start_time, 0x0);
20982118
#endif
2099-
os_fast_mutex_lock(&pgcomp_mtx);
2119+
// os_fast_mutex_lock(&pgcomp_mtx);
21002120
pgcomp_flush_work_items(srv_buf_pool_instances,
21012121
cnt_flush, BUF_FLUSH_LIST,
21022122
min_n, lsn_limit);
2103-
os_fast_mutex_unlock(&pgcomp_mtx);
2123+
// os_fast_mutex_unlock(&pgcomp_mtx);
21042124

21052125
for (i = 0; i < srv_buf_pool_instances; i++) {
21062126
if (n_processed) {

storage/xtradb/srv/srv0start.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,9 @@ extern void buf_flush_common(buf_flush_t flush_type, ulint page_count);
15201520
extern ulint buf_flush_batch(buf_pool_t* buf_pool, buf_flush_t flush_type, ulint min_n, lsn_t lsn_limit, bool limited_lru_scan,
15211521
flush_counters_t* n);
15221522
extern void pgcomp_init(void);
1523+
extern void pgcomp_deinit(void);
1524+
extern void buf_pool_enter_LRU_mutex(buf_pool_t*);
1525+
extern void buf_pool_exit_LRU_mutex(buf_pool_t*);
15231526

15241527
typedef enum wrk_status {
15251528
WRK_ITEM_SET=0, // wrk-item is set
@@ -1554,7 +1557,6 @@ typedef struct wr_tsk {
15541557
ulint min; //minimum number of pages requested to be flushed
15551558
lsn_t lsn_limit;//lsn limit for the buffer-pool flush operation
15561559
} wr_tsk_t;
1557-
15581560

15591561
typedef struct rd_tsk {
15601562
void *page_pool; //list of pages to decompress;
@@ -1665,9 +1667,9 @@ int flush_pool_instance(wrk_t *wi)
16651667
/* srv_LRU_scan_depth can be arbitrarily large value.
16661668
* We cap it with current LRU size.
16671669
*/
1668-
buf_pool_mutex_enter(wi->wr.buf_pool);
1670+
buf_pool_enter_LRU_mutex(wi->wr.buf_pool);
16691671
wi->wr.min = UT_LIST_GET_LEN(wi->wr.buf_pool->LRU);
1670-
buf_pool_mutex_exit(wi->wr.buf_pool);
1672+
buf_pool_exit_LRU_mutex(wi->wr.buf_pool);
16711673
wi->wr.min = ut_min(srv_LRU_scan_depth,wi->wr.min);
16721674
}
16731675

@@ -3407,8 +3409,20 @@ innobase_shutdown_for_mysql(void)
34073409
logs_empty_and_mark_files_at_shutdown() and should have
34083410
already quit or is quitting right now. */
34093411

3412+
/* g. Exit the multi threaded flush threads */
3413+
3414+
page_comp_io_thread_exit();
3415+
3416+
#ifdef UNIV_DEBUG
3417+
fprintf(stderr, "%s:%d os_thread_count:%lu \n", __FUNCTION__, __LINE__, os_thread_count);
3418+
#endif
3419+
3420+
/* h. Remove the mutex */
3421+
pgcomp_deinit();
3422+
34103423
os_mutex_enter(os_sync_mutex);
34113424

3425+
34123426
if (os_thread_count == 0) {
34133427
/* All the threads have exited or are just exiting;
34143428
NOTE that the threads may not have completed their

0 commit comments

Comments
 (0)