# 2.0.4.5 - The process cannot access the file because it is being used by another process

**URL:** https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515
**Category:** Uncategorized
**Created:** [December 5, 2018, 10:41am UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515 "2018-12-05T10:41:55Z")
**Posts on this page:** 8
**Page:** 2

<div class="post-metadata">

### Author: ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)
#### Post date: [March 11, 2022, 2:13pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/22 "2022-03-11T14:13:37Z")

</div>

> [@PaulHop](#):
>
> “The process cannot access the file because it is being used by another process”

If the stack trace details look similar to original post, there’s an update you might try:

> [@Large job stopped halfway. Stuck in loops, either "database is locked" or "No filelists found on the remote destination" EDIT: auto-cleanup bug?](https://forum.duplicati.com/t/large-job-stopped-halfway-stuck-in-loops-either-database-is-locked-or-no-filelists-found-on-the-remote-destination-edit-auto-cleanup-bug/11861/2):
>
> OK, found why the database locks itself out when running the job:
> 
> **auto-cleanup**
> 
> When auto-cleanup is set to on I always get the _“The process cannot access the file because it is being used by another process.”_ on the database itself.
> 
> When auto-cleanup is turned off I have no problems with any locked file

> [@PaulHop](#):
>
> there’s still a bug lurking in there somewhere

> [@PaulHop](#):
>
> Anyway, it’s a guess, as I don’t have time to go through the code.

One technical writeup theorizing about what’s going on is:

[Database is locked when performing auto-cleanup #4631](https://github.com/duplicati/duplicati/issues/4631#issuecomment-955601902)

If above map helps any, have at it. Duplicati is very much in need of people willing to help in any area, whether it’s helping on forum, test, documentation, or (all-important to forward progress) development.

---

<div class="post-metadata">

### Author: ![PaulHop](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@PaulHop](https://forum.duplicati.com/u/PaulHop)
#### Post date: [March 11, 2022, 3:38pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/23 "2022-03-11T15:38:17Z")

</div>

Thank you ts678… when the database locks for me it occurs shortly after the “verify files” part of the backup, i.e. at the beginning so I don’t think it’s associated with auto-cleanup for me.

I again set max threads to 1 and managed to rebuild the database. I have changed database backup frequency to 6 hourly (i.e. 4 times a day) and only keep the last 10 days of backups. This should reduce the current database size significantly (and reduce it a little further over time as the 4 hourly backups are replaced with 6 hourly).

The backup looked like it was running well but just after “Deleting unwanted files” it reports “The remote server returned an error: (403) forbidden”… this is another issue and a topic for a different thread. Now I can’t get past the 403 error. I’m stuck, I’ll try again later.

---

<div class="post-metadata">

### Author: ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)
#### Post date: [March 11, 2022, 4:39pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/24 "2022-03-11T16:39:33Z")

</div>

> [@PaulHop](#):
>
> it occurs shortly after the “verify files” part of the backup

If you mean after it starts that, that’s exactly when it may run – if option asks for that – does yours?

> <https://github.com/duplicati/duplicati/blob/fd1e687ac8a5a872fd15b88633c3f95c00a9e4f9/Duplicati/Library/Main/Operation/BackupHandler.cs#L144-L174>

---

<div class="post-metadata">

### Author: ![PaulHop](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@PaulHop](https://forum.duplicati.com/u/PaulHop)
#### Post date: [March 12, 2022, 1:30pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/25 "2022-03-12T13:30:09Z")

</div>

It’s happening after “Verify Files”, it sits on Verify Files for a while so I assume it has completed it. I don’t know what steps in the process display something in the notification bar but nothing else displays as far as I can see before the error occurs.

Just looking through RunAsync which calls PreBackupVerify… PreBackupVerify is called on line 466. On line 482 the progress bar is definitely updated to “Processing Files”. I suspect the code is having issues in UploadSyntheticFileList on 469 or RecreateMissingIndexFiles on 479. Both these areas appear to pass in a new instance of the database (which is suspicious given the error, but I’m not sure because “var” is used on line 431 so I don’t know what the datatype is - it’s a significant problem when using “var”). I haven’t delved into these two areas so I’m not sure what’s in them.

I have seen a potential issue… RunAsync is obviously called asynchronously. In RunAsync variables such as m\_result, m\_database, etc. are shared but they don’t have locks around them when their properties are assigned. If m\_result (for example) is cached then it’s properties are also cached, writing to a property of m\_result could write to a cached property and without a lock statement this won’t be flushed to memory immediately. Correct me if I’m wrong, but I would have thought that all these shared object property assignments should have locks around them.

---

<div class="post-metadata">

### Author: ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)
#### Post date: [March 12, 2022, 2:00pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/26 "2022-03-12T14:00:47Z")

</div>

> [@PaulHop](#):
>
> it sits on Verify Files for a while so I assume it has completed

> [@PaulHop](#):
>
> nothing else displays as far as I can see before the error occurs.

One problem with using status to know where you are is that all you know is you’ve gotten as far as the status seen, but not as far as the next one, and some aren’t specifically seen because of other displays which fill the status bar – one can see phase at About → System info, e.g. for Backup\_ProcessingFiles.

[Stuck on “Waiting for upload to finish”](https://forum.duplicati.com/t/stuck-on-waiting-for-upload-to-finish/13951/30) gave an example of finding phases at the finishing end of backup.

One can sometimes also study log messages (which can be set quite high) to try to figure out locations. Ruling out auto-cleanup, though, may be as easy as your saying it is or is not in your Advanced options.

> [@PaulHop](#):
>
> Correct me if I’m wrong, but I would have thought that all these shared object property assignments should have locks around them.

You would have to ask a C# developer, which I’m not, but sometimes I can follow Duplicati code around. There is unfortunately a huge need for Duplicati developers, as well as for people to help with anything.

---

<div class="post-metadata">

### Author: ![PaulHop](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/p/0ea827/32.png) [@PaulHop](https://forum.duplicati.com/u/PaulHop)
#### Post date: [March 14, 2022, 10:30am UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/27 "2022-03-14T10:30:16Z")

</div>

Now that I’ve fixed the 403 (forbidden) error I was receiving (that we’ve been discussing in another thread) and reduced the size of my backup I’m not having this issue any longer. I’ll revert my settings to backing up often to try to cause the issue and if it occurs I’ll investigate from there.

At some point I’ll investigate where I think locking is missing… that issue seems to be quite common in the code.

---

<div class="post-metadata">

### Author: ![funnym0nk3y](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/f/8baadc/32.png) [@funnym0nk3y](https://forum.duplicati.com/u/funnym0nk3y)
#### Post date: [July 1, 2022, 10:55pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/28 "2022-07-01T22:55:40Z")

</div>

I’m having this issue with version 2.6.3 beta too. It seems that when the database is locked once it persists. Killing the process in task manager does not help and the repair job also fails.

---

<div class="post-metadata">

### Author: ![frank](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/f/3d9bf3/32.png) [@frank](https://forum.duplicati.com/u/frank)
#### Post date: [January 16, 2024, 4:50pm UTC](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515/29 "2024-01-16T16:50:39Z")

</div>

I encountered that issue with Duplicati - version 2.0.7.1\_beta\_2023-05-25 during one of the three backups on my system.

Using the simple repair option in the database commands resolved the issues. Following that, I was able to proceed with the backup as usual

[Previous page](https://forum.duplicati.com/t/2-0-4-5-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/5515.md?page=1)
