|
/** |
|
* The number of times we will attempt to delete files/directory trees |
|
* before giving up and throwing an exception.<br/> |
|
* Specifying a value less than 1 is invalid and will be treated as if |
|
* a value of 1 (i.e. one attempt, no retries) was specified. |
|
* <p> |
|
* e.g. if some of the child directories are big, it might take long enough |
|
* to delete that it allows others to create new files in the directory we |
|
* are trying to empty, causing problems like JENKINS-10113. |
|
* Or, if we're on Windows, then deletes can fail for transient reasons |
|
* regardless of external activity; see JENKINS-15331. |
|
* Whatever the reason, this allows us to do multiple attempts before we |
|
* give up, thus improving build reliability. |
|
*/ |
|
@Restricted(value = NoExternalUse.class) |
|
static int DELETION_MAX = Math.max(1, SystemProperties.getInteger(Util.class.getName() + ".maxFileDeletionRetries", 3)); |
is confused.
The properties is for "retries" which you should be able to disable with a count of zero. but you can not. but the comment implies it is just for the number of tries (not retries).
However the code calls PathRemover.newFilteredRobustRemover(pathChecker, DELETION_MAX - 1, GC_AFTER_FAILED_DELETE, WAIT_BETWEEN_DELETION_RETRIES);]
which ends up in
|
public static PathRemover newFilteredRobustRemover(@Nonnull PathChecker pathChecker, int maxRetries, boolean gcAfterFailedRemove, long waitBetweenRetries) { |
|
return new PathRemover(new PausingGCRetryStrategy(Math.max(maxRetries, 1), gcAfterFailedRemove, waitBetweenRetries), pathChecker); |
|
} |
which is using a max retries.
However if you run a test with the system property set to one. then you do get one retry not one try.
-DargLine=-Dhudson.Util.maxFileDeletionRetries=1
Unable to delete 'C:\Users\IEUser\Desktop\oc-server\target\tmp\j h6725733765603761727'. Tried 2 time (of a maximum of 2) waiting 0.1 sec between attempts.
so the property does seem to be acting as a retry despite the code comment but you can not set it to zero one because...
static int DELETION_MAX = Math.max(1, SystemProperties.getInteger(Util.class.getName() + ".maxFileDeletionRetries", 3));
and the PathRemover]..
return new PathRemover(new PausingGCRetryStrategy(Math.max(maxRetries, 1), gcAfterFailedRemove, waitBetweenRetries), pathChecker);
which means it will always retry once, which is a PITA when trying to some timing bugs.
Originally reported by
teilo, imported from: can not disable the retries of Util.delete
- status: Resolved
- priority: Minor
- component(s): core
- label(s): 2.204.2-fixed
- resolution: Fixed
- resolved: 2019-12-20T10:35:50+00:00
- votes: 0
- watchers: 1
- imported: 2025-11-24
Raw content of original issue
|
/** |
|
* The number of times we will attempt to delete files/directory trees |
|
* before giving up and throwing an exception.<br/> |
|
* Specifying a value less than 1 is invalid and will be treated as if |
|
* a value of 1 (i.e. one attempt, no retries) was specified. |
|
* <p> |
|
* e.g. if some of the child directories are big, it might take long enough |
|
* to delete that it allows others to create new files in the directory we |
|
* are trying to empty, causing problems like JENKINS-10113. |
|
* Or, if we're on Windows, then deletes can fail for transient reasons |
|
* regardless of external activity; see JENKINS-15331. |
|
* Whatever the reason, this allows us to do multiple attempts before we |
|
* give up, thus improving build reliability. |
|
*/ |
|
@Restricted(value = NoExternalUse.class) |
|
static int DELETION_MAX = Math.max(1, SystemProperties.getInteger(Util.class.getName() + ".maxFileDeletionRetries", 3)); |
is confused.
The properties is for "retries" which you should be able to disable with a count of zero. but you can not. but the comment implies it is just for the number of tries (not retries).
However the code calls PathRemover.newFilteredRobustRemover(pathChecker, DELETION_MAX - 1, GC_AFTER_FAILED_DELETE, WAIT_BETWEEN_DELETION_RETRIES);]
which ends up in
|
public static PathRemover newFilteredRobustRemover(@Nonnull PathChecker pathChecker, int maxRetries, boolean gcAfterFailedRemove, long waitBetweenRetries) { |
|
return new PathRemover(new PausingGCRetryStrategy(Math.max(maxRetries, 1), gcAfterFailedRemove, waitBetweenRetries), pathChecker); |
|
} |
which is using a max retries.
However if you run a test with the system property set to one. then you do get one retry not one try.
-DargLine=-Dhudson.Util.maxFileDeletionRetries=1
Unable to delete 'C:\Users\IEUser\Desktop\oc-server\target\tmp\j h6725733765603761727'. Tried 2 time (of a maximum of 2) waiting 0.1 sec between attempts.
so the property does seem to be acting as a retry despite the code comment but you can not set it to zero one because...
static int DELETION_MAX = Math.max(1, SystemProperties.getInteger(Util.class.getName() + ".maxFileDeletionRetries", 3));
and the PathRemover]..
return new PathRemover(new PausingGCRetryStrategy(Math.max(maxRetries, 1), gcAfterFailedRemove, waitBetweenRetries), pathChecker);
which means it will always retry once, which is a PITA when trying to some timing bugs.
jenkins/core/src/main/java/hudson/Util.java
Lines 1581 to 1596 in c8efc7c
The properties is for "retries" which you should be able to disable with a count of zero. but you can not. but the comment implies it is just for the number of tries (not retries).
However the code calls PathRemover.newFilteredRobustRemover(pathChecker, DELETION_MAX - 1, GC_AFTER_FAILED_DELETE, WAIT_BETWEEN_DELETION_RETRIES);]
which ends up in
jenkins/core/src/main/java/jenkins/util/io/PathRemover.java
Lines 63 to 65 in c8efc7c
However if you run a test with the system property set to one. then you do get one retry not one try.
-DargLine=-Dhudson.Util.maxFileDeletionRetries=1
so the property does seem to be acting as a retry despite the code comment but you can not set it to zero one because...
and the PathRemover]..
which means it will always retry once, which is a PITA when trying to some timing bugs.
Originally reported by
teilo, imported from: can not disable the retries of Util.delete
Raw content of original issue