@@ -37,13 +37,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang
3737#include " zlib.h"
3838#include " fts0opt.h"
3939#include " fts0vlc.h"
40- #include " wsrep.h"
41-
42- #ifdef WITH_WSREP
43- extern Atomic_relaxed<bool > wsrep_sst_disable_writes;
44- #else
45- constexpr bool wsrep_sst_disable_writes= false ;
46- #endif
4740
4841/* * The FTS optimize thread's work queue. */
4942ib_wqueue_t * fts_optimize_wq;
@@ -52,7 +45,7 @@ static void timer_callback(void*);
5245static tpool::timer* timer;
5346
5447static tpool::task_group task_group (1 );
55- static tpool::task task (fts_optimize_callback,0 , &task_group);
48+ static tpool::waitable_task task (fts_optimize_callback,0 , &task_group);
5649
5750/* * FTS optimize thread, for MDL acquisition */
5851static THD *fts_opt_thd;
@@ -230,7 +223,7 @@ ulong fts_num_word_optimize;
230223char fts_enable_diag_print;
231224
232225/* * ZLib compressed block size.*/
233- static ulint FTS_ZIP_BLOCK_SIZE = 1024 ;
226+ static constexpr ulint FTS_ZIP_BLOCK_SIZE = 1024 ;
234227
235228/* * The amount of time optimizing in a single pass, in seconds. */
236229static ulint fts_optimize_time_limit;
@@ -2831,6 +2824,10 @@ static void fts_optimize_callback(void *)
28312824 static ulint n_tables = ib_vector_size (fts_slots);
28322825
28332826 while (!done && srv_shutdown_state <= SRV_SHUTDOWN_INITIATED ) {
2827+ #ifdef WITH_WSREP
2828+ ut_d (extern Atomic_relaxed<bool > wsrep_sst_disable_writes);
2829+ ut_ad (!wsrep_sst_disable_writes);
2830+ #endif
28342831 /* If there is no message in the queue and we have tables
28352832 to optimize then optimize the tables. */
28362833
@@ -2841,17 +2838,6 @@ static void fts_optimize_callback(void *)
28412838
28422839 /* The queue is empty but we have tables
28432840 to optimize. */
2844- if (UNIV_UNLIKELY (wsrep_sst_disable_writes)) {
2845- retry_later:
2846- if (fts_is_sync_needed ()) {
2847- fts_need_sync = true ;
2848- }
2849- if (n_tables) {
2850- timer->set_time (5000 , 0 );
2851- }
2852- return ;
2853- }
2854-
28552841 fts_slot_t * slot = static_cast <fts_slot_t *>(
28562842 ib_vector_get (fts_slots, current));
28572843
@@ -2872,7 +2858,13 @@ static void fts_optimize_callback(void *)
28722858 (ib_wqueue_nowait (fts_optimize_wq));
28732859 /* Timeout ? */
28742860 if (!msg) {
2875- goto retry_later;
2861+ if (fts_is_sync_needed ()) {
2862+ fts_need_sync = true ;
2863+ }
2864+ if (n_tables) {
2865+ timer->set_time (5000 , 0 );
2866+ }
2867+ return ;
28762868 }
28772869
28782870 switch (msg->type ) {
@@ -2898,11 +2890,6 @@ static void fts_optimize_callback(void *)
28982890 break ;
28992891
29002892 case FTS_MSG_SYNC_TABLE :
2901- if (UNIV_UNLIKELY (wsrep_sst_disable_writes)) {
2902- add_msg (msg);
2903- goto retry_later;
2904- }
2905-
29062893 DBUG_EXECUTE_IF (
29072894 " fts_instrument_msg_sync_sleep" ,
29082895 std::this_thread::sleep_for (
@@ -2945,11 +2932,8 @@ static void fts_optimize_callback(void *)
29452932 ib::info () << " FTS optimize thread exiting." ;
29462933}
29472934
2948- /* *********************************************************************/ /* *
2949- Startup the optimize thread and create the work queue. */
2950- void
2951- fts_optimize_init (void )
2952- /* ===================*/
2935+ /* * Startup the optimize task and create the work queue. */
2936+ void fts_optimize_init ()
29532937{
29542938 mem_heap_t * heap;
29552939 ib_alloc_t * heap_alloc;
@@ -2993,9 +2977,8 @@ fts_optimize_init(void)
29932977 last_check_sync_time = time (NULL );
29942978}
29952979
2996- /* * Shutdown fts optimize thread. */
2997- void
2998- fts_optimize_shutdown ()
2980+ /* * Shut down the fts optimize thread. */
2981+ void fts_optimize_shutdown ()
29992982{
30002983 ut_ad (!srv_read_only_mode);
30012984
@@ -3004,7 +2987,7 @@ fts_optimize_shutdown()
30042987 dict_sys.freeze (SRW_LOCK_CALL );
30052988 mysql_mutex_lock (&fts_optimize_wq->mutex );
30062989 /* Tells FTS optimizer system that we are exiting from
3007- optimizer thread, message send their after will not be
2990+ optimizer thread, messages sent thereafter will not be
30082991 processed */
30092992 fts_opt_start_shutdown = true ;
30102993 dict_sys.unfreeze ();
@@ -3034,6 +3017,26 @@ fts_optimize_shutdown()
30343017 timer = NULL ;
30353018}
30363019
3020+ #ifdef WITH_WSREP
3021+ /* * Pause the optimize subsystem. */
3022+ void fts_optimize_pause ()
3023+ {
3024+ ut_ad (!srv_read_only_mode);
3025+ /* Prevent fts_optimize_callback() from being scheduled. */
3026+ timer->disarm ();
3027+ /* Wait for any current fts_optimize_callback() to finish. */
3028+ task.wait ();
3029+ }
3030+
3031+ /* * Resume after fts_optimize_stop() */
3032+ void fts_optimize_resume ()
3033+ {
3034+ /* Schedule fts_optimize_callback() immediately.
3035+ It will reschedule itself via the timer when needed. */
3036+ srv_thread_pool->submit_task (&task);
3037+ }
3038+ #endif
3039+
30373040/* * Sync the table during commit phase
30383041@param[in] table table to be synced */
30393042void fts_sync_during_ddl (dict_table_t * table)
0 commit comments