Skip to content

Commit 7f5e938

Browse files
committed
Add debug logs on ClusterMap methods to debug potential deadlock
1 parent dcc7deb commit 7f5e938

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/net/cluster.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ where
302302
locality: Option<Locality>,
303303
cluster: BTreeSet<Endpoint>,
304304
) {
305+
tracing::debug!("ClusterMap::insert");
305306
let _res = self.apply(remote_addr, locality, EndpointSet::new(cluster));
306307
}
307308

@@ -311,6 +312,7 @@ where
311312
locality: Option<Locality>,
312313
cluster: EndpointSet,
313314
) -> crate::Result<()> {
315+
tracing::debug!("ClusterMap::apply");
314316
if let Some(raddr) = self.localities.get(&locality) {
315317
if *raddr != remote_addr {
316318
eyre::bail!(
@@ -358,26 +360,31 @@ where
358360

359361
#[inline]
360362
pub fn len(&self) -> usize {
363+
tracing::debug!("ClusterMap::len");
361364
self.map.len()
362365
}
363366

364367
#[inline]
365368
pub fn is_empty(&self) -> bool {
369+
tracing::debug!("ClusterMap::is_empty");
366370
self.map.is_empty()
367371
}
368372

369373
#[inline]
370374
pub fn get(&self, key: &Option<Locality>) -> Option<DashMapRef<'_>> {
375+
tracing::debug!("ClusterMap::get");
371376
self.map.get(key)
372377
}
373378

374379
#[inline]
375380
pub fn insert_default(&self, endpoints: BTreeSet<Endpoint>) {
381+
tracing::debug!("ClusterMap::insert_default");
376382
self.insert(None, None, endpoints);
377383
}
378384

379385
#[inline]
380386
pub fn remove_endpoint(&self, needle: &Endpoint) -> bool {
387+
tracing::debug!("ClusterMap::remove_endpoint");
381388
let locality = 'l: {
382389
for mut entry in self.map.iter_mut() {
383390
let set = entry.value_mut();
@@ -403,6 +410,7 @@ where
403410

404411
#[inline]
405412
pub fn remove_endpoint_if(&self, closure: impl Fn(&Endpoint) -> bool) -> bool {
413+
tracing::debug!("ClusterMap::remove_endpoint_if");
406414
let locality = 'l: {
407415
for mut entry in self.map.iter_mut() {
408416
let set = entry.value_mut();
@@ -432,6 +440,7 @@ where
432440

433441
#[inline]
434442
pub fn iter(&self) -> dashmap::iter::Iter<'_, Option<Locality>, EndpointSet, S> {
443+
tracing::debug!("ClusterMap::iter");
435444
self.map.iter()
436445
}
437446

@@ -442,6 +451,7 @@ where
442451
locality: Option<Locality>,
443452
endpoint: Endpoint,
444453
) -> Option<Endpoint> {
454+
tracing::debug!("ClusterMap::replace");
445455
if let Some(raddr) = self.localities.get(&locality) {
446456
if *raddr != remote_addr {
447457
tracing::trace!("not replacing locality endpoints");
@@ -467,6 +477,7 @@ where
467477

468478
#[inline]
469479
pub fn endpoints(&self) -> Vec<Endpoint> {
480+
tracing::debug!("ClusterMap::endpoints");
470481
let mut endpoints = Vec::with_capacity(self.num_of_endpoints());
471482

472483
for set in self.map.iter() {
@@ -477,6 +488,7 @@ where
477488
}
478489

479490
pub fn nth_endpoint(&self, mut index: usize) -> Option<Endpoint> {
491+
tracing::debug!("ClusterMap::nth_endpoint");
480492
for set in self.iter() {
481493
let set = &set.value().endpoints;
482494
if index < set.len() {
@@ -490,6 +502,7 @@ where
490502
}
491503

492504
pub fn filter_endpoints(&self, f: impl Fn(&Endpoint) -> bool) -> Vec<Endpoint> {
505+
tracing::debug!("ClusterMap::filter_endpoints");
493506
let mut endpoints = Vec::new();
494507

495508
for set in self.iter() {
@@ -517,6 +530,7 @@ where
517530
remote_addr: Option<std::net::IpAddr>,
518531
locality: Locality,
519532
) {
533+
tracing::debug!("ClusterMap::update_unlocated_endpoints");
520534
if let Some(raddr) = self.localities.get(&None) {
521535
if *raddr != remote_addr {
522536
tracing::trace!("not updating locality");
@@ -537,6 +551,7 @@ where
537551

538552
#[inline]
539553
fn do_remove_locality(&self, locality: &Option<Locality>) -> Option<EndpointSet> {
554+
tracing::debug!("ClusterMap::do_remove_locality");
540555
self.localities.remove(locality);
541556

542557
let ret = self.map.remove(locality).map(|(_k, v)| v);
@@ -549,6 +564,7 @@ where
549564

550565
#[inline]
551566
pub fn remove_contributor(&self, remote_addr: Option<std::net::IpAddr>) {
567+
tracing::debug!("ClusterMap::remove_contributor");
552568
self.localities.retain(|k, v| {
553569
let keep = *v != remote_addr;
554570
if !keep {
@@ -564,6 +580,7 @@ where
564580
remote_addr: Option<std::net::IpAddr>,
565581
locality: &Option<Locality>,
566582
) -> Option<EndpointSet> {
583+
tracing::debug!("ClusterMap::remove_locality");
567584
{
568585
if let Some(raddr) = self.localities.get(locality) {
569586
if *raddr != remote_addr {
@@ -577,6 +594,7 @@ where
577594
}
578595

579596
pub fn addresses_for_token(&self, token: Token, addrs: &mut Vec<EndpointAddress>) {
597+
tracing::debug!("ClusterMap::addresses_for_token");
580598
if let Some(ma) = self.token_map.get(&token.0) {
581599
addrs.extend(ma.value().iter().cloned());
582600
}

0 commit comments

Comments
 (0)