thunderbird / thunderbird-android

Thunderbird for Android – Open Source Email App for Android (fka K-9 Mail)
https://thunderbird.net/
Apache License 2.0
10.02k stars 2.47k forks source link

If saving BinaryTempBody fails, check the cache folder structure exists - if it doesn't, recreate and try again #2486

Open daviwph opened 7 years ago

daviwph commented 7 years ago

Please search to check for an existing issue (including closed issues, for which the fix may not have yet been released) before opening a new issue: https://github.com/k9mail/k-9/issues?q=is%3Aissue

Expected behavior

New emails should appear in the Inbox until deleted or pushed off the bottom

Actual behavior

Phone appears to be polling normally, then, recent emails are no longer visible and new emails are not being received. A Synchronizing Disabled message may appear for in instant. Under the Inbox, the message: "ErrnoException: open failed" remains constant. To resolve the issue, I use TaskManager to stop K9 and then upon restart, K9 Mail runs normally. Emails that came and went, now re-appear is if they are new.

Steps to reproduce

  1. I do a cold start in the morning. First occurrence of ErrnoException may happen around noon.
  2. I have the same issue on another identical phone which uses a different Email provider
  3. K9 Mail has been used successfully on this phone for over 3 years with no issues.

Environment

K-9 Mail version: 5.206

Android version: 4.1.2

Account type (IMAP, POP3, WebDAV/Exchange): IMAP k9mail.txt screenshot_2017-04-04-15-56-35

philipwhiuk commented 7 years ago

How much storage do you have left on the device. It's failing to create a temporary file.

daviwph commented 7 years ago

Hello Philip The phone is reporting 613 MB available. The one clue that I can’t emphasize enough is that it works for about a 1/2 day perfectly. Yesterday, I used Task Manager to stop K9Mail and it suddenly started working again. It’s working perfectly right now.

I really appreciate your help with this.  K9mail has been a wonderful tool since January 2014!

In another unrelated but unexpected occurrence, I completely uninstalled K9Mail in order to do a fresh install of version 5.206 as part of troubleshooting the above problem.  When I used the previous version’s settings, K9 Mail would not start.  There was a blip on the screen and then it was gone.  Unfortunately, I didn’t capture a log.  I simply reconfigured the account manually.

Wayne Davis

From: Philip Sent: Thursday, April 06, 2017 3:45 AM To: k9mail/k-9 Cc: daviwph ; Author Subject: Re: [k9mail/k-9] Issue fetching New Emails typically after several hours of success - ErrnoException: open failed (#2486)

How much storage do you have left on the device. It's failing to create a temporary file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

daviwph commented 7 years ago

I have some information that might help: My phone has a “Task Manager” which came factory installed and not present on the market. I’ve used it to kill processes that linger in the background from Google Maps and Chrome. It also has an automatic “Clear Ram” function that can be set to “Optimize Ram” every hour. To the best of my recollection, I’ve used the “Clear Ram” automatic function for the past 3 years.

Observations: Running “Clear Ram” manually will restart the K9Mail PushService Running “Clear Ram” manually will clear the ErrnoException: open failed condition Setting “Clear Ram” to not run automatically may prevent ErrnoException: open failed from happening

Out of curiosity, is the temporary file in RAM or in the phone’s DATA section? If it’s in RAM and “Clear Ram” removes the reference, it may be causing this unrecoverable error. Just a wild guess.

philipwhiuk commented 7 years ago

It's a file. It's almost certainly stored in a /tmp folder or similar. But that could well be in RAM until the OS flushes it to disk.

If you're running applications that interfere with Android's memory management you're going to see unpredictable problems which we can't reasonably support.

We do our best to fix memory leaks and so on. You shouldn't need to be doing stuff that kills our code abruptly - Android will automatically clean up stuff if it needs to and we test that we behave reasonably.

philipwhiuk commented 7 years ago

If this can be reproduced without that thing running feel free to re-open this.

daviwph commented 7 years ago

Thank you Philip, Yes, it’s OK now and I must reply with a red face.

I found the temp file location in the data folder under /com.fsck.k9/cache

As many times over the years we have seen the message “No such file or directory”, I think it’s safe to say that sometimes there is no such file –because- there is no such directory.  In this case, I believe the sub-directory cache was deleted.  When K9 is starts, it will create a sub-folder /cache/ if there isn’t one and will go on with life.  If /cache/ is deleted in while K9Mail is running, it will try to create a file on a folder that doesn’t exist and we know that will never work.
So yes, I suffered from a self-inflicted wound.  At the risk of sounding like a patch, wouldn’t be wonderful if K9Mail could reinitialize the cache folder as it does when it first starts when open failed occurs.  Then, it could deliver a notification that would say:  “You tried to break me but I’m much smarter than you are”
Thanks for your help!
nh905 commented 6 years ago

I ran into the same problem today on a Samsung Galaxy S4 - no new mail showing up in the Inbox with the error as reported above. I am not using any sort of Task Manager. However, I did clear the system cache yesterday when I noticed disk space was only about 400MB. Rebooting the phone got K-9 working again.

I second the suggestion that K-9 should handle this situation more gracefully.

philipwhiuk commented 6 years ago

I've re-opened it, but in my view it's really low priority - if you're messing around with the file system on Android and not using the inbuilt 'Clear Cache' method then you ought to know what you're deleting. It's like doing rm -r on an application's folder and expecting the application to be fine.

nh905 commented 6 years ago

Hi Philip, I was using the Android 'Clear Cache' command.

philipwhiuk commented 6 years ago

Ah okay, we should definitely handle that :(

uberneko commented 5 years ago

Hello - I confirm that bug still exists - installed some weeks ago K9-email, with two accounts on a LG G4 Android 6 - Everything was ok until I accepted the "Smart Cleaning" yesterday suggested by Android (including deletion app cache).. then when syncing accounts I had "ErrnoException" stated below each folder - impossible to retrieve any email. Only suppression of K9, re-installation (via F-Droid) worked.