findNewIds() chunking can return massive duplicate/already-known ID sets and cause memory exhaustion
I maintainer di solito rispondono entro 1 giorno
@kesselb ci sta già lavorando.
Dal 28/9/2026.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia da MessageMapper::findNewIds() e segui l’endpoint di sincronizzazione della mailbox utilizzato quando è attiva una ricerca filtrata. Riproduci il comportamento con più di 1.000 ID noti, quindi verifica che l’insieme restituito non contenga ID noti o duplicati e che la sincronizzazione non si avvicini più all’esaurimento della memoria.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 1k
- Fork
- 359
- Merge medio
- 2g 1h
- PR unite (30g)
- 98
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nextcloud/mail
-
1. to develop enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nextcloud/mail#13703 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
1. to develop bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
nextcloud/mail#13472 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
1. to develop technical debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
0. to triage bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
Filter: Apply actions to all incoming messagesForse già presa @kesselb l’ha presa 1 giorno fa. Aperta1. to develop bug
nextcloud/mail#13784 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nextcloud/mail
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openlibhums/janeway#5604 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Generic OSC does not initialize OSC client on startup when "Listen for Feedback" is disabledAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
area/statement-execution TS conversion
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scylladb/nodejs-rs-driver#584 ·
I maintainer di solito rispondono entro 2 giorni
-
新讀者走讀回報,照著一篇文章實際操作Apertadocumentation good first issue help wanted
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
I maintainer di solito rispondono entro 2 giorni