1
0

Less emails per transactinos (#4406)

This commit is contained in:
François-Xavier Talbot
2025-09-22 20:40:59 +01:00
committed by GitHub
parent d41b31c775
commit f33efed91b
2 changed files with 30 additions and 6 deletions

View File

@@ -64,8 +64,26 @@ impl BackgroundTask {
}
pub async fn run_email(email_queue: EmailQueue) {
if let Err(error) = email_queue.index().await {
error!(%error, "Failed to index email queue");
// Only index for 5 emails at a time, to reduce transaction length,
// for a total of 100 emails.
for _ in 0..20 {
let then = std::time::Instant::now();
match email_queue.index(5).await {
Ok(true) => {
info!(
"Indexed email queue in {}ms",
then.elapsed().as_millis()
);
}
Ok(false) => {
info!("No more emails to index");
break;
}
Err(error) => {
error!(%error, "Failed to index email queue");
}
}
}
}