Redis "LOADING Redis is loading the dataset in memory" in CI
On startup Redis loads its dataset from RDB or AOF and rejects most commands with "LOADING Redis is loading the dataset in memory" until that completes. In CI this appears when a persisted dump is restored before the service is ready.
What this error means
Early commands fail with "LOADING Redis is loading the dataset in memory" and succeed once loading finishes, making the first test flaky.
(error) LOADING Redis is loading the dataset in memory
# python:
redis.exceptions.BusyLoadingError: Redis is loading the dataset in memoryCommon causes
A persisted dataset is being loaded at boot
A mounted dump.rdb or appendonly file makes Redis spend time loading before it answers, and PING may pass while data commands still return LOADING.
Connecting during the load window
The health check passed but the dataset load is not complete, so the first real command hits the LOADING state.
How to fix it
Start with no dataset to load
For ephemeral CI, disable persistence so there is nothing to load at startup.
services:
redis:
image: redis:7
options: --save "" --appendonly no
ports: ['6379:6379']Wait until loading finishes
Poll a data command (not just PING) and retry on the LOADING error before running tests.
until redis-cli -h localhost -p 6379 get __probe__ >/dev/null 2>&1; do
echo "redis still loading dataset..."; sleep 1
doneHow to prevent it
- Avoid mounting a large RDB/AOF into the CI Redis unless tests need it.
- Gate tests on a data command, not only on PING.
- Keep persistence off for throwaway test data.