dbox files are always created with DBOX_TEMP_FILE_PREFIX, not the mailbox
list-specific prefix. This was a problem only if dbox was used with
LAYOUT=Maildir++, which nobody was likely to do. Other layouts had
identical temp file prefixes to DBOX_TEMP_FILE_PREFIX.
Timo Sirainen [Tue, 20 Jun 2023 15:44:52 +0000 (18:44 +0300)]
mdbox: Don't do temp file scanning for mailbox directories
The intention was to delete any temporary mail files that have been left
behind by crashed processes, but mail files are written to storage/
directory.
Timo Sirainen [Tue, 20 Jun 2023 15:24:34 +0000 (18:24 +0300)]
mdbox: Fix fdatasync() path when saving mails
It was supposed to be called on the parent directory of where mails were
written, i.e. storage/ directory. The previous code was instead calling it
on the mailbox-specific directory (similarly to sdbox) where nothing was
written.
Timo Sirainen [Sun, 5 Feb 2023 18:47:08 +0000 (20:47 +0200)]
lib-index: Don't update max_tail_offset if write to dovecot.index.log fails
The max_tail_offset didn't actually increase in that situation.
This fixes wrongly updating mail_index_header.log_file_tail_offset after
write to dovecot.index.log failed (due to out of disk space), which in
turn can cause some unexpected errors.
Timo Sirainen [Fri, 24 Mar 2023 00:29:39 +0000 (02:29 +0200)]
imap: Update process title while unhibernating
Previously the process title stayed as [idling] even though the process was
busy waiting on the imap-hibernate process to finish sending the
unhibernation request.
Timo Sirainen [Thu, 23 Mar 2023 23:45:34 +0000 (01:45 +0200)]
imap: Improve disconnection log message if it happens immediately after unhibernation
The "No commands sent after unhibernation" can mean that imap-hibernate
process saw a timeout while unhibernating and shutdown the connection.
Or it can also mean just that the client itself disconnected.
Timo Sirainen [Thu, 23 Mar 2023 23:41:37 +0000 (01:41 +0200)]
imap-hibernate: If unhibernation fails, make sure imap process won't finish it later on
Especially if unhibernation fails due to a connection timeout to imap
process due to high load, it's possible that the imap process will
eventually finish the unhibernation and continue with the client. This is
rather confusing, since imap-hibernate process already logged that the
client got disconnected.
Timo Sirainen [Thu, 23 Mar 2023 20:23:39 +0000 (22:23 +0200)]
master: Fix service { idle_kill } to work better on busy servers
The previous behavior was to kill a process once it had idled for idle_kill
seconds. However, on a busy server the new connections are picked up somewhat
randomly by all the idling processes, so there's never any single process
idling for a long time. This effectively prevents the idle_kill from killing
any processes, even if there are unnecessarily many of them.
The new behavior here tracks the lowest number of idling processes during
idle_kill time interval. Then it kills that many processes. If the load
stays the same, this should shrink the number of processes to the number
that is needed to handle the load, but no more.
Timo Sirainen [Mon, 3 Apr 2023 21:43:55 +0000 (00:43 +0300)]
dsync: Fix handling mailboxes with % character when BROKENCHAR isn't explicitly set in config
When vname_escape_char (= BROKENCHAR) isn't explicitly set in configuration,
'%' character (or if it was hierarchy separator, '~') was used as the default
internal escape character. However, this was used inconsistently between local
and remote mailbox trees. The remote tree stored the mailbox names unescaped,
while the local mailbox names were escaped. This inconsistency caused dsync
to do unnecessary mailbox renames, which might have ended up failing.
This especially fixes dsync failures when mailbox name ended with the '%'
character.
Timo Sirainen [Thu, 9 Feb 2023 15:04:22 +0000 (17:04 +0200)]
lib-imap-client: Fix/clarify selection state handling
The old code assumed that selected_box would be non-NULL while a new mailbox
is being selected. That's not true though, the imapc-storage code closes the
old mailbox before selecting the next one. So the QRESYNC-specific code for
tracking selected-state was never being used. Fixed this, and clarified in
general how the selected-state is supposed to work.
Timo Sirainen [Thu, 9 Feb 2023 14:12:35 +0000 (16:12 +0200)]
imapc: Don't process untagged replies in mailbox that isn't fully selected yet
For example if the communication was:
C: a SELECT box1
...
C: b SELECT box2
S: * 1 EXPUNGE
S: * 1 EXISTS
S: * OK [UIDVALIDITY 1675948459] UIDs valid
S: ...
S: b OK
The expunge was intended for box1, not box2. This caused:
Warning: imapc(...): Mailbox '...' state corrupted: EXPUNGE received for empty mailbox - reconnecting
Fixed this by ignoring untagged EXPUNGE, FETCH, SEARCH and ESEARCH replies
when the UIDVALIDITY reply hasn't been yet received for a mailbox.
Markus Valentin [Mon, 9 Jan 2023 14:06:54 +0000 (15:06 +0100)]
welcome-plugin: Move script_execute() to welcome_create_box()
The welcome script was executed while opening the INBOX only when
the same session had created it. This could have led to unexpectedly not
executing welcome when not opening the mailbox right after it was created.
The original code delayed the welcome script run because mailbox creation
wasn't finished until the mailbox was opened. This seems to have become
fixed at some point.
Timo Sirainen [Mon, 26 Dec 2022 21:48:27 +0000 (23:48 +0200)]
lib-storage: Fix unnecessary data stack growth when iterating mailboxes
When listing mailbox list indexes, it was possible that each iteration
increased the data stack memory usage. It was all freed at the end though,
so this didn't cause any permanent leaks.
This change also slightly changes the lmtp log prefixes in some places.
It removes "conn $ip:$port [$idx]: rcpt $user:" from some of the log
messages (but that wasn't in all of the log messages anyway), but it now
always includes mail_log_prefix in these log messages, which previously
wasn't always set at that point yet.
Timo Sirainen [Tue, 25 Oct 2022 10:27:23 +0000 (13:27 +0300)]
replicator: Make sure to prevent request starvation
This synchronizes how priority queue is ordered vs what
replicator_queue_want_sync_now() returns. The mismatch might have caused
request starvation in some situations because they behaved differently.
Also this change makes sure that higher priority requests don't infinitely
block lower priority requests. Instead, they get a temporary boost time
(hardcoded 15-45 minutes). Afterwards lower priority requests are started
to be handled as well.
Timo Sirainen [Tue, 25 Oct 2022 10:11:37 +0000 (13:11 +0300)]
replicator: Don't update user's last_update if priority doesn't change
This didn't actually matter, since it was only used to check if importing
should update an existing user. However, importing is only run at startup
when all users have last_update=0 anyway.
The following changes bring new use cases for last_update.
Timo Sirainen [Tue, 25 Oct 2022 09:49:03 +0000 (12:49 +0300)]
replicator: Fix user placement in replication queue
Especially replicator queue importing and NOTIFY command could have
placed the user to wrong place in the queue, because they modified the
last sync timestamps afterwards.
Fixed by splitting replicator_queue_add() into get/update/add(), so all
the necessary changes can be done before replicator_queue_add() is used
to place the user into the queue.
Timo Sirainen [Thu, 27 Oct 2022 21:56:29 +0000 (00:56 +0300)]
maildir: If mailbox create fails, don't try to apply mailbox_update changes
This was especially causing problems with mailbox GUID mismatches in dsync.
The mismatch wasn't automatically fixed, because mailbox_create() incorrectly
kept updating the mailbox GUID for the already existing mailbox.
Fixes errors such as:
Remote lost mailbox GUID ... (maybe it was just deleted?)