Sync that runs out of memory leaves the mailbox locked and is retried forever
Los mantenedores suelen responder en 1 día
@dillardblom ya está trabajando en esto.
Desde el 8/10/2026.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, php
Línea de trabajo
Start with ImapToDbSynchronizer::sync(), its finally-based lock handling, and the sync-token persistence path; then inspect the 15-second retry in Mailbox.vue and the GET /api/messages and POST /api/mailboxes/{id}/sync entry points. Reproduce the partial sync from the CLI at the reported memory limit if possible. Done should prevent repeated identical retries after failure, preserve usable progress or release stale locks, and make the UI show an error instead of looping.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
When a mailbox sync runs out of PHP memory, the PHP process dies with a fatal error. The finally blocks in ImapToDbSynchronizer::sync() that release sync_new_lock, sync_changed_lock and sync_vanished_lock do not run on a fatal error, so the mailbox stays locked until Mailbox::LOCK_TIMEOUT (300 s) expires.
Meanwhile the web UI keeps loading the envelope list. GET /api/messages returns 409 (MailboxLockedException: … is already being synced) and Mailbox.vue waits 15 s and tries again. As soon as the lock expires, the next POST /api/mailboxes/{id}/sync starts the same sync, which runs out of memory again. The sync tokens are only stored after a successful sync, so every attempt starts from the same point and fails in the same way.
The result is a loop that does not end by itself:
- The inbox takes a very long time to load, or does not load, because every envelope request waits for the 15 s retry.
- A PHP fatal error happens every 5 minutes:
Allowed memory size of 536870912 bytes exhausted … horde-imap-client/lib/Horde/Imap/Client/Base.php(in_updateCache(), alsoData/Fetch.php). - The IMAP server sees a new login every 2 seconds from the retrying requests (about 30 per minute instead of 2 or 3).
- Other requests from the same session report
Slow session_start detected.
It stayed like this for over an hour until the sync was run once with a higher memory limit. After that one successful run, the same sync needed 0.4 to 1.7 s and 44 to 71 MB again.
Steps to reproduce
We cannot name the exact trigger. It is probably a rare race condition that mostly shows up with very large mailboxes. Mailboxes of this size are not unusual in companies, though, so the app should be robust against it.
What we saw:
- An INBOX with a large number of messages (here about 18,000) on a Dovecot server with CONDSTORE/QRESYNC.
- Something (unknown) made the next partial sync process a large set of messages.
- PHP's memory limit at 512M (the Nextcloud AIO default).
- Mail opened in the browser.
Expected behavior
Record sync progress along the way, and at the very least when the sync crashes, so that the next attempt does not start over from the beginning and end up in an endless loop. For example, fetch changed messages in chunks and store the sync tokens per chunk.
In addition:
- A sync that keeps failing stops and shows an error instead of being retried in exactly the same form forever.
- A lock whose process no longer exists does not block the mailbox for another 5 minutes.
- The UI does not keep a retry loop running without telling the user anything.
Actual behavior
The loop described above. Running the partial sync from the CLI with the same parameters as the browser (20 known ids, partial sync) reproduces the fatal error at 512M. With a 4G limit it succeeds after 82.5 s with a peak of 586 MB.
Mail app version
5.12.2
Nextcloud version
34.0.4 (All-in-One)
PHP version
8.4 (AIO), memory_limit 512M
Mail server
Dovecot 2.4 (DirectAdmin), IMAP with CONDSTORE/QRESYNC
Additional context
The lock timeout, the finally-based unlocking and the 15 s retry in Mailbox.vue are unchanged on main.
Related, but not the same: #13473 (retry loop on MailboxNotCachedError).
Assisted-by: ClaudeCode:claude-opus-5-5 (debugging)
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.1k
- Forks
- 373
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 99
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nextcloud/mail
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
1. to develop bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nextcloud/mail#13950 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
1. to develop bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
nextcloud/mail#13922 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
1. to develop enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nextcloud/mail#13903 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Feature]: Need a close preview button/option in mail viewPosiblemente ocupada @steven-mpawulo la tomó hace 12 días. Abierto1. to develop enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
nextcloud/mail#13841 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud/mail
Issues similares
-
enhancement version-minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
cuttle-cards/cuttle#1467 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 3-5 días Aptitud para principiantes 62/100
career-ops-hq/career-ops#6399 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Link Checker ReportAbiertoautomated issue report
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
area: hook area: plugin claude-code difficulty: easy dx enhancement good first issue help wanted tech: node
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
flisk-sh/run-my-agents#25 ·