Skip to content

Restore before nginx starts; keep rsync partials out of the cache tree - #7

Merged
Robbie1977 merged 2 commits into
mainfrom
fix/rsync-temp-dir-outside-loader-path
Aug 26, 2026
Merged

Restore before nginx starts; keep rsync partials out of the cache tree#7
Robbie1977 merged 2 commits into
mainfrom
fix/rsync-temp-dir-outside-loader-path

Conversation

@Robbie1977

Copy link
Copy Markdown
Contributor

What changed

CACHE_RESTORE_MODE=blocking (new default): the archive is copied into the local cache before nginx starts, so a fresh instance only takes traffic once it is fully warm. Port 80 stays closed meanwhile, so the orchestrator's health check must allow for the restore time (Rancher: raise the service's initializing timeout, or rely on the load balancer's check). CACHE_RESTORE_MODE=background keeps the 2.0.0 behaviour for single-instance deployments.

rsync now writes its partial files to <cache root>/.rsync-tmp rather than beside the target, and the backup does the same on the archive. A restore batch that reports errors is retried once at the end, and the result is reported in /status.

Why

In 2.0.0 nginx's cache loader, which walks the cache tree once at startup, found rsync's in-progress .<hash>.XXXXXX partials during a concurrent restore, judged them "too small" and deleted them from under rsync ([crit] cache file "..." is too small followed by rsync stat/rename errors). Those entries then never landed and were not retried. Blocking mode removes the race by construction; the temp-dir change fixes it for background mode and for any cache-restore.sh --force run against a live nginx.

How to test

sh test/cache-sync-test.sh (49 checks, adds partial-location assertions); CI startup test now exercises the blocking path end to end. On a deployed 2.0.0 the symptom is the [crit] … is too small line in the container log during restore.

Follow-ups

The Rancher service health check's initializing timeout needs raising before the archive is large.

… batches

nginx's cache loader walks the cache directory once at startup. With the
restore running concurrently it found rsync's in-progress partial files
(.<hash>.XXXXXX), judged them too small to be cache entries and deleted
them, so rsync's rename failed and those entries never landed (seen in
2.0.0 as '[crit] cache file ... is too small' followed by rsync stat and
rename errors). rsync now writes partials to <cache root>/.rsync-tmp,
outside the loader's path but on the same filesystem, and the backup does
the same on the archive. A restore batch that reports errors is retried
once at the end and the outcome is reported in /status.
With a redundant instance covering, a fresh container should only take
traffic once its cache is fully warm. CACHE_RESTORE_MODE=blocking (new
default) runs cache-restore.sh to completion before exec nginx; port 80
stays closed meanwhile, so the orchestrator's health-check grace must
cover the restore time. CACHE_RESTORE_MODE=background keeps the 2.0.0
behaviour for single-instance deployments.
@Robbie1977
Robbie1977 merged commit 97bc17e into main Aug 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant