mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-02-22 23:12:54 +08:00
Increase retry attempts to build UID maps (#17)
This commit is contained in:
parent
481e86fdd4
commit
ed0e41062d
1 changed files with 22 additions and 11 deletions
|
@ -40,6 +40,8 @@ use crate::core::ImapId;
|
|||
|
||||
use super::{MailboxId, MailboxState, NextMailboxState, SelectedMailbox, SessionData};
|
||||
|
||||
const MAX_RETRIES: usize = 50;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct UidMap {
|
||||
uid_next: u32,
|
||||
|
@ -195,7 +197,7 @@ impl SessionData {
|
|||
|
||||
match self.jmap.store.write(batch.build()).await {
|
||||
Ok(_) => (),
|
||||
Err(store::Error::AssertValueFailed) if try_count < 3 => {
|
||||
Err(store::Error::AssertValueFailed) if try_count < MAX_RETRIES => {
|
||||
try_count += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -205,7 +207,7 @@ impl SessionData {
|
|||
account_id = mailbox.account_id,
|
||||
collection = ?Collection::Mailbox,
|
||||
error = ?err,
|
||||
"Failed to store uid map");
|
||||
"Failed to update uid map");
|
||||
return Err(StatusResponse::database_failure());
|
||||
}
|
||||
}
|
||||
|
@ -265,16 +267,25 @@ impl SessionData {
|
|||
.with_account_id(mailbox.account_id)
|
||||
.with_collection(Collection::Mailbox)
|
||||
.update_document(mailbox.mailbox_id.unwrap_or(u32::MAX))
|
||||
.assert_value(Property::EmailIds, ())
|
||||
.value(Property::EmailIds, &uid_map, F_VALUE);
|
||||
self.jmap.store.write(batch.build()).await.map_err(|err| {
|
||||
tracing::error!(event = "error",
|
||||
context = "store",
|
||||
account_id = mailbox.account_id,
|
||||
collection = ?Collection::Mailbox,
|
||||
error = ?err,
|
||||
"Failed to store uid map");
|
||||
StatusResponse::database_failure()
|
||||
})?;
|
||||
|
||||
match self.jmap.store.write(batch.build()).await {
|
||||
Ok(_) => (),
|
||||
Err(store::Error::AssertValueFailed) if try_count < MAX_RETRIES => {
|
||||
try_count += 1;
|
||||
continue;
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(event = "error",
|
||||
context = "store",
|
||||
account_id = mailbox.account_id,
|
||||
collection = ?Collection::Mailbox,
|
||||
error = ?err,
|
||||
"Failed to store new uid map");
|
||||
return Err(StatusResponse::database_failure());
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(MailboxState {
|
||||
uid_next,
|
||||
|
|
Loading…
Reference in a new issue