Skip to content

Commit

Permalink
Fix the compatibility problem with glog, caused by noflush logging
Browse files Browse the repository at this point in the history
  • Loading branch information
PFZheng committed Apr 26, 2019
1 parent 20ae73b commit 242e47e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
11 changes: 7 additions & 4 deletions src/braft/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2849,14 +2849,17 @@ void NodeImpl::ConfigurationCtx::start(const Configuration& old_conf,
new_conf.diffs(old_conf, &adding, &removing);
_nchanges = adding.size() + removing.size();

LOG(INFO) << "node " << _node->_group_id << ":" << _node->_server_id
<< " change_peers from " << old_conf << " to " << new_conf << noflush;
std::stringstream ss;
ss << "node " << _node->_group_id << ":" << _node->_server_id
<< " change_peers from " << old_conf << " to " << new_conf;

if (adding.empty()) {
LOG(INFO) << ", begin removing.";
ss << ", begin removing.";
LOG(INFO) << ss.str();
return next_stage();
}
LOG(INFO) << ", begin caughtup.";
ss << ", begin caughtup.";
LOG(INFO) << ss.str();
adding.list_peers(&_adding_peers);
for (std::set<PeerId>::const_iterator iter
= _adding_peers.begin(); iter != _adding_peers.end(); ++iter) {
Expand Down
24 changes: 15 additions & 9 deletions src/braft/snapshot_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,18 @@ int SnapshotExecutor::on_snapshot_save_done(
LOG(WARNING) << "node " << _node->node_id() << " fail to close writer";
}

std::stringstream ss;
if (_node) {
LOG(INFO) << "node " << _node->node_id() << ' ' << noflush;
ss << "node " << _node->node_id() << ' ';
}
lck.lock();
if (ret == 0) {
_last_snapshot_index = meta.last_included_index();
_last_snapshot_term = meta.last_included_term();
lck.unlock();
LOG(INFO) << "snapshot_save_done, last_included_index=" << meta.last_included_index()
<< " last_included_term=" << meta.last_included_term();
ss << "snapshot_save_done, last_included_index=" << meta.last_included_index()
<< " last_included_term=" << meta.last_included_term();
LOG(INFO) << ss.str();
_log_manager->set_snapshot(&meta);
lck.lock();
}
Expand Down Expand Up @@ -409,9 +411,11 @@ void SnapshotExecutor::install_snapshot(brpc::Controller* cntl,
// as the retry snapshot will replace this one.
if (ret != 0) {
if (_node) {
LOG(WARNING) << "node " << _node->node_id() << ' ' << noflush;
LOG(WARNING) << "node " << _node->node_id()
<< " fail to register_downloading_snapshot";
} else {
LOG(WARNING) << "Fail to register_downloading_snapshot";
}
LOG(WARNING) << "Fail to register_downloading_snapshot";
if (ret > 0) {
// This RPC will be responded by the previous session
done_guard.release();
Expand Down Expand Up @@ -593,12 +597,14 @@ void SnapshotExecutor::interrupt_downloading_snapshot(int64_t new_term) {
}
CHECK(_cur_copier);
_cur_copier->cancel();
std::stringstream ss;
if (_node) {
LOG(INFO) << "node " << _node->node_id() << ' ' << noflush;
ss << "node " << _node->node_id() << ' ';
}
LOG(INFO) << " Trying to cancel downloading snapshot : "
<< _downloading_snapshot.load(butil::memory_order_relaxed)
->request->ShortDebugString();
ss << "Trying to cancel downloading snapshot : "
<< _downloading_snapshot.load(butil::memory_order_relaxed)
->request->ShortDebugString();
LOG(INFO) << ss.str();
}

void SnapshotExecutor::report_error(int error_code, const char* fmt, ...) {
Expand Down

0 comments on commit 242e47e

Please sign in to comment.