Skip to content

Commit

Permalink
Fixes and rebase cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arpad-m committed Jan 24, 2025
1 parent 98b0277 commit 8e7ce7a
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions storage_controller/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ impl Persistence {
+ 'a,
R: Send + 'b,
{
let mut conn = self.connection_pool.get().await?;
let mut retry_count = 0;
loop {
let mut conn = self.connection_pool.get().await?;
match conn
.build_transaction()
.serializable()
Expand Down Expand Up @@ -1228,26 +1228,29 @@ impl Persistence {
) -> Result<(), DatabaseError> {
use crate::schema::safekeepers::dsl::*;

self.with_conn(move |conn| -> DatabaseResult<()> {
#[derive(Insertable, AsChangeset)]
#[diesel(table_name = crate::schema::safekeepers)]
struct UpdateSkSchedulingPolicy<'a> {
id: i64,
scheduling_policy: &'a str,
}
let scheduling_policy_ = String::from(scheduling_policy_);
self.with_conn(move |conn| {
Box::pin(async move {
#[derive(Insertable, AsChangeset)]
#[diesel(table_name = crate::schema::safekeepers)]
struct UpdateSkSchedulingPolicy<'a> {
id: i64,
scheduling_policy: &'a str,
}
let scheduling_policy_ = String::from(scheduling_policy_);

let rows_affected = diesel::update(safekeepers.filter(id.eq(id_)))
.set(scheduling_policy.eq(scheduling_policy_))
.execute(conn)?;
let rows_affected = diesel::update(safekeepers.filter(id.eq(id_)))
.set(scheduling_policy.eq(scheduling_policy_))
.execute(conn)
.await?;

if rows_affected != 1 {
return Err(DatabaseError::Logical(format!(
"unexpected number of rows ({rows_affected})",
)));
}
if rows_affected != 1 {
return Err(DatabaseError::Logical(format!(
"unexpected number of rows ({rows_affected})",
)));
}

Ok(())
Ok(())
})
})
.await
}
Expand Down

0 comments on commit 8e7ce7a

Please sign in to comment.