Explorar el Código

Extend RPC deadline to 2 seconds.

Longer deadline works better in slow networks, which allows request
to actually return, intead of go totally wasted.
Jing Yang hace 5 años
padre
commit
f285f6f514
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/lib.rs

+ 2 - 1
src/lib.rs

@@ -655,7 +655,7 @@ impl Raft {
         let term = args.term;
         let match_index = args.prev_log_index + args.entries.len();
         let result = tokio::time::timeout(
-            Duration::from_millis(HEARTBEAT_INTERVAL_MILLIS),
+            RPC_DEADLINE,
             Self::append_entries(rpc_client, args),
         )
         .await;
@@ -871,6 +871,7 @@ impl RaftState {
 const HEARTBEAT_INTERVAL_MILLIS: u64 = 150;
 const ELECTION_TIMEOUT_BASE_MILLIS: u64 = 150;
 const ELECTION_TIMEOUT_VAR_MILLIS: u64 = 250;
+const RPC_DEADLINE: Duration = Duration::from_secs(2);
 
 impl ElectionState {
     fn reset_election_timer(&self) {