Skip to content

Commit

Permalink
refactor: check both lock and expire time, add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePieWw committed Dec 19, 2024
1 parent 22c628f commit 5074686
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 214 deletions.
14 changes: 4 additions & 10 deletions src/meta-srv/src/election/etcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,9 @@ impl Election for EtcdElection {
.compare_exchange(true, false, Ordering::Relaxed, Ordering::Relaxed)
.is_ok()
{
if let Err(e) = self
.leader_watcher
self.leader_watcher
.send(LeaderChangeMessage::StepDown(Arc::new(leader.clone())))
{
error!(e; "Failed to send leader change message");
}
.context(error::SendLeaderChangeSnafu)?;
}
}

Expand Down Expand Up @@ -342,12 +339,9 @@ impl EtcdElection {
{
self.infancy.store(true, Ordering::Relaxed);

if let Err(e) = self
.leader_watcher
self.leader_watcher
.send(LeaderChangeMessage::Elected(Arc::new(leader)))
{
error!(e; "Failed to send leader change message");
}
.context(error::SendLeaderChangeSnafu)?;
}
}

Expand Down
Loading

0 comments on commit 5074686

Please sign in to comment.