mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-12-11 13:56:27 +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};
|
use super::{MailboxId, MailboxState, NextMailboxState, SelectedMailbox, SessionData};
|
||||||
|
|
||||||
|
const MAX_RETRIES: usize = 50;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct UidMap {
|
struct UidMap {
|
||||||
uid_next: u32,
|
uid_next: u32,
|
||||||
|
|
@ -195,7 +197,7 @@ impl SessionData {
|
||||||
|
|
||||||
match self.jmap.store.write(batch.build()).await {
|
match self.jmap.store.write(batch.build()).await {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(store::Error::AssertValueFailed) if try_count < 3 => {
|
Err(store::Error::AssertValueFailed) if try_count < MAX_RETRIES => {
|
||||||
try_count += 1;
|
try_count += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +207,7 @@ impl SessionData {
|
||||||
account_id = mailbox.account_id,
|
account_id = mailbox.account_id,
|
||||||
collection = ?Collection::Mailbox,
|
collection = ?Collection::Mailbox,
|
||||||
error = ?err,
|
error = ?err,
|
||||||
"Failed to store uid map");
|
"Failed to update uid map");
|
||||||
return Err(StatusResponse::database_failure());
|
return Err(StatusResponse::database_failure());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,16 +267,25 @@ impl SessionData {
|
||||||
.with_account_id(mailbox.account_id)
|
.with_account_id(mailbox.account_id)
|
||||||
.with_collection(Collection::Mailbox)
|
.with_collection(Collection::Mailbox)
|
||||||
.update_document(mailbox.mailbox_id.unwrap_or(u32::MAX))
|
.update_document(mailbox.mailbox_id.unwrap_or(u32::MAX))
|
||||||
|
.assert_value(Property::EmailIds, ())
|
||||||
.value(Property::EmailIds, &uid_map, F_VALUE);
|
.value(Property::EmailIds, &uid_map, F_VALUE);
|
||||||
self.jmap.store.write(batch.build()).await.map_err(|err| {
|
|
||||||
tracing::error!(event = "error",
|
match self.jmap.store.write(batch.build()).await {
|
||||||
context = "store",
|
Ok(_) => (),
|
||||||
account_id = mailbox.account_id,
|
Err(store::Error::AssertValueFailed) if try_count < MAX_RETRIES => {
|
||||||
collection = ?Collection::Mailbox,
|
try_count += 1;
|
||||||
error = ?err,
|
continue;
|
||||||
"Failed to store uid map");
|
}
|
||||||
StatusResponse::database_failure()
|
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 {
|
return Ok(MailboxState {
|
||||||
uid_next,
|
uid_next,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue