From d707130b237f56aeaedf02e74f4416ab54ab676b Mon Sep 17 00:00:00 2001 From: Arkanoider Date: Wed, 4 Oct 2023 21:05:15 +0200 Subject: [PATCH] Dirty fix for memory grow of scheduler threads --- src/app/dispute.rs | 2 +- src/scheduler.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/dispute.rs b/src/app/dispute.rs index 037da451..d719cda8 100644 --- a/src/app/dispute.rs +++ b/src/app/dispute.rs @@ -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(()) } diff --git a/src/scheduler.rs b/src/scheduler.rs index 90374afa..88e9f4b0 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -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), @@ -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 ), @@ -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),