This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new c41e9fde43 [ENHANCEMENT] JMAP: limit parallel read in case of fastView 
miss
c41e9fde43 is described below

commit c41e9fde431e6e9c969dd3a336c198bb112802b7
Author: Benoit TELLIER <[email protected]>
AuthorDate: Mon Mar 18 17:14:26 2024 +0100

    [ENHANCEMENT] JMAP: limit parallel read in case of fastView miss
    
    If requesting 30 message fast view, and fast view fails,
    all messages were loaded at once in memory which could
    be catastrophic with large messages.
    
    Avoid this by lowering concurrency, and splitting the calls
---
 .../src/main/scala/org/apache/james/jmap/mail/Email.scala           | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala
 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala
index b7de62a699..f5d620fecd 100644
--- 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Email.scala
@@ -705,10 +705,12 @@ private class EmailFastViewReader 
@Inject()(messageIdManager: MessageIdManager,
       case _ => None
     }
 
+    val lowConcurrency = 2
     SFlux.merge(Seq(
       toFastViews(availables, request, mailboxSession),
-      fullReader.read(unavailables.map(_.id), request, mailboxSession)
-        .doOnNext(storeOnCacheMisses)))
+      SFlux.fromIterable(unavailables.map(_.id))
+        .flatMap(id => fullReader.read(Seq(id), request, mailboxSession)
+          .doOnNext(storeOnCacheMisses), lowConcurrency, lowConcurrency)))
   }
 
   private def storeOnCacheMisses(fullView: EmailFullView) = {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to