Skip to content

Commit

Permalink
Allow chunk GC mtime tolerance for unfinished part chunks
Browse files Browse the repository at this point in the history
Whenever part chunks are written, every fwrite in the write loop will
reset the mtime to the current mtime. Only at the end will the touch()
operation set the mtime to now + ttl, in the future.

However the GC code is expecting that every chunk with mtime < now are
old and must be deleted. This causes the GC to sometimes delete part
chunks in which the write loop is slow.

To fix this, a tolerance value is added in the GC code to allow for
more time before a part chunk gets deleted.
  • Loading branch information
Vincent Petry committed May 18, 2016
1 parent 8cee246 commit 5bb892b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/private/cache/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public function clear($prefix='') {
public function gc() {
$storage = $this->getStorage();
if($storage and $storage->is_dir('/')) {
$now = time();
// extra hour safety, in case of stray part chunks that take longer to write,
// because touch() is only called after the chunk was finished
$now = time() - 3600;
$dh=$storage->opendir('/');
if(!is_resource($dh)) {
return null;
Expand Down

0 comments on commit 5bb892b

Please sign in to comment.