U4-10739 - PhysicalFileSystem needs retry logic

Created by Claus Jensen 07 Dec 2017, 14:10:12 Updated by Claus Jensen 04 Jan 2018, 11:30:57

Relates to: U4-10802

Subtask of: U4-9609

When a file is currently being accessed by something else, trying to manipulate this file using the PhysicalFileSystem, will throw an exception because it cannot be accessed.

Instead of just throwing - we should implement retry logic, as in most cases the file lock is released immediately after anyway.


Stephan 07 Dec 2017, 14:37:46

note: this is mainly for shadow FS that wants to complete and copy/move files, but throws if the file is busy, and this aborts deploy - having a quick retry loop would help here

Stephan 21 Dec 2017, 13:49:52

PR https://github.com/umbraco/Umbraco-CMS/pull/2359

retrying for IOException only (not the inherited exceptions) - that should cover the "file is used" cases but not the "file does not exist" - review = lock an image file (open in some software) and then delete the media... should throw unless the media is released fast enough

Claus Jensen 04 Jan 2018, 10:57:25

Fixed up a couple of things:

  • The for loop was running the action multiple times without stopping on a first success. Should only run again if it failed before.

  • Sleep was being hit on all attempts - should be scoped to only sleep when actually doing a retry in the loop.

Tested this with file locks and the exception is not thrown until it is done with the specified retry attempts. Exception is thrown correctly when running out of attempts.

I've retargetted to v7.8 and creating a new issue for backporting this if we're doing another release of 7.7.x.

Shannon Deminick 04 Jan 2018, 11:05:57

nice work!

Priority: Normal

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.7.6

Due in version: 7.8.0

Sprint: Sprint 75

Story Points: 1

Cycle: 6