Skip to content

Commit

Permalink
Fix: span.enter() in async loop causes memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Jun 17, 2022
1 parent f633756 commit a0a94af
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
9 changes: 0 additions & 9 deletions openraft/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,6 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
return Ok(());
}

let span = tracing::debug_span!("CHrx:LeaderState");
let _ent = span.enter();

tokio::select! {
Some((msg,span)) = self.core.rx_api.recv() => {
self.handle_msg(msg).instrument(span).await?;
Expand Down Expand Up @@ -914,9 +911,6 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
}
let timeout_fut = sleep_until(self.core.get_next_election_timeout());

let span = tracing::debug_span!("CHrx:CandidateState");
let _ent = span.enter();

tokio::select! {
_ = timeout_fut => break, // This election has timed-out. Break to outer loop, which starts a new term.

Expand Down Expand Up @@ -1067,9 +1061,6 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>
return Ok(());
}

let span = tracing::debug_span!("CHrx:LearnerState");
let _ent = span.enter();

tokio::select! {
Some((msg,span)) = self.core.rx_api.recv() => {
self.handle_msg(msg).instrument(span).await?;
Expand Down
3 changes: 0 additions & 3 deletions openraft/src/replication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,6 @@ impl<D: AppData, R: AppDataResponse, N: RaftNetwork<D>, S: RaftStorage<D, R>> Re
});
}

let span = tracing::debug_span!("CHrx:LineRate");
let _en = span.enter();

// Check raft channel to ensure we are staying up-to-date
self.try_drain_raft_rx().await?;
if self.has_more_log() {
Expand Down

0 comments on commit a0a94af

Please sign in to comment.