Overview
The error “File has unexpected size. Mirror sync in progress”, often accompanied by a checksum mismatch, is typically caused by stale cached metadata in Artifactory when proxying APT repositories.
Root Cause
This issue occurs when the APT client receives outdated metadata from Artifactory:
- Artifactory serves a cached InRelease file to the APT client.
- The InRelease file specifies an expected size for a metadata file (for example, Components-amd64.yml.gz with an expected size of 10112 bytes).
- Artifactory then retrieves the actual file from the upstream registry.
- If the upstream registry has updated the file since the metadata was cached, the file size may differ (for example, 25192 bytes instead of 10112).
- When the APT client compares the downloaded file against the metadata, it detects a size mismatch.
- Due to the mismatch, APT considers the file untrusted and aborts the download.
Resolution
Clearing the Artifactory cache resolves the issue by forcing retrieval of a fresh InRelease file from the upstream repository. The updated metadata contains the correct file size, allowing the APT client to proceed successfully.
Prevention
To reduce the likelihood of this issue occurring:
- Lower the Metadata Retrieval Cache Period for the APT remote repository.
Reducing this value causes Artifactory to expire cached metadata more frequently, ensuring that APT clients receive up-to-date metadata that matches the current state of the upstream repository.