Fix page cache reclaim test when /tmp is tmpfs (#16067)

### Issue

`test_reclaimFilePageCache` fails when `/tmp` is mounted as tmpfs, as on
Ubuntu 26.04. `POSIX_FADV_DONTNEED` does not evict tmpfs file pages, so
the cache reclaim assertions fail. The daily `test-ubuntu-reclaim-cache`
job has the same problem with RDB files under `/tmp`.

### Change

Use `/var/tmp`, which normally uses a disk filesystem, for the unit test
file and the daily job's master and replica directories. Update the
related pidfile and RDB paths. Keep the existing cache reclaim checks.
This commit is contained in:
Vitah Lin authored and GitHub committed 2026-10-27 19:48:51 +08:00
1 parent 79d3af9350
commit 33c2a2a145
2 files changed
+13 -11

No files matched your search

+10 -10
View File
@@ -500,8 +500,8 @@ jobs:
- name: testprep
run: |
sudo apt-get install vmtouch
mkdir /tmp/master
mkdir /tmp/slave
mkdir /var/tmp/master
mkdir /var/tmp/slave
- name: warm up
run: |
./src/redis-server --daemonize yes --logfile /dev/null
@@ -535,16 +535,16 @@ jobs:
echo "test SAVE doesn't increase cache"
CACHE0=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')
echo "$CACHE0"
./src/redis-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080 --repl-diskless-sync no --pidfile /tmp/master/redis.pid --rdbcompression no --enable-debug-command yes
./src/redis-server --daemonize yes --logfile /dev/null --dir /var/tmp/master --port 8080 --repl-diskless-sync no --pidfile /var/tmp/master/redis.pid --rdbcompression no --enable-debug-command yes
# Runtime TSC calibration can delay startup on x86, while the daemonized
# parent exits before the child listens. Wait before the first command.
wait_for_redis_start 8080
./src/redis-cli -p 8080 debug populate 10000 k 102400
./src/redis-server --daemonize yes --logfile /dev/null --dir /tmp/slave --port 8081 --repl-diskless-load disabled --rdbcompression no
./src/redis-server --daemonize yes --logfile /dev/null --dir /var/tmp/slave --port 8081 --repl-diskless-load disabled --rdbcompression no
wait_for_redis_start 8081
./src/redis-cli -p 8080 save > /dev/null
VMOUT=$(vmtouch -v /tmp/master/dump.rdb)
VMOUT=$(vmtouch -v /var/tmp/master/dump.rdb)
echo $VMOUT
grep -q " 0%" <<< $VMOUT
CACHE=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')
@@ -555,10 +555,10 @@ jobs:
./src/redis-cli -p 8081 REPLICAOF 127.0.0.1 8080 > /dev/null
while [ $(./src/redis-cli -p 8081 info replication | grep "master_link_status:down") ]; do sleep 1; done;
sleep 1 # wait for the completion of cache reclaim bio
VMOUT=$(vmtouch -v /tmp/master/dump.rdb)
VMOUT=$(vmtouch -v /var/tmp/master/dump.rdb)
echo $VMOUT
grep -q " 0%" <<< $VMOUT
VMOUT=$(vmtouch -v /tmp/slave/dump.rdb)
VMOUT=$(vmtouch -v /var/tmp/slave/dump.rdb)
echo $VMOUT
grep -q " 0%" <<< $VMOUT
CACHE=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')
@@ -566,10 +566,10 @@ jobs:
if [ "$(( $CACHE-$CACHE0 ))" -gt "8000000" ]; then exit 1; fi
echo "test reboot doesn't increase cache"
PID=$(cat /tmp/master/redis.pid)
PID=$(cat /var/tmp/master/redis.pid)
kill -15 $PID
while [ -x /proc/${PID} ]; do sleep 1; done
./src/redis-server --daemonize yes --logfile /dev/null --dir /tmp/master --port 8080
./src/redis-server --daemonize yes --logfile /dev/null --dir /var/tmp/master --port 8080
# The daemonized parent can exit before the child listens, so tolerate
# connection failures until INFO is available, then wait for RDB loading.
@@ -586,7 +586,7 @@ jobs:
done
sleep 1 # wait for the completion of cache reclaim bio
VMOUT=$(vmtouch -v /tmp/master/dump.rdb)
VMOUT=$(vmtouch -v /var/tmp/master/dump.rdb)
echo $VMOUT
grep -q " 0%" <<< $VMOUT
CACHE=$(grep -w file /sys/fs/cgroup/memory.stat | awk '{print $2}')
+3 -1
View File
@@ -1826,7 +1826,9 @@ static int cache_exist(int fd) {
}
static void test_reclaimFilePageCache(void) {
char *tmpfile = "/tmp/redis-reclaim-cache-test";
/* Use /var/tmp: /tmp may be tmpfs, where
* POSIX_FADV_DONTNEED does not evict file pages. */
char *tmpfile = "/var/tmp/redis-reclaim-cache-test";
int fd = open(tmpfile, O_RDWR|O_CREAT, 0644);
assert(fd >= 0);