diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2018-07-19 19:13:44 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2018-07-19 19:13:44 +0200 |
commit | fb4b3472d2bfbe877dd7fe50bc834c4b29258eda (patch) | |
tree | 3673ff8bb10afbf114a2735357fb23f6098e0348 /sql | |
parent | 0896d7ebc3698f898bd66544bbc0ba6e4a4fbe0e (diff) | |
parent | 09f147659f36a30d7075885d88392c9a41244505 (diff) | |
download | mariadb-git-fb4b3472d2bfbe877dd7fe50bc834c4b29258eda.tar.gz |
Merge branch '10.1' into bb-10.1-merge-sanja
Diffstat (limited to 'sql')
-rw-r--r-- | sql/wsrep_binlog.cc | 14 | ||||
-rw-r--r-- | sql/wsrep_sst.cc | 26 |
2 files changed, 27 insertions, 13 deletions
diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc index 902190d4772..c7674cd0169 100644 --- a/sql/wsrep_binlog.cc +++ b/sql/wsrep_binlog.cc @@ -326,11 +326,16 @@ void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len) WSREP_ERROR("snprintf error: %d, skipping dump.", len); return; } + /* + len doesn't count the \0 end-of-string. Use len+1 below + to alloc and pass as an argument to snprintf. + */ char *filename= (char *)malloc(len+1); - int len1= snprintf(filename, len, "%s/GRA_%ld_%lld.log", + int len1= snprintf(filename, len+1, "%s/GRA_%ld_%lld.log", wsrep_data_home_dir, thd->thread_id, (long long)wsrep_thd_trx_seqno(thd)); + if (len > len1) { WSREP_ERROR("RBR dump path truncated: %d, skipping dump.", len); @@ -469,7 +474,10 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, int len= snprintf(NULL, 0, "%s/GRA_%ld_%lld_v2.log", wsrep_data_home_dir, thd->thread_id, thd_trx_seqno); - + /* + len doesn't count the \0 end-of-string. Use len+1 below + to alloc and pass as an argument to snprintf. + */ char *filename; if (len < 0 || !(filename= (char*)malloc(len+1))) { @@ -477,7 +485,7 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf, DBUG_VOID_RETURN; } - int len1= snprintf(filename, len, "%s/GRA_%ld_%lld_v2.log", + int len1= snprintf(filename, len+1, "%s/GRA_%ld_%lld_v2.log", wsrep_data_home_dir, thd->thread_id, thd_trx_seqno); diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 60683bf740c..155051bfe84 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -204,8 +204,7 @@ void wsrep_sst_grab () // Wait for end of SST bool wsrep_sst_wait () { - struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0}; - uint32 total_wtime = 0; + double total_wtime = 0; if (mysql_mutex_lock (&LOCK_wsrep_sst)) abort(); @@ -214,14 +213,18 @@ bool wsrep_sst_wait () while (!sst_complete) { + struct timespec wtime; + set_timespec(wtime, WSREP_TIMEDWAIT_SECONDS); + time_t start_time = time(NULL); mysql_cond_timedwait (&COND_wsrep_sst, &LOCK_wsrep_sst, &wtime); + time_t end_time = time(NULL); if (!sst_complete) { - total_wtime += wtime.tv_sec; - WSREP_DEBUG("Waiting for SST to complete. waited %u secs.", total_wtime); + total_wtime += difftime(end_time, start_time); + WSREP_DEBUG("Waiting for SST to complete. current seqno: %ld waited %f secs.", local_seqno, total_wtime); service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL, - "WSREP state transfer ongoing, current seqno: %ld", local_seqno); + "WSREP state transfer ongoing, current seqno: %ld waited %f secs", local_seqno, total_wtime); } } @@ -1319,19 +1322,22 @@ void wsrep_SE_init_grab() void wsrep_SE_init_wait() { - struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0}; - uint32 total_wtime=0; + double total_wtime=0; while (SE_initialized == false) { + struct timespec wtime; + set_timespec(wtime, WSREP_TIMEDWAIT_SECONDS); + time_t start_time = time(NULL); mysql_cond_timedwait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init, &wtime); + time_t end_time = time(NULL); if (!SE_initialized) { - total_wtime += wtime.tv_sec; - WSREP_DEBUG("Waiting for SST to complete. waited %u secs.", total_wtime); + total_wtime += difftime(end_time, start_time); + WSREP_DEBUG("Waiting for SST to complete. current seqno: %ld waited %f secs.", local_seqno, total_wtime); service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL, - "WSREP SE initialization ongoing."); + "WSREP state transfer ongoing, current seqno: %ld waited %f secs", local_seqno, total_wtime); } } |