Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error 409 / Mailbox is locked #3159

Closed
krodelabestiole opened this issue May 28, 2020 · 21 comments
Closed

error 409 / Mailbox is locked #3159

krodelabestiole opened this issue May 28, 2020 · 21 comments

Comments

@krodelabestiole
Copy link

krodelabestiole commented May 28, 2020

The app used to work but I did a few refactoring on my server (going from native debian lamp to dockerised Apache + PHP FPM with traefik). The issue might be related.

Actual behavior

I can't get to the inbox, endless spinning wheel. Chrome console shows an error 409 :
xhr.js:178 GET https://nextcloud.xxxxxx.net/index.php/apps/mail/api/accounts/3/folders/SU5CT1g%3D/messages 409
And on Firefox :
Content Security Policy: Les paramètres de la page ont empêché le chargement d’une ressource à eval (« script-src »).
then :
[INFO] mail: Mailbox is locked {app: "mail", uid: "kro", error: MailboxLockedError at t.convertAxiosError (https://nextcloud.xxxxxx.net/apps/mail/js/mail.js?v=3808e48f-102:844:291) at https://nextcloud.xxxxxx.net/apps/mail/js/mail.js?v=3808e48f-102:355:86791 at async Promise.all (index 0)}

Mail app

Mail app version: 1.3.5

Mailserver or service: Infomaniak (very good email service)

Server configuration

Operating system: Dockerised LAMP services (not nextcloud image) on debian buster.

Web server: Apache

Database: MariaDB

PHP version: FPM 7.4.6

Nextcloud Version: 18.0.4

Client configuration

Browser: latest stable Chrome or vivaldi or firefox

Operating system: Windows

@ChristophWurst
Copy link
Member

Mailbox is locked

This is OK if you have a very large mailbox. Is that the case for you?

Run occ mail:account:diagnose <id> to get more info

@krodelabestiole
Copy link
Author

krodelabestiole commented May 28, 2020

I do have a huge mailbox...

Sorry what id ?

I'm asking because
occ mail:account:diagnose krodelabestiole - which is my uid
returns Account 0 does not exist

@no-response no-response bot removed the needs info label May 28, 2020
@ChristophWurst
Copy link
Member

Open the app. Go to the individual INBOX of your account. See the URL. It something like .../accounts/<id>/.....

@ChristophWurst
Copy link
Member

Alternatively look into the oc_mail_accounts table.

@krodelabestiole
Copy link
Author

thanks :

occ mail:account:diagnose 3
IMAP capabilities:
- +
- AUTH
- IDLE
- IMAP4REV1
- LITERAL
- QUOTA
- UIDPLUS

Account has 56199 messages in 115 mailboxes

@ChristophWurst
Copy link
Member

Account has 56199 messages in 115 mailboxes

Okay, that can take a few minutes. But it should eventually finish.You can check the select count(*) from oc_mail_messages like once a minute to see if it makes any progress.

@krodelabestiole
Copy link
Author

ok thanks ! I will try to be more more patient and close this if it works...
(I have used the app previously with the same mailbox and I have no recall it used to be slow though)

@krodelabestiole
Copy link
Author

krodelabestiole commented May 28, 2020

... just to say I'm running into other error messages during the process (and it has still not ended, I doubt it will) :

[ERROR] mail: Background sync failed: undefined 
{app: "mail", uid: "krodelabestiole", error: MailboxLockedError
    at t.convertAxiosError (https://nextcloud.xxxxxxx.net/apps/mail/js/mail.js?v=3808e48f-102:844:291)
    at https://nextcloud.xxxxxx.net/apps/mail/js/mail.js?v=3808e48f-102:355:86791}

and also GET requests that meet 409 errors, and seem to concern mail.js :

GET https://nextcloud.xxxxx.net/index.php/apps/mail/api/accounts/3/folders/SU5CT1g%3D/messages 409
  | (anonymous) | @ | xhr.js:178
-- | -- | -- | --
  | e.exports | @ | xhr.js:12
  | e.exports | @ | dispatchRequest.js:50
  | Promise.then (async) |   |  
  | u.request | @ | Axios.js:61
  | r.forEach.u.<computed> | @ | Axios.js:76
  | (anonymous) | @ | bind.js:9
  | t.fetchEnvelopes | @ | MessageService.js:49
  | (anonymous) | @ | _pipe.js:3
  | (anonymous) | @ | _arity.js:26
  | fetchEnvelopes | @ | actions.js:257
  | (anonymous) | @ | vuex.esm.js:751
  | l.dispatch | @ | vuex.esm.js:442
  | dispatch | @ | vuex.esm.js:332
  | (anonymous) | @ | actions.js:456
  | u | @ | runtime.js:45
  | (anonymous) | @ | runtime.js:274
  | forEach.e.<computed> | @ | runtime.js:97
  | g | @ | mail.js?v=3808e48f-102:1574
  | i | @ | mail.js?v=3808e48f-102:1574
  | (anonymous) | @ | mail.js?v=3808e48f-102:1574
  | (anonymous) | @ | mail.js?v=3808e48f-102:1574
  ....

@ChristophWurst
Copy link
Member

That is not an error. Thus the 4xx status code. There is just more than one process that tries to sync. And to prevent concurrency issues we lock the mailbox during the synchronization.

The only case where the MailboxLockedException is an issue is when the original sync process was killed (due to an error) and the mailbox remains locked. But even then, the lock will be released after 5min. Keep an eye on your logs. If there is a sync error then it will show up in nextcloud.log.

@krodelabestiole
Copy link
Author

krodelabestiole commented May 28, 2020

I do have some errors on the server log :

{"reqId":"EkpjFhQ54nS9HhLcxnol","level":3,"time":"2020-05-
28T07:33:21+00:00","remoteAddr":"172.19.0.8","user":"--
","app":"index","method":"HEAD","url":"/index.php/apps/mail/api/accounts/3/folders/SU5CT1g%3D/
messages","message":{"Exception":"TypeError","Message":"Argument 7 passed to 
OCA\\Mail\\Controller\\MessagesController::__construct() must be of the type string, null 
given","Code":0,"Trace":
[{"function":"__construct","class":"OCA\\Mail\\Controller\\MessagesController","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":83,"functio
n":"newInstanceArgs","class":"ReflectionClass","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":100,"functi
on":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":115,"functi
on":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":
415,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":
386,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","t
ype":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/App.php","line":112,"function":"query","class":
"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"f
unction":"main","class":"OC\\AppFramework\\App","type":"::"},
{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->"},
{"file":"/srv/www/nextcloud/lib/private/Route/Router.php","line":299,"function":"call_user_func"},
{"file":"/srv/www/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","
type":"->"},
{"file":"/srv/www/nextcloud/index.php","line":38,"function":"handleRequest","class":"OC","type":"::"}],"F
ile":"/srv/www/nextcloud/apps/mail/lib/Controller/MessagesController.php","Line":103,"CustomMess
age":"--"},"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 
(KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36","version":"18.0.4.2"}

@ChristophWurst
Copy link
Member

That is unrelated to the synchronization, though.

@krodelabestiole
Copy link
Author

That is not an error. Thus the 4xx status code.

I would tend to think that 4xx are technically errors (at least on the client side) and I rather not have any...

The script is still running 5 hours later and the database doesn't show any progress :

MariaDB [nextcloud]> select count(*) from oc_mail_messages;
+----------+
| count(*) |
+----------+
|    43409 |
+----------+
1 row in set (0.000 sec)

@krodelabestiole
Copy link
Author

krodelabestiole commented May 29, 2020

when I open the URL retrurning a 409 in a new tab (i.e. https://nextcloud.xxxxxx.net/index.php/apps/mail/api/accounts/3/folders/SU5CT1g%3D/messages),
nextcloud shows this error, which makes more sense :

Accès non autorisé
CSRF check failed

(forbidden access)

Do you have any idea what could cause this CSRF issue ?
... since it is a GET request I guess there si no POST data to pass any CSRF token, unless it is stored in the cookies...

@ChristophWurst
Copy link
Member

I would tend to think that 4xx are technically errors (at least on the client side) and I rather not have any...

Then tell me, what would be the appropriate HTTP status for a request that fails due to locking?

Do you have any idea what could cause this CSRF issue ?
... since it is a GET request I guess there si no POST data to pass any CSRF token, unless it is stored in the cookies...

That is how our CSRF protection works in Nextcloud. This is not really an issue as a user would never directly access the API route and the browser code correctly sends the required token.

@krodelabestiole
Copy link
Author

ah ok, sorry I hadn't understood the 409 was related to the locking !
thank you for this clarification.

still. the inbox never shows up and the database shows no progress... how can I troubleshoot my problem then ?

@ChristophWurst
Copy link
Member

still. the inbox never shows up and the database shows no progress... how can I troubleshoot my problem then ?

You could lower your log level to 0/debug and enable debug mode. Then you trigger the sync from the CLI with occ mail:account:sync <accountId> and keep an eye on nextcloud.log. If there is nothing sensitive there please post the logs here.

Reset log level and debug mode afterwards.

@ChristophWurst
Copy link
Member

closing due to lack of feedback

@eleith
Copy link
Member

eleith commented Nov 7, 2020

i'm experiencing the same symptoms as originally reported.

then, i ran occ mail:account:sync <id> and got the following:

In ImapToDbSynchronizer.php line 235:

Sync failed for 3:INBOX: Return value of OCA\Mail\Address::getEmail() 
must be of the type string or null, bool returned

In Address.php line 78:
                                                                                                  
  Return value of OCA\Mail\Address::getEmail() must be of the type 
string or null, bool returned 

i'll dig into this some more, but posting here for visibility

@eleith
Copy link
Member

eleith commented Nov 7, 2020

looks like this error is at the root

Error: iconv(): Wrong charset, conversion from `UTF-8' to `UTF-8//IGNORE' is not allowed at /var/www/html/apps/mail/lib/Address.php#78

not sure when this started or how i got into this state, but i now see in master some updates that address the null exception

@eleith
Copy link
Member

eleith commented Nov 7, 2020

testing this solution now as this seems to be the root cause with my environment (using alpine): docker-library/php#240 (comment)

....

confirmed. this works. looks like the base nextcloud fpm alpine images will need this for iconv to work correctly.

@eleith
Copy link
Member

eleith commented Nov 7, 2020

looks like this issue was introduced in

4a9ad43#diff-d58572e8c8a251330835114e6e2731fd6ae84a19658ba3f6b578ab137dbcdf61

there is now a PR to address this here: nextcloud/docker#1300 and the issue filed nextcloud/docker#1299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants