Skip to content

Commit

Permalink
Dirty fix for memory grow of scheduler threads (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanoider authored Oct 4, 2023
1 parent 1a615fa commit 0abb8e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub async fn dispute_action(
created_at: 0,
taken_at: 0,
};
add_dispute(&dispute, &pool).await?;
add_dispute(&dispute, pool).await?;

Ok(())
}
11 changes: 11 additions & 0 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub async fn cron_scheduler(
.await;
}
}

// Drop threads of client to avoid memory usage go up
let _ = client.shutdown().await;

let next_tick = l.next_tick_for_job(uuid).await;
match next_tick {
Ok(Some(ts)) => info!("Next time for 1 minute is {:?}", ts),
Expand Down Expand Up @@ -157,6 +161,10 @@ pub async fn cron_scheduler(

}
}

// Drop threads of client to avoid memory usage go up
let _ = client.shutdown().await;

let next_tick = l.next_tick_for_job(uuid).await;
match next_tick {
Ok(Some(ts)) => info!("Checking orders stuck for more than {} minutes - next check is at {:?}",exp_seconds.to_string(), ts ),
Expand Down Expand Up @@ -191,6 +199,9 @@ pub async fn cron_scheduler(
// Clear list after send events
inner_list.lock().await.clear();

// Drop threads of client to avoid memory usage go up
let _ = client.shutdown().await;

let next_tick = l.next_tick_for_job(uuid).await;
match next_tick {
Ok(Some(ts)) => info!("Next time for 1 hour is {:?}", ts),
Expand Down

0 comments on commit 0abb8e2

Please sign in to comment.