Consensus proposal pruning improvement. (#314)

Consensus proposal pruning improvement.
hpfs binary fd leak fix.
This commit is contained in:
Ravin Perera
2021-05-29 12:53:49 +05:30
committed by GitHub
parent a6dbf1f277
commit 7cd56a1475
5 changed files with 30 additions and 8 deletions

View File

@@ -104,7 +104,7 @@ namespace consensus
// Throughout consensus, we continously update and prune the candidate proposals for newly
// arived ones and expired ones.
revise_candidate_proposals();
revise_candidate_proposals(ctx.sync_status == 0);
// Get current lcl, state, patch, primary shard and raw shard info.
p2p::sequence_hash lcl_id = ledger::ctx.get_lcl_id();
@@ -139,7 +139,25 @@ namespace consensus
const size_t unl_count = unl::count();
vote_counter votes;
ctx.sync_status = check_sync_status(unl_count, votes, lcl_id);
// Check whether we are in sync with other nodes using proposals.
{
const int new_sync_status = check_sync_status(unl_count, votes, lcl_id);
if (ctx.sync_status != 0 && new_sync_status == 0)
{
// If we are just becoming 'in-sync' after being out-of-sync, check the sync status again after the proper
// pruning of candidate proposals. This is because we relax the proposal pruning rules when we are not in sync,
// and we need to make the final sync status check after proper pruning rules are applied.
LOG_DEBUG << "Rechecking sync status after becoming in-sync.";
revise_candidate_proposals(true);
ctx.sync_status = check_sync_status(unl_count, votes, lcl_id);
}
else
{
ctx.sync_status = new_sync_status;
}
}
if (ctx.sync_status == -2) // Unreliable votes.
{
@@ -320,8 +338,9 @@ namespace consensus
/**
* Moves proposals collected from the network into candidate proposals and
* cleans up any outdated proposals from the candidate set.
* @param in_sync Whether the node is currently on sync or not. We relax the pruning criteria if we are not in sync.
*/
void revise_candidate_proposals()
void revise_candidate_proposals(const bool in_sync)
{
// Move over the incoming proposal collection into a local list. This is to have a private working
// set for candidate parsing and avoid threading conflicts with network incoming proposals.
@@ -371,7 +390,7 @@ namespace consensus
// If we are in sync, only consider this round's proposals which are from current or previous stage.
// Otherwise consider all proposals as long as they are from the same round.
const bool stage_valid = ctx.sync_status == 0 ? (ctx.stage >= cp.stage && (ctx.stage - cp.stage) <= 1) : true;
const bool stage_valid = in_sync ? (ctx.stage >= cp.stage && (ctx.stage - cp.stage) <= 1) : true;
const bool keep_candidate = (ctx.round_start_time == cp.time) && stage_valid;
LOG_DEBUG << (keep_candidate ? "Prop--->" : "Erased")
<< " [s" << std::to_string(cp.stage)

View File

@@ -154,7 +154,7 @@ namespace consensus
int check_sync_status(const size_t unl_count, vote_counter &votes, const p2p::sequence_hash &lcl_id);
void revise_candidate_proposals();
void revise_candidate_proposals(const bool in_sync);
int prepare_consensed_users(consensed_user_map &consensed_users, const p2p::proposal &cons_prop);

View File

@@ -205,6 +205,7 @@ namespace hpfs
if (rw_consumers == 0)
{
LOG_DEBUG << "Stopping rw session at " << rw_dir;
const std::string session_file = mount_dir + RW_SESSION;
if (unlink(session_file.c_str()) == -1)
{

View File

@@ -425,8 +425,10 @@ namespace hpfs
on_sync_target_acheived(target_vpath, target_hash);
}
LOG_DEBUG << "Hpfs " << name << " sync: Current:" << updated_hash << " | target:" << target_hash << " " << target_vpath;
else
{
LOG_DEBUG << "Hpfs " << name << " sync: Current:" << updated_hash << " | target:" << target_hash << " " << target_vpath;
}
}
else
{
@@ -770,7 +772,7 @@ namespace hpfs
}
}
LOG_ERROR << errno << "," << ENOENT << ": Error in stat when applying file/dir mode. " << physical_path;
LOG_ERROR << errno << ": Error in stat when applying file/dir mode. " << physical_path;
return -1;
}

Binary file not shown.