feat(disk-cache): use fsync to force flush changes on NFS, and use retry mechanism to archive caches...

This commit is contained in:
RhodeCode Admin 2024-06-10 17:01:42 +02:00
parent 164d313bea
commit 3d0e81968b
2 changed files with 8 additions and 1 deletions

View file

@ -459,7 +459,7 @@ class RepoFilesView(RepoAppView):
response.location = location
return response
reader, metadata = d_cache.fetch(archive_name_key)
reader, metadata = d_cache.fetch(archive_name_key, retry=True, retry_attempts=30)
response = Response(app_iter=archive_iterator(reader))
response.content_disposition = f'attachment; filename={response_archive_name}'

View file

@ -139,6 +139,13 @@ class FileSystemCache:
for chunk in iterator:
size += len(chunk)
writer.write(chunk)
writer.flush()
# Get the file descriptor
fd = writer.fileno()
# Sync the file descriptor to disk, helps with NFS cases...
os.fsync(fd)
log.debug('written new archive cache under %s', full_path)
return size
def _get_keyfile(self, key):