Skip to content

Commit

Permalink
pool: retry allocation on OutOfDiskException from Allocator
Browse files Browse the repository at this point in the history
Motivation:

To reduce the number of calls to the Allocator, the
AllocatorAwareRespitoryChannel ensures a minimum allocation size.
Towards the end of the file's upload, this results in over-allocation of
capacity.  If the file size is close to the available size then the
over-allocation can lead to the upload failing, even though sufficient
space is available to accept the file.

Modification:

If the allocation fails with OutOfDiskException then retry the
allocation without the minimum allocation.

Result:

Files are accepted that would otherwise fail.

Target: master
Require-notes: no
Require-book: no
Patch: https://rb.dcache.org/r/11090/
Acked-by: Albert Rossi
  • Loading branch information
paulmillar committed Aug 15, 2018
1 parent 41dcc64 commit c93949d
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -189,10 +189,7 @@ private void preallocate(long pos) throws IOException {
checkArgument(pos >= 0);

if (pos > allocated) {
long delta = Math.max(pos - allocated, SPACE_INC);
LOGGER.trace("preallocate: {}", delta);
allocator.allocate(delta);
allocated += delta;
allocated += allocate(pos - allocated);
}
} catch (InterruptedException e) {
throw new InterruptedIOException(e.getMessage());
Expand All @@ -201,4 +198,18 @@ private void preallocate(long pos) throws IOException {
}
}
}

private long allocate(long minRequired) throws InterruptedException, OutOfDiskException
{
long delta = Math.max(minRequired, SPACE_INC);
try {
allocator.allocate(delta);
} catch (OutOfDiskException e) {
// Try again, but this time with the minimum required.
delta = minRequired;
allocator.allocate(delta);
}
LOGGER.trace("preallocate: {}", delta);
return delta;
}
}

0 comments on commit c93949d

Please sign in to comment.