The process cannot access the file because another process has locked a portion of the file

Hi, today I m getting the following error when I try to do anything in my collection:

anki.errors.BackendIOError: IoError(“Os { code: 33, kind: Uncategorized, message: "The process cannot access the file because another process has locked a portion of the file." }”)

Error
An error occurred. Please use Tools > Check Database to see if that fixes the problem.
If problems persist, please report the problem on our support site. Please copy and paste the information below into your report.
Anki 2.1.54 (b6a7760c) Python 3.9.7 Qt 5.15.2 PyQt 5.15.5
Platform: Windows 10
Flags: frz=True ao=False sv=3
Add-ons, last update check: 2022-10-05 12:01:50

Caught exception:
Traceback (most recent call last):
  File "aqt.taskman", line 122, in _on_closures_pending
  File "aqt.taskman", line 71, in <lambda>
  File "aqt.taskman", line 90, in wrapped_done
  File "aqt.dbcheck", line 41, in on_future_done
  File "concurrent.futures._base", line 438, in result
  File "concurrent.futures._base", line 390, in __get_result
  File "concurrent.futures.thread", line 52, in run
  File "aqt.dbcheck", line 36, in do_check
  File "aqt.main", line 1385, in create_backup_now
  File "anki.collection", line 371, in create_backup
  File "anki._backend.generated", line 1789, in create_backup
  File "anki._backend", line 146, in _run_command
anki.errors.BackendIOError: IoError("Os { code: 33, kind: Uncategorized, message: \"The process cannot access the file because another process has locked a portion of the file.\" }")

I restarted my computer, load Anki with no add-ons etc and I cannot even restore from a back up, check the database or anything.

I am inclined to think the error message may not be the exact cause, as I also get it when Anki is idle (perhaps an automatic backup attempt) and no one seems to have reported this error yet.

Thank you

That makes me think something else on your system is reading the file, such as an AV program, or a file syncing program.

I don’t know what that may be. I don’t use antivirus or any syncing. That is why I suspect the error is not reflecting the root cause.

Edit. I opened the same collection with Anki 2.1.49 and I don’t have this issue. Any thoughts? Did the backup changed across these versions? The only think I can speculate is the file size. My collection uncomrpessed was below a GB and now is 1.04GB. Perhaps just a coincidence.

I will be using 2.1.49 for now…

1 Like

I confirm my suspection is true. The error is rised when the collection size is above 1024 MB. I just exported a big deck and delete it from my collection to reduce the size down to 915MB or so. No issues when making backups, checking collections etc. As soon as I import back the deck, therefore, making the collection size above 1024, the error is rised again.

1 Like

Thank you for confirming, I’ve added this to Backup creation fails when collection over 1GB on Windows · Issue #2123 · ankitects/anki · GitHub

2 Likes

Hi,

This issue has reappearted in 2.1.60.

Backup creation failed: ⁨Failed to read ‘C:\Users.…\collection.anki2’:
The process cannot access the file because another process has locked a portion of the file. (os error 33)⁩

If I click File->create backup I get the same error as well, and if I keep insisting I get the following message:

Backup creation failed: ⁨’NoneType’ object has no attribute 'modified_in_python’⁩

Nobody’s gotten around to it yet I’m afraid.

Finally this has been fixed in 2.1.61. Thank you @Rumo

2 Likes