3030#include < cstdio>
3131#include < cstdlib>
3232
33+ #include < my_service_manager.h>
34+
3335static char wsrep_defaults_file[FN_REFLEN * 2 + 10 + 30 +
3436 sizeof (WSREP_SST_OPT_CONF) +
3537 sizeof (WSREP_SST_OPT_CONF_SUFFIX) +
@@ -177,6 +179,9 @@ bool wsrep_before_SE()
177179static bool sst_complete = false ;
178180static bool sst_needed = false ;
179181
182+ #define WSREP_EXTEND_TIMEOUT_INTERVAL 30
183+ #define WSREP_TIMEDWAIT_SECONDS 10
184+
180185void wsrep_sst_grab ()
181186{
182187 WSREP_INFO (" wsrep_sst_grab()" );
@@ -188,11 +193,25 @@ void wsrep_sst_grab ()
188193// Wait for end of SST
189194bool wsrep_sst_wait ()
190195{
191- if (mysql_mutex_lock (&LOCK_wsrep_sst)) abort ();
196+ struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0 };
197+ uint32 total_wtime = 0 ;
198+
199+ if (mysql_mutex_lock (&LOCK_wsrep_sst))
200+ abort ();
201+
202+ WSREP_INFO (" Waiting for SST to complete." );
203+
192204 while (!sst_complete)
193205 {
194- WSREP_INFO (" Waiting for SST to complete." );
195- mysql_cond_wait (&COND_wsrep_sst, &LOCK_wsrep_sst);
206+ mysql_cond_timedwait (&COND_wsrep_sst, &LOCK_wsrep_sst, &wtime);
207+
208+ if (!sst_complete)
209+ {
210+ total_wtime += wtime.tv_sec ;
211+ WSREP_DEBUG (" Waiting for SST to complete. waited %u secs." , total_wtime);
212+ service_manager_extend_timeout (WSREP_EXTEND_TIMEOUT_INTERVAL,
213+ " WSREP state transfer ongoing, current seqno: %ld" , local_seqno);
214+ }
196215 }
197216
198217 if (local_seqno >= 0 )
@@ -1347,10 +1366,22 @@ void wsrep_SE_init_grab()
13471366
13481367void wsrep_SE_init_wait ()
13491368{
1369+ struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0 };
1370+ uint32 total_wtime=0 ;
1371+
13501372 while (SE_initialized == false )
13511373 {
1352- mysql_cond_wait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init);
1374+ mysql_cond_timedwait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init, &wtime);
1375+
1376+ if (!SE_initialized)
1377+ {
1378+ total_wtime += wtime.tv_sec ;
1379+ WSREP_DEBUG (" Waiting for SST to complete. waited %u secs." , total_wtime);
1380+ service_manager_extend_timeout (WSREP_EXTEND_TIMEOUT_INTERVAL,
1381+ " WSREP SE initialization ongoing." );
1382+ }
13531383 }
1384+
13541385 mysql_mutex_unlock (&LOCK_wsrep_sst_init);
13551386}
13561387
0 commit comments