Redis 重启后立刻连接,会得到 “LOADING Redis is loading the dataset in memory”。这篇用 Redis 8.10.2 在本机造一个 400 万 key 的数据集:看端口什么时候通、加载要多久、哪些命令加载期间还能用、INFO 里的进度字段靠不靠谱、为什么 PING 型的健康检查会出问题,以及从库全量同步时是什么表现。
DEBUG POPULATE 用时 2.0 s,DBSIZE = 4000000
SAVE 用时 2.4 s,dump.rdb = 141.8 MB
启动后第一次得到的 PING 回复(第 0.02 s):(error) LOADING Redis is loading the dataset in memory
加载完成、PING 开始返回 PONG 的时间:2.99 s(进程启动起)
加载期间每 0.25 s 采样一次 INFO persistence:
t= 0.03s loading=1 loading_loaded_perc=0.74 loading_eta_seconds=1 loaded_bytes=1048573/141775871
t= 0.29s loading=1 loading_loaded_perc=12.20 loading_eta_seconds=1 loaded_bytes=17301487/141775871
t= 0.57s loading=1 loading_loaded_perc=23.30 loading_eta_seconds=3 loaded_bytes=33030139/141775871
t= 0.84s loading=1 loading_loaded_perc=34.02 loading_eta_seconds=1 loaded_bytes=48234491/141775871
t= 1.11s loading=1 loading_loaded_perc=44.38 loading_eta_seconds=1 loaded_bytes=62914540/141775871
t= 1.38s loading=1 loading_loaded_perc=54.73 loading_eta_seconds=1 loaded_bytes=77594611/141775871
t= 1.65s loading=1 loading_loaded_perc=64.72 loading_eta_seconds=1 loaded_bytes=91750395/141775871
t= 1.92s loading=1 loading_loaded_perc=74.33 loading_eta_seconds=0 loaded_bytes=105381871/141775871
t= 2.20s loading=1 loading_loaded_perc=83.57 loading_eta_seconds=0 loaded_bytes=118489083/141775871
t= 2.47s loading=1 loading_loaded_perc=90.60 loading_eta_seconds=0 loaded_bytes=128450557/141775871
t= 2.74s loading=1 loading_loaded_perc=99.85 loading_eta_seconds=0 loaded_bytes=141557759/141775871先监听、后加载;PING 在加载期间返回 LOADING,loading_eta_seconds 开头不准。
> PING (error) LOADING Redis is loading the dataset in memory > GET k:1 (error) LOADING Redis is loading the dataset in memory > SET x 1 (error) LOADING Redis is loading the dataset in memory > DBSIZE (error) LOADING Redis is loading the dataset in memory > KEYS zzz* (error) LOADING Redis is loading the dataset in memory > INFO server "# Server\r\nredis_version:8.10.2\r\nredis_git_sha1:00000000\r\nredis_git_dirty:1\r\nredis_build_id:764b3e4506 > INFO persistence "# Persistence\r\nloading:1\r\nasync_loading:0\r\ncurrent_cow_peak:0\r\ncurrent_cow_size:0\r\ncurrent_cow_size > INFO keyspace "# Keyspace\r\ndb0:keys=133128,expires=0,avg_ttl=0,subexpiry=0\r\n" > CONFIG GET maxmemory 1) "maxmemory" 2) "0" > CLIENT LIST "id=4 addr=127.0.0.1:60224 laddr=127.0.0.1:8200 fd=10 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 mult > PUBLISH ch m (integer) 0 > AUTH x (error) ERR AUTH <password> called without any password configured for the default user. Are you sure your con > ROLE 1) "master" 2) (integer) 0 3) (empty array) (之后加载结束,PING -> "PONG")
INFO、CONFIG GET、PUBLISH 等可用,读写命令被拒;PING 探针会误杀。
repl-diskless-load disabled(默认):replica 上 CONFIG GET repl-diskless-load = disabled,master 的 repl-diskless-sync = yes
同步期间 (loading, async_loading, GET old_only) 的分布(共 42 次采样):
22 次 loading=1 async_loading=0 GET old_only -> (error) LOADING Redis is loading the dataset in memory
19 次 loading=0 async_loading=0 GET old_only -> "stale-value"
1 次 loading=0 async_loading=0 GET old_only -> (nil)
同步结束后 DBSIZE = 4000000
repl-diskless-load swapdb:replica 上 CONFIG GET repl-diskless-load = swapdb,master 的 repl-diskless-sync = yes
同步期间 (loading, async_loading, GET old_only) 的分布(共 17 次采样):
15 次 loading=1 async_loading=0 GET old_only -> (error) LOADING Redis is loading the dataset in memory
1 次 loading=0 async_loading=0 GET old_only -> "stale-value"
1 次 loading=0 async_loading=0 GET old_only -> (nil)
同步结束后 DBSIZE = 4000000同步期间读得到 LOADING,swapdb 在本机没有改变这一点。