maestral icon indicating copy to clipboard operation
maestral copied to clipboard

Input/output error when trying to enable new selective sync folder on initial merge

Open brandur opened this issue 4 years ago • 13 comments

Describe the bug Preface: Wow — this project is great. I recently got a new M1 Mac and couldn't bring myself to install the existing Dropbox heavyweight Intel binary. Someone mentioned this app so I tried it, and still can't believe how polished it is. Amazing work!

Okay, so this bug may be very specific, but it may occur broadly in a way that I didn't directly experience too. Background: I have a number of separate computers, and was going through each one to disable and remove Dropbox and turn on Maestral in its place. When setting up Maestral, I'd target the existing ~/Dropbox and having it merge.

Some of these computers were syncing my Dropbox completely, and some were using selective sync. When enabling Maestral on the selective sync machines, I tried to enable the same set of folders for selective sync, but made a couple mistakes and enabled some new folders by accident.

Computers that synced fully merged with no problems at all. Computers on selective sync mostly worked, but specifically for folders that I'd newly enabled by accident (so they weren't sync'ing previously on Dropbox, but now were syncing on Maestral) could not sync successfully. Every file appeared in the sync issues log as "input/output error". The files seemed to have been created and were even the right size, but were unusable.

Workaround: No amount of rebuilding the index or restarting Maestral had any effect, but I was eventually able to fix the problem by quitting Maestral, removing the corrupt files that had been created, rsync'ing them from a working installation, then re-enabling Maestral.

To Reproduce

  1. Start from a partially sync'ed Dropbox where selective sync had been used previously such that some folders don't exist yet.
  2. Start Maestral, target the existing Dropbox and tell it to merge. Selective sync all existing folders, but also at least one new folder that had not been previously selective sync'ed.
  3. Wait for Maestral to do the initial index/sync. You'll see that "input/output errors" for all files that were in the newly added selective sync folder.

Expected behaviour If a new selective sync folder is added, those files should be downloaded from Dropbox and sync'ed as expected.

System:

  • Maestral version: v1.5.1
  • Python version: Python 3.8.9
  • OS: macOS Big Sur 11.6
  • Desktop environment: See above
  • PyQt version (for Linux GUI): Oof not sure — command from above fails with a ModuleNotFoundError: No module named 'PyQt5'.

Additional context N/A

brandur avatar Nov 08 '21 01:11 brandur

Thanks for the report! This is a bit concerning since I have come across similar bug reports already without making any headway into understanding what happens. Files are created using Python's builtin methods and this should not typically fail.

Do the files which show this sync error have anything in common, apart form being in newly included folders? Could you also share the detailed traceback from the logs? The log file is located at ~/Library/Logs/maestral.

samschott avatar Nov 08 '21 20:11 samschott

Do the files which show this sync error have anything in common, apart form being in newly included folders?

Nope, just that they were newly selected folders. I ended up adding folders across a couple different media types, so I saw the same thing happen for EPUBs and PDFs that were only a few hundred kBs large, but also for video files that were 1 GB+.

Could you also share the detailed traceback from the logs? The log file is located at ~/Library/Logs/maestral.

Yep! Here's an example of one:

OSError: [Errno 5] Input/output error: '/Users/brandur/Dropbox/books/The Art of Unix Programming.pdf'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "Contents/Resources/app_packages/maestral/sync.py", line 3333, in _create_local_entry
  File "Contents/Resources/app_packages/maestral/sync.py", line 3406, in _on_remote_file
  File "Contents/Resources/app_packages/maestral/sync.py", line 3130, in _check_download_conflict
  File "Contents/Resources/app_packages/maestral/sync.py", line 842, in get_local_hash
  File "Contents/Resources/Support/Python/Resources/lib/python3.9/contextlib.py", line 135, in __exit__
  File "Contents/Resources/app_packages/maestral/client.py", line 143, in convert_api_errors

I scrolled through the logs a little ways and as far as I can tell, all the errors look exactly the same as this one.

brandur avatar Nov 08 '21 20:11 brandur

Oh and one last thing: since I couldn't find any previous issues with this error for Maestral specifically, I started looking for examples of it more broadly and although unfortunately it's quite a broad error message that can occur in quite a few situations, one of the cases it can appear in is for permissions problems. Is there any possibility that Maestral could be creating files without a write permission and then failing on trying to write them (or some such thing)?

brandur avatar Nov 08 '21 21:11 brandur

@brandur, sorry for my slow response time. I moved between countries end of last year and had very little time to spend on Maestral. If you still have the logs from back then, could you answer a few more questions?

  1. The traceback which you show looks like it's cut off before it show where exactly the error was raised. Could you post the remainder?
  2. The example traceback which you show points to the file /Users/brandur/Dropbox/books/The Art of Unix Programming.pdf. Does the file actually exist when the error is raised? Or is Maestral trying to create it as part of the download sync?

Is there any possibility that Maestral could be creating files without a write permission and then failing on trying to write them (or some such thing)?

Maestral will always create files with the same permissions as the user account under which it is running. I.e., if you have write and read permissions for a certain file, so should Maestral.

samschott avatar Jan 13 '22 21:01 samschott

The traceback which you show looks like it's cut off before it show where exactly the error was raised. Could you post the remainder?

Hm, I just looked, and unfortunately I believe the error's since rotated out of the logs, or I can't find it anymore at least, and I haven't experience any similar issues since opening this originally. For what it's worth though, I think I pasted the entire stack trace present in the logs in there.

The example traceback which you show points to the file /Users/brandur/Dropbox/books/The Art of Unix Programming.pdf. Does the file actually exist when the error is raised? Or is Maestral trying to create it as part of the download sync?

So this would've been a new file that Maestral was trying to create as part of a newly selected selective sync folder.

I found that selective sync folders that were already synced worked fine, and new folders on non-selective sync installations also worked fine — it's just this specific case of selective sync with a new selective sync folder that wasn't there before that seems to be the the problem.

brandur avatar Jan 14 '22 00:01 brandur

I believe the error's since rotated out of the logs

Quite possible, the logs are overwritten eventually when they exceed a couple of MB.

it's just this specific case of selective sync with a new selective sync folder that wasn't there before that seems to be the the problem

I've tried to reproduce this scenario but could not. From the traceback which you posted originally, the error occurs when trying to get the content hash of a non-existing local file. This should typically cause a FileNotFoundError which is recognised by Maestral as the file not yet being present locally. However, a OSError: [Errno 5] Input/output error is unexpected and leads to the crash. Errors like this typically occur when the path lies on a network drive which becomes unaccessible, a spinning hard drive with issues, or similar exotic cases. Most occurrences are transient.

There is not much I can do at the moment without reproducing this myself. I am reluctant to just retry on such errors without more information.

samschott avatar Jan 14 '22 22:01 samschott

Glad someone else has had the same issue as me here 😀

I have 2 Dropbox accounts - personal and business. Setup maestral with personal as the default config. Then added Business one. The Personal one syncs without issue and did NOT have selective sync enabled previously. The Business one did have selective sync enabled previously and has same IO errors as above for lots of files. However, some of these files are in folders that were previously selected for sync!

QuaCKeReD avatar Feb 01 '22 12:02 QuaCKeReD

The logs for this, from today, for a file that was is in root DB folder and was previously synced;

2022-01-26 11:54:10 manager INFO: Connected
2022-01-26 11:54:17 manager INFO: Connected
2022-01-26 11:54:48 manager INFO: Connected
2022-01-26 12:06:16 manager INFO: Connected
2022-01-26 12:06:17 main INFO: Excluded /tms
2022-01-26 12:06:17 main INFO: Up to date
2022-01-26 12:06:23 manager INFO: Connected
2022-01-26 12:06:24 main INFO: Excluded /sales
2022-01-26 12:06:24 main INFO: Up to date
2022-01-26 12:06:34 manager INFO: Connected
2022-01-26 12:06:34 main INFO: Up to date
2022-01-26 12:08:10 daemon INFO: Starting daemon
2022-01-26 12:08:10 manager INFO: Connected
2022-01-26 12:08:11 sync INFO: Indexing remote Dropbox
2022-01-26 12:08:12 sync INFO: Indexing 17...
2022-01-26 12:08:12 sync INFO: Creating folders...
2022-01-26 12:08:12 sync INFO: Could not sync Roadmap Template 2.xlsx
Traceback (most recent call last):
  File "Contents/Resources/app_packages/maestral/client.py", line 127, in convert_api_errors
  File "Contents/Resources/app_packages/maestral/sync.py", line 843, in get_local_hash
  File "Contents/Resources/app_packages/maestral/utils/path.py", line 416, in content_hash
OSError: [Errno 5] Input/output error: '/Users/mark/Dropbox/TMS//Roadmap Template 2.xlsx'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "Contents/Resources/app_packages/maestral/sync.py", line 3353, in _create_local_entry
  File "Contents/Resources/app_packages/maestral/sync.py", line 3432, in _on_remote_file
  File "Contents/Resources/app_packages/maestral/sync.py", line 3147, in _check_download_conflict
  File "Contents/Resources/app_packages/maestral/sync.py", line 842, in get_local_hash
  File "Contents/Resources/Support/Python/Resources/lib/python3.10/contextlib.py", line 153, in __exit__
  File "Contents/Resources/app_packages/maestral/client.py", line 144, in convert_api_errors
maestral.errors.FileReadError: Could not sync file or folder. Could not access file. Errno 5: Input/output error.

QuaCKeReD avatar Feb 01 '22 12:02 QuaCKeReD

I also get the following, when starting the sync via terminal;

Notification failed
Traceback (most recent call last):
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 206, in __call__
KeyError: frozenset({''})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Contents/Resources/app_packages/desktop_notifier/base.py", line 204, in send
  File "Contents/Resources/app_packages/desktop_notifier/macos.py", line 252, in _send
  File "Contents/Resources/app_packages/desktop_notifier/macos.py", line 366, in _create_category_for_notification
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 236, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 215, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 153, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 1519, in ns_from_py
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 236, in __call__
  File "Contents/Resources/app_packages/rubicon/objc/api.py", line 208, in __call__
ValueError: No method was found starting with 'addObject' and with keywords set()
Known keywords are:
frozenset({'toPropertyWithKey', ''})
frozenset({'', 'toBothSidesOfRelationshipWithKey'})

QuaCKeReD avatar Feb 01 '22 12:02 QuaCKeReD

Think I understand the cause now - new file storage!

By default, my business account had the option for 'save hard drive space automatically' turned on and set to 'Online-only' - meaning all files I hadn't been using were kept as placeholders on local disk.

I have turned this feature off and reset maestral sync on this account - no issues reported now!

QuaCKeReD avatar Feb 01 '22 16:02 QuaCKeReD

Ahh, that explains things! Those funky placeholder files that download on demand are managed by some black magic kernel extension provided by Dropbox.

samschott avatar Feb 01 '22 20:02 samschott

@QuaCKeReD, could you open a new issue for the notification error in https://github.com/samschott/desktop-notifier, also specifying if you are running on Apple Silicon?

samschott avatar Feb 01 '22 20:02 samschott

Apologies for delay, created issue now

QuaCKeReD avatar Apr 01 '22 15:04 QuaCKeReD