Skip to content

Commit

Permalink
Fix: workaround cargo leaking SSL_CERT_FILE issue
Browse files Browse the repository at this point in the history
On Linux: command `cargo run` pollutes environment variables: It leaks
`SSL_CERT_FILE` and `SSL_CERT_DIR` to the testing sub progress it runs.
Which cause `reqwest` spending ~50 ms loading the certificates for every
RPC.

We just extend the RPC timeout to work around.

- Fix: #550
  • Loading branch information
drmingdrmer committed Dec 10, 2022
1 parent 6bb6ba3 commit 0e7ab5a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/raft-kv-memstore/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl ExampleClient {
}
.send();

let res = timeout(Duration::from_millis(500), fu).await;
let res = timeout(Duration::from_millis(3_000), fu).await;
let resp = match res {
Ok(x) => x.map_err(|e| RPCError::Network(NetworkError::new(&e)))?,
Err(timeout_err) => {
Expand Down
9 changes: 8 additions & 1 deletion examples/raft-kv-memstore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ pub type ExampleRaft = Raft<ExampleTypeConfig, ExampleNetwork, Arc<ExampleStore>

pub async fn start_example_raft_node(node_id: ExampleNodeId, http_addr: String) -> std::io::Result<()> {
// Create a configuration for the raft instance.
let config = Arc::new(Config::default().validate().unwrap());
let config = Config {
heartbeat_interval: 500,
election_timeout_min: 1500,
election_timeout_max: 3000,
..Default::default()
};

let config = Arc::new(config.validate().unwrap());

// Create a instance of where the Raft data will be stored.
let store = Arc::new(ExampleStore::default());
Expand Down
2 changes: 1 addition & 1 deletion examples/raft-kv-memstore/tests/cluster/test_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async fn test_cluster() -> anyhow::Result<()> {
println!("=== change-membership to 3, ");
let _x = client.change_membership(&btreeset! {3}).await?;

tokio::time::sleep(Duration::from_millis(1_000)).await;
tokio::time::sleep(Duration::from_millis(8_000)).await;

println!("=== metrics after change-membership to {{3}}");
let x = client.metrics().await?;
Expand Down
4 changes: 2 additions & 2 deletions openraft/src/core/raft_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,8 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,

if session_id.membership_log_id != self.engine.state.membership_state.effective.log_id {
tracing::warn!(
"membership_log_id changed: msg sent by: {:?}; curr: {}; ignore when ({})",
session_id.membership_log_id,
"membership_log_id changed: msg sent by: {}; curr: {}; ignore when ({})",
session_id.membership_log_id.summary(),
self.engine.state.membership_state.effective.log_id.summary(),
msg
);
Expand Down

0 comments on commit 0e7ab5a

Please sign in to comment.