vttranlina opened a new pull request, #1477:
URL: https://github.com/apache/james-project/pull/1477

   We spotted a possible data race issue when populating the query email view, 
giving potentially false results when fetching emails ids via the email query 
view with Email/query jmap method
   
   For example, for a user
   
   ```json
   {
       "using": [
           "urn:ietf:params:jmap:core",
           "urn:ietf:params:jmap:mail"
       ],
       "methodCalls": [
           [
               "Email/query",
               {
                   "accountId": 
"59ecb678c68f69e90d50b580d14512b6c2ec520afe5a3c522113b100235df799",
                   "filter": {
                       "inMailbox": "bb6b69d0-32cf-11eb-995c-a3ae66e9f96a"
                   },
                   "sort": [
                       {
                           "isAscending": false,
                           "property": "receivedAt"
                       }
                   ],
                   "limit": 20
               },
               "c2"
           ],
           [
               "Email/get",
               {
                   "accountId": 
"59ecb678c68f69e90d50b580d14512b6c2ec520afe5a3c522113b100235df799",
                   "#ids": {
                       "resultOf": "c2",
                       "name": "Email/query",
                       "path": "ids/*"
                   }
               },
               "c3"
           ]
       ]
   }
   ```
   
   Then the response 
   ```json
   {
       "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
       "methodResponses": [
           [
               "Email/query",
               {
                   "accountId": 
"59ecb678c68f69e90d50b580d14512b6c2ec520afe5a3c522113b100235df799",
                   "queryState": "d36356fd",
                   "canCalculateChanges": false,
                   "ids": [
                       "8a6b5e00-f4f1-11eb-b5be-2347bf0946f3",
                       "6458a9c0-f4f1-11eb-b5be-2347bf0946f3",
                       "4f07e100-5151-11ec-b483-3d35a4dab7c4"
                   
                   ],
                   "position": 0
               },
               "c2"
           ],
           [
               "Email/get",
               {
                   "accountId": 
"59ecb678c68f69e90d50b580d14512b6c2ec520afe5a3c522113b100235df799",
                   "notFound": [],
                   "state": "497c0f10-bf1c-11ed-8da6-c5628a8cf003",
                   "list": [
                       {
                           "id": "6458a9c0-f4f1-11eb-b5be-2347bf0946f3",
                           "mailboxIds": {
                               "bb6b69d0-32cf-11eb-995c-a3ae66e9f96a": true,
                               "bb794c80-32cf-11eb-995c-a3ae66e9f96a": true
                           }
                       },
                       {
                           "id": "8a6b5e00-f4f1-11eb-b5be-2347bf0946f3",
                           "mailboxIds": {
                               "bb794c80-32cf-11eb-995c-a3ae66e9f96a": true
                           }
                       },
                       {
                           "id": "4f07e100-5151-11ec-b483-3d35a4dab7c4",
                           "mailboxIds": {
                               "bb6b69d0-32cf-11eb-995c-a3ae66e9f96a": true
                           }
                       }
                   ]
               },
               "c3"
           ]
       ]
   }
   ```
   The messageId `4f07e100-5151-11ec-b483-3d35a4dab7c4` is not in 
`bb6b69d0-32cf-11eb-995c-a3ae66e9f96a`, 
   but It is still in the response 
   
   
   The mailbox targeted here is Outbox. Some emails returned are part of that 
mailbox, some others are part of the Sent mailbox, some others are part of both.
   
   When sending email, normal sequence should be:
   
   * users sends the email thus saves it in outbox
   * populate email query view is populated for outbox
   * system moves the email into sent box
   * populate email query view is populated for sent
   
   What maybe happens is:
   
   * users sends the email thus saves it in outbox
   * system moves the email into sent box
   * populate email query view is populated for sent
   * populate email query view is populated for outbox
   
   We need to find a way to handle this case correctly.
   
   
   ## How to fix it?
   
   in the `PopulateEmailQueryViewListener`. re-check the current mailbox-id of 
a message to ensure it is not outdated


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to