#ifndef __WIN__ void* #else ulint #endif srv_buffer_pool_proactive_thread( /*=====================*/ /* out: a dummy parameter */ void* arg __attribute__((unused))) /* in: a dummy parameter required by os_thread_create */ { ulint free_blocks, threshold, blocks_to_free; ulint target_blocks, chunk_blocks; #ifdef UNIV_DEBUG_THREAD_CREATION fprintf(stderr, "Buffer pool proactive free thread starts, id %lu\n", os_thread_pf(os_thread_get_curr_id())); fflush(stderr); #endif /* Sleep for 5 seconds in order to give the buffer pool a chance to completely come up before we try to enforce the threshold. */ os_thread_sleep(5000000); while (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) { os_thread_sleep(1000 * srv_buffer_pool_proactive_free_interval); if(!srv_buffer_pool_proactive_free_size) continue; target_blocks = srv_buffer_pool_proactive_free_size / UNIV_PAGE_SIZE; chunk_blocks = srv_buffer_pool_proactive_free_chunk / UNIV_PAGE_SIZE; free_blocks = UT_LIST_GET_LEN(buf_pool->free); blocks_to_free = target_blocks - free_blocks; if(chunk_blocks && (blocks_to_free > chunk_blocks)) { blocks_to_free= chunk_blocks; } if(free_blocks < target_blocks) { buf_flush_batch(BUF_FLUSH_LRU, blocks_to_free, ut_dulint_zero); buf_LRU_search_and_free_block(1, blocks_to_free); } } os_thread_exit(NULL); #ifndef __WIN__ return(NULL); #else return(0); #endif }