Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dirty fix for memory grow of scheduler threads #122

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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