Public feed
#893548
#ifndef __WIN__void*#elseulint#endifsrv_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 _size is not configured, loop and wait for the user to dynamically configure it using SET GLOBAL. Note that if _size is 0 and _interval is small, this loop could be quite tight and burn up a lot of CPU. Don't do that. */ if(!srv_buffer_pool_proactive_free_size) continue; /* Target size of free space in blocks */ target_blocks = srv_buffer_pool_proactive_free_size / UNIV_PAGE_SIZE; /* Number of blocks to free in a single pass */ chunk_blocks = srv_buffer_pool_proactive_free_chunk / UNIV_PAGE_SIZE; /* Current number of free blocks */ free_blocks = UT_LIST_GET_LEN(buf_pool->free); /* Try to free all blocks to get to our target */ blocks_to_free = target_blocks - free_blocks; /* Unless a chunk has been configured, then limit ... */ if(chunk_blocks && (blocks_to_free > chunk_blocks)) { blocks_to_free= chunk_blocks; } if(free_blocks < target_blocks) { /* Flush blocks to disk so they are not dirty and can be freed */ buf_flush_batch(BUF_FLUSH_LRU, blocks_to_free, ut_dulint_zero); /* Free blocks to the free list */ buf_LRU_search_and_free_block(1, blocks_to_free); } } os_thread_exit(NULL);#ifndef __WIN__ return(NULL);#else return(0);#endif}