Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions galera/src/galera_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,55 @@ galera::View::View(const wsrep_view_info_t& view_info)
}
}

#ifdef PXC
/* An arbitrator (garbd) never applies write sets, so it never sends NBO end
and must not be waited for by the NBO end barrier. garbd always joins as
stateless (gcs.stateless=yes) and with an empty incoming address, whatever
its name. A data node can also be stateless (so it is never chosen as
donor), but it applies write sets and has an incoming address, so it is
still waited for. */
static bool is_arbitrator(const gcs_act_cchange::member& member)
{
return (member.stateless_ && member.incoming_.empty());
}

galera::View::View(const gcs_act_cchange& conf)
:
members_()
{
/* Arbitrators are left out only if every other member does the same.
Otherwise (older nodes in the view, or a CC written by an older node)
wait for all members as before, so that all nodes end the NBO at the
same point. */
bool skip_arbitrators(true);
for (size_t i(0); i < conf.memb.size(); ++i)
{
if (!is_arbitrator(conf.memb[i]) && !conf.memb[i].arb_nbo_)
{
skip_arbitrators = false;
break;
}
}

for (size_t i(0); i < conf.memb.size(); ++i)
{
if (skip_arbitrators && is_arbitrator(conf.memb[i])) continue;
members_.insert(conf.memb[i].uuid_);
}

/* If every member looks like an arbitrator, subset_of() would be
trivially true and NBO would end on the first NBO end message, so wait
for all members instead. */
if (members_.empty())
{
for (size_t i(0); i < conf.memb.size(); ++i)
{
members_.insert(conf.memb[i].uuid_);
}
}
}
#endif /* PXC */

galera::View::~View()
{ }

Expand Down
7 changes: 7 additions & 0 deletions galera/src/galera_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#define GALERA_VIEW_HPP

#include "wsrep_api.h" // for wsrep_view_info_t
#ifdef PXC
#include "gcs.hpp" // for gcs_act_cchange
#endif /* PXC */
#include "gu_uuid.hpp"
#include <set>

Expand Down Expand Up @@ -41,6 +44,10 @@ namespace galera
View();
// Construct View from wsrep_view_info_t
View(const wsrep_view_info_t&);
#ifdef PXC
// Construct View from configuration change, leaving out arbitrators
explicit View(const gcs_act_cchange&);
#endif /* PXC */
// Destructor
~View();
// Return true if the members of the view are subset of
Expand Down
39 changes: 39 additions & 0 deletions galera/src/replicator_smm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,23 @@ galera::ReplicatorSMM::ReplicatorSMM(const struct wsrep_init_args* args)
// update gcache position to one supplied by app.
}

#ifdef PXC
/* Other nodes recognize the arbitrator by the stateless flag and an
empty incoming address, and do not wait for it to end NBO operations
(see galera_view.cpp). A data node must never look the same, so
refuse to start before joining the cluster. */
if (config_.get("gcs.stateless", false) &&
NULL != args->node_incoming && '\0' == args->node_incoming[0])
{
gu_throw_error(EINVAL)
<< "gcs.stateless is set and the node has no address for "
<< "incoming client connections, so the cluster would treat it "
<< "as an arbitrator and would not wait for it to finish NBO "
<< "operations. Unset gcs.stateless or set "
<< "wsrep_node_incoming_address.";
}
#endif /* PXC */

build_stats_vars(wsrep_stats_);
}

Expand Down Expand Up @@ -2797,8 +2814,14 @@ static void validate_local_prim_view_info(const wsrep_view_info_t* view_info,
}
}

#ifdef PXC
bool galera::ReplicatorSMM::skip_prim_conf_change(
const wsrep_view_info_t& view_info, const gcs_act_cchange& conf,
int const proto_ver)
#else
bool galera::ReplicatorSMM::skip_prim_conf_change(
const wsrep_view_info_t& view_info, int const proto_ver)
#endif /* PXC */
{
wsrep_seqno_t cc_seqno(WSREP_SEQNO_UNDEFINED);
bool keep(false); // keep in cache
Expand All @@ -2814,9 +2837,15 @@ bool galera::ReplicatorSMM::skip_prim_conf_change(
assert(cc_seqno == cert_.position() + 1);
const int trx_ver
(std::get<0>(get_trx_protocol_versions(proto_ver)));
#ifdef PXC
cert_.adjust_position(View(conf),
gu::GTID(view_info.state_id.uuid, cc_seqno),
trx_ver);
#else
cert_.adjust_position(view_info,
gu::GTID(view_info.state_id.uuid, cc_seqno),
trx_ver);
#endif /* PXC */
// even if CC was part of SST, it still may carry updated protocol
// version and updated CC seqno
finish_local_prim_conf_change(proto_ver, cc_seqno, "CC");
Expand Down Expand Up @@ -3204,7 +3233,11 @@ void galera::ReplicatorSMM::process_prim_conf_change(void* recv_ctx,
if (conf.seqno <= sst_seqno_)
{
// contained already in SST, skip any further processing
#ifdef PXC
if (skip_prim_conf_change(*view_info, conf, group_proto_version))
#else
if (skip_prim_conf_change(*view_info, group_proto_version))
#endif /* PXC */
{
// was not part of IST, don't discard
cc_buf_discard.keep(conf.seqno);
Expand Down Expand Up @@ -3298,9 +3331,15 @@ void galera::ReplicatorSMM::process_prim_conf_change(void* recv_ctx,
/* since CC does not pass certification, need to adjust cert
* position explicitly (when processed in order) */
/* flushes service thd, must be called before gcache_.seqno_reset()*/
#ifdef PXC
cert_.adjust_position(View(conf),
gu::GTID(group_uuid, group_seqno),
trx_params_.version_);
#else
cert_.adjust_position(*view_info,
gu::GTID(group_uuid, group_seqno),
trx_params_.version_);
#endif /* PXC */

if (first_view)
{
Expand Down
6 changes: 6 additions & 0 deletions galera/src/replicator_smm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,14 @@ namespace galera
void process_non_prim_conf_change(void* recv_ctx,
const gcs_act_cchange&,
int my_index);
#ifdef PXC
bool skip_prim_conf_change(const wsrep_view_info_t& view,
const gcs_act_cchange& conf,
int group_proto_ver);
#else
bool skip_prim_conf_change(const wsrep_view_info_t& view,
int group_proto_ver);
#endif /* PXC */
void process_first_view(const wsrep_view_info_t*, const wsrep_uuid_t&);
void process_group_change(const wsrep_view_info_t*);
void process_st_required(void* recv_ctx, int group_proto_ver,
Expand Down
10 changes: 10 additions & 0 deletions galera/src/replicator_str.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,8 +1899,13 @@ void galera::ReplicatorSMM::process_ist_conf_change(const gcs_act_cchange& conf)
// Establish protocol version before adjusting cert position as
// trx_params_.version is decided there.
establish_protocol_versions (conf.repl_proto_ver);
#ifdef PXC
cert_.adjust_position(View(conf), gu::GTID(conf.uuid, conf.seqno),
trx_params_.version_);
#else
cert_.adjust_position(*view_info, gu::GTID(conf.uuid, conf.seqno),
trx_params_.version_);
#endif /* PXC */
update_incoming_list(*view_info);
record_cc_seqnos(conf.seqno, "ist");

Expand Down Expand Up @@ -1961,8 +1966,13 @@ void ReplicatorSMM::ist_cc(const gcs_action& act, bool must_apply,
primary component and NBO already finished in primary component,
so if we reset nbo waiters, we may not get notifications from
some nodes. The only way is to learn the history through IST */
#ifdef PXC
cert_.adjust_position(View(conf), gu::GTID(conf.uuid, conf.seqno),
trx_params_.version_, false);
#else
cert_.adjust_position(*view_info, gu::GTID(conf.uuid, conf.seqno),
trx_params_.version_, false);
#endif /* PXC */
// record CC related state seqnos needed for IST on DONOR
record_cc_seqnos(conf.seqno, "preload");
::free(view_info);
Expand Down
Loading