diff --git a/autopush-common/src/db/dual/mod.rs b/autopush-common/src/db/dual/mod.rs index 7adf26988..336d9e0c5 100644 --- a/autopush-common/src/db/dual/mod.rs +++ b/autopush-common/src/db/dual/mod.rs @@ -191,23 +191,23 @@ impl DbClient for DualClientImpl { debug_assert!(user.version.is_none()); user.version = Some(Uuid::new_v4()); if let Err(e) = self.primary.add_user(&user).await { - if matches!(e, DbError::Conditional) { - // User is being migrated underneath us. - // Try fetching the record from primary again, - // and back off if still not there. - let user = self.primary.get_user(uaid).await?; - // Possibly a higher number of these occur than - // expected, so sanity check that a user now - // exists - self.metrics - .incr_with_tags("database.already_migrated") - .with_tag("exists", &user.is_some().to_string()) - .send(); - if user.is_none() { - return Err(DbError::Backoff("Move in progress".to_owned())); - }; - return Ok(user); + if !matches!(e, DbError::Conditional) { + return Err(e); } + // User is being migrated underneath us. Try + // fetching the record from primary again, and back + // off if still not there. + let user = self.primary.get_user(uaid).await?; + // Possibly a higher number of these occur than + // expected, so sanity check that a user now exists + self.metrics + .incr_with_tags("database.already_migrated") + .with_tag("exists", &user.is_some().to_string()) + .send(); + if user.is_none() { + return Err(DbError::Backoff("Move in progress".to_owned())); + }; + return Ok(user); }; self.metrics.incr_with_tags("database.migrate").send(); let channels = self.secondary.get_channels(uaid).await?;