findNewIds() chunking can return massive duplicate/already-known ID sets and cause memory exhaustion
Los mantenedores suelen responder en 1 día
@kesselb ya está trabajando en esto.
Desde el 28/9/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Comienza en MessageMapper::findNewIds() y sigue el endpoint de sincronización del buzón que se utiliza cuando hay una búsqueda filtrada activa. Reproduce el comportamiento con más de 1.000 IDs conocidas y verifica después que el conjunto devuelto no contenga IDs conocidas ni duplicadas, y que la sincronización ya no se acerque al agotamiento de la memoria.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Steps to reproduce
- Use a mailbox with more than 1000 locally known messages. In our case the mailbox had ~41,000 known messages.
- Open the mailbox in Nextcloud Mail and perform a filtered search.
- Let the client call the mailbox sync endpoint while the filter is active.
- Instrument
MessageMapper::findNewIds()and compare the number of known IDs with the returned new IDs.
In our production case:
knownIds = 40810
but findNewIds() returned approximately:
newIds = 820000
In another request the filtered result reached approximately 982697 IDs.
The issue is caused by chunking the known ID list into groups of 1000 while NOT IN (:ids) only excludes the current chunk.
Expected behavior
findNewIds() should return only IDs that are not present in the complete known-ID set.
Each message ID should be returned at most once, regardless of how the known IDs are chunked internally.
Actual behavior
When the known ID list contains more than 1000 IDs, each SQL query excludes only the current 1000-ID chunk.
Known IDs belonging to the other chunks can therefore be returned again and again.
The results of all chunks are then concatenated, producing a very large result set.
In our case:
knownIds = 40810
newIds = ~820000
This caused the mailbox sync request to approach the 1 GB PHP memory limit and eventually fail with memory exhaustion.
We tested the following workaround successfully:
$knownIds = array_fill_keys($ids, true);
$results = [];
foreach (array_chunk($ids, 1000) as $chunk) {
$select->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
foreach ($this->findIds($select) as $id) {
if (!isset($knownIds[$id])) {
$results[$id] = $id;
}
}
}
return array_values($results);
Mail app version
5.12.0
Nextcloud version
34.0.2
Mailserver or service
IMAP + Gmail
Operating system
Debian GNU/Linux 13 (trixie)
PHP engine version
Other
Nextcloud memory caching
memcache.local: APCu memcache.distributed: Redis memcache.locking: Redis
Web server
Apache (supported)
Database
PostgreSQL
Additional info
PHP: 8.5.10
Web server: Apache 2.4.68
OS: Debian GNU/Linux 13 (trixie)
Nextcloud memory caching:
- memcache.local: \OC\Memcache\APCu
- memcache.distributed: \OC\Memcache\Redis
- memcache.locking: \OC\Memcache\Redis
PHP memory_limit: 1024M
The issue was reproduced on a mailbox with approximately 41,000 locally known messages.
- Lenguaje dominante
- JavaScript
- Estrellas
- 1k
- Forks
- 369
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 118
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
-
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 5 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
-
1. to develop enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
nextcloud/mail#13828 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Show email next to name in Search dropdownPosiblemente ocupada @vansh-nagar la tomó hace 30 días. Abierto1. to develop enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
nextcloud/mail#13703 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud/mail
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Yomguithereal/mnemonist#247 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
up-for-grabs/up-for-grabs.net#6330 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
TheOdinProject/curriculum#31490 ·
Los mantenedores suelen responder en 1 día
-
bug require-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
expressjs/expressjs.com#2549 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Docs: no path for someone who just wants to try IndiekitPosiblemente ocupada @rmdes la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
getindiekit/indiekit#1028 ·
Los mantenedores suelen responder en 1 día