1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-30 07:23:07 +03:00

fixing reviewer comments

- style fixes
- small improvement to avoid unnecessary search on close_orphaned_sr
This commit is contained in:
Leandro Pacheco
2019-03-05 10:53:21 +01:00
parent 5ef5becea6
commit ae746fb289
4 changed files with 37 additions and 47 deletions

View File

@ -355,6 +355,7 @@ namespace wsrep
* Return current view * Return current view
*/ */
const wsrep::view& current_view() const { return current_view_; } const wsrep::view& current_view() const { return current_view_; }
/** /**
* Set last committed GTID. * Set last committed GTID.
*/ */

View File

@ -887,21 +887,8 @@ void wsrep::server_state::on_view(const wsrep::view& view,
{ {
wsrep::log_info() wsrep::log_info()
<< "================================================\nView:\n" << "================================================\nView:\n"
<< " id: " << view.state_id() << "\n" << view
<< " seqno: " << view.view_seqno() << "\n" << "=================================================";
<< " status: " << view.status() << "\n"
<< " protocol_version: " << view.protocol_version() << "\n"
<< " own_index: " << view.own_index() << "\n"
<< " final: " << view.final() << "\n"
<< " members";
const std::vector<wsrep::view::member>& members(view.members());
for (std::vector<wsrep::view::member>::const_iterator i(members.begin());
i != members.end(); ++i)
{
wsrep::log_info() << " id: " << i->id() << " "
<< "name: " << i->name();
}
wsrep::log_info() << "=================================================";
if (current_view_.status() == wsrep::view::primary) if (current_view_.status() == wsrep::view::primary)
{ {
previous_primary_view_ = current_view_; previous_primary_view_ = current_view_;
@ -1309,12 +1296,13 @@ void wsrep::server_state::close_orphaned_sr_transactions(
streaming_appliers_map::iterator i(streaming_appliers_.begin()); streaming_appliers_map::iterator i(streaming_appliers_.begin());
while (i != streaming_appliers_.end()) while (i != streaming_appliers_.end())
{ {
bool origin_not_in_view = std::find_if(current_view_.members().begin(), // rollback SR on equal consecutive primary views or if its
// originator is not in the current view
if (equal_consecutive_views ||
(std::find_if(current_view_.members().begin(),
current_view_.members().end(), current_view_.members().end(),
server_id_cmp(i->first.first)) == server_id_cmp(i->first.first)) ==
current_view_.members().end(); current_view_.members().end()))
if (origin_not_in_view || equal_consecutive_views)
{ {
WSREP_LOG_DEBUG(wsrep::log::debug_log_level(), WSREP_LOG_DEBUG(wsrep::log::debug_log_level(),
wsrep::log::debug_level_server_state, wsrep::log::debug_level_server_state,

View File

@ -43,7 +43,8 @@ bool wsrep::view::equal_membership(const wsrep::view& other) const
for (std::vector<member>::const_iterator i(members_.begin()); for (std::vector<member>::const_iterator i(members_.begin());
i != members_.end(); ++i) i != members_.end(); ++i)
{ {
if (other.member_index(i->id()) == -1) { if (other.member_index(i->id()) == -1)
{
return false; return false;
} }
} }
@ -54,7 +55,7 @@ void wsrep::view::print(std::ostream& os) const
{ {
os << " id: " << state_id() << "\n" os << " id: " << state_id() << "\n"
<< " status: " << to_c_string(status()) << "\n" << " status: " << to_c_string(status()) << "\n"
<< " prococol_version: " << protocol_version() << "\n" << " protocol_version: " << protocol_version() << "\n"
<< " capabilities: " << provider::capability::str(capabilities())<<"\n" << " capabilities: " << provider::capability::str(capabilities())<<"\n"
<< " final: " << (final() ? "yes" : "no") << "\n" << " final: " << (final() ? "yes" : "no") << "\n"
<< " own_index: " << own_index() << "\n" << " own_index: " << own_index() << "\n"