Skip to content

Commit 1214ccb

Browse files
author
Alexey Yurchenko
committed
Merge branch 'MW-384-5.6' into MW-384-5.7
2 parents 0547054 + 1b47af4 commit 1214ccb

File tree

8 files changed

+35
-23
lines changed

8 files changed

+35
-23
lines changed

sql/binlog.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11868,7 +11868,8 @@ TC_LOG::enum_result wsrep_thd_binlog_commit(THD* thd, bool all)
1186811868
- applier and replayer can skip binlog commit
1186911869
- also if node is not joined, replication must be skipped
1187011870
*/
11871-
if (WSREP_EMULATE_BINLOG(thd) && (thd->wsrep_exec_mode != REPL_RECV) && wsrep_ready)
11871+
if (WSREP_EMULATE_BINLOG(thd) && (thd->wsrep_exec_mode != REPL_RECV) &&
11872+
wsrep_ready_get())
1187211873
return mysql_bin_log.commit(thd, all);
1187311874
else
1187411875
return (ha_commit_low(thd, all) ?
@@ -11881,7 +11882,8 @@ int wsrep_thd_binlog_rollback(THD* thd, bool all)
1188111882
- applier and replayer can skip binlog commit
1188211883
- also if node is not joined, replication must be skipped
1188311884
*/
11884-
if (WSREP_EMULATE_BINLOG(thd) && (thd->wsrep_exec_mode != REPL_RECV) && wsrep_ready)
11885+
if (WSREP_EMULATE_BINLOG(thd) && (thd->wsrep_exec_mode != REPL_RECV) &&
11886+
wsrep_ready_get())
1188511887
return mysql_bin_log.rollback(thd, all);
1188611888
else
1188711889
return ha_rollback_low(thd, all);

sql/mysqld.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7584,7 +7584,7 @@ SHOW_VAR status_vars[]= {
75847584
#endif
75857585
#ifdef WITH_WSREP
75867586
{"wsrep_connected", (char*) &wsrep_connected, SHOW_BOOL, SHOW_SCOPE_GLOBAL},
7587-
{"wsrep_ready", (char*) &wsrep_ready, SHOW_BOOL, SHOW_SCOPE_GLOBAL},
7587+
{"wsrep_ready", (char*) &wsrep_show_ready, SHOW_FUNC, SHOW_SCOPE_GLOBAL},
75887588
{"wsrep_cluster_state_uuid", (char*) &wsrep_cluster_state_uuid,SHOW_CHAR_PTR, SHOW_SCOPE_GLOBAL},
75897589
{"wsrep_cluster_conf_id", (char*) &wsrep_cluster_conf_id, SHOW_LONGLONG, SHOW_SCOPE_GLOBAL},
75907590
{"wsrep_cluster_status", (char*) &wsrep_cluster_status, SHOW_CHAR_PTR, SHOW_SCOPE_GLOBAL},

sql/rpl_slave.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7740,7 +7740,7 @@ llstr(rli->get_group_master_log_pos(), llbuff));
77407740
*/
77417741
if (wsrep_node_dropped && wsrep_restart_slave)
77427742
{
7743-
if (wsrep_ready)
7743+
if (wsrep_ready_get())
77447744
{
77457745
WSREP_INFO("Slave error due to node temporarily non-primary"
77467746
"SQL slave will continue");

sql/sql_parse.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,11 @@ bool do_command(THD *thd)
10861086
* allow queries "SET" and "SHOW", they are trapped later in execute_command
10871087
*/
10881088
if (thd->variables.wsrep_on && !thd->wsrep_applier &&
1089-
(!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE) &&
1089+
(!wsrep_ready_get() || wsrep_reject_queries != WSREP_REJECT_NONE) &&
10901090
(server_command_flags[command] & CF_SKIP_WSREP_CHECK) == 0
10911091
) {
10921092
my_message(ER_UNKNOWN_COM_ERROR,
1093-
"WSREP has not yet prepared node for application use", MYF(0));
1093+
"WSREP has not yet prepared node for application use", MYF(0));
10941094
thd->end_statement();
10951095

10961096
/* Performance Schema Interface instrumentation end */
@@ -2967,7 +2967,7 @@ mysql_execute_command(THD *thd, bool first_level)
29672967
*/
29682968
if (thd->variables.wsrep_on &&
29692969
!thd->wsrep_applier &&
2970-
!(wsrep_ready && wsrep_reject_queries == WSREP_REJECT_NONE) &&
2970+
!(wsrep_ready_get() && wsrep_reject_queries == WSREP_REJECT_NONE) &&
29712971
!(thd->variables.wsrep_dirty_reads &&
29722972
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) &&
29732973
!wsrep_tables_accessible_when_detached(all_tables) &&

sql/wsrep_mysqld.cc

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
along with this program; if not, write to the Free Software
1414
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1515

16+
#include <sql_plugin.h> // SHOW_MY_BOOL
1617
#include <mysqld.h>
1718
#include <sql_base.h>
1819
#include <sql_class.h>
@@ -229,7 +230,7 @@ wsrep_view_handler_cb (void* app_ctx,
229230
// version change
230231
if (view->proto_ver != wsrep_protocol_version)
231232
{
232-
my_bool wsrep_ready_saved= wsrep_ready;
233+
my_bool wsrep_ready_saved= wsrep_ready_get();
233234
wsrep_ready_set(FALSE);
234235
WSREP_INFO("closing client connections for "
235236
"protocol change %ld -> %d",
@@ -342,16 +343,34 @@ wsrep_view_handler_cb (void* app_ctx,
342343
return WSREP_CB_SUCCESS;
343344
}
344345

345-
void wsrep_ready_set (my_bool x)
346+
my_bool wsrep_ready_set (my_bool x)
346347
{
347348
WSREP_DEBUG("Setting wsrep_ready to %d", x);
348349
if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort();
349-
if (wsrep_ready != x)
350+
my_bool ret= (wsrep_ready != x);
351+
if (ret)
350352
{
351353
wsrep_ready= x;
352354
mysql_cond_signal (&COND_wsrep_ready);
353355
}
354356
mysql_mutex_unlock (&LOCK_wsrep_ready);
357+
return ret;
358+
}
359+
360+
my_bool wsrep_ready_get (void)
361+
{
362+
if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort();
363+
my_bool ret= wsrep_ready;
364+
mysql_mutex_unlock (&LOCK_wsrep_ready);
365+
return ret;
366+
}
367+
368+
int wsrep_show_ready(THD *thd, SHOW_VAR *var, char *buff)
369+
{
370+
var->type= SHOW_MY_BOOL;
371+
var->value= buff;
372+
*((my_bool *)buff)= wsrep_ready_get();
373+
return 0;
355374
}
356375

357376
// Wait until wsrep has reached ready state
@@ -370,17 +389,8 @@ void wsrep_ready_wait ()
370389
static void wsrep_synced_cb(void* app_ctx)
371390
{
372391
WSREP_INFO("Synchronized with group, ready for connections");
373-
bool signal_main= false;
374-
if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort();
375-
if (!wsrep_ready)
376-
{
377-
wsrep_ready= TRUE;
378-
mysql_cond_signal (&COND_wsrep_ready);
379-
signal_main= true;
380-
381-
}
392+
my_bool signal_main= wsrep_ready_set(TRUE);
382393
local_status.set(WSREP_MEMBER_SYNCED);
383-
mysql_mutex_unlock (&LOCK_wsrep_ready);
384394

385395
if (signal_main)
386396
{

sql/wsrep_mysqld.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ enum enum_wsrep_sync_wait {
125125

126126
// MySQL status variables
127127
extern my_bool wsrep_connected;
128-
extern my_bool wsrep_ready;
129128
extern const char* wsrep_cluster_state_uuid;
130129
extern long long wsrep_cluster_conf_id;
131130
extern const char* wsrep_cluster_status;
@@ -137,6 +136,7 @@ extern const char* wsrep_provider_version;
137136
extern const char* wsrep_provider_vendor;
138137

139138
int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff);
139+
int wsrep_show_ready(THD *thd, SHOW_VAR *var, char *buff);
140140
void wsrep_free_status(THD *thd);
141141

142142
/* Filters out --wsrep-new-cluster oprtion from argv[]
@@ -270,6 +270,7 @@ extern wsrep_seqno_t wsrep_locked_seqno;
270270
((!opt_general_log_raw) && thd->rewritten_query.length() \
271271
? thd->rewritten_query.c_ptr_safe() : thd->query().str)
272272

273+
extern my_bool wsrep_ready_get();
273274
extern void wsrep_ready_wait();
274275

275276
enum wsrep_trx_status {

sql/wsrep_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <pthread.h>
2727
#include <cstdio>
2828

29-
void wsrep_ready_set (my_bool x);
29+
my_bool wsrep_ready_set (my_bool x);
3030

3131
ssize_t wsrep_sst_prepare (void** msg, THD* thd);
3232
wsrep_cb_status wsrep_sst_donate_cb (void* app_ctx,

sql/wsrep_sst.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,6 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
10871087
{
10881088
/* This will be reset when sync callback is called.
10891089
* Should we set wsrep_ready to FALSE here too? */
1090-
// wsrep_notify_status(WSREP_MEMBER_DONOR);
10911090
local_status.set(WSREP_MEMBER_DONOR);
10921091

10931092
const char* method = (char*)msg;

0 commit comments

Comments
 (0)