当前位置:网站首页>Redis data loss problem
Redis data loss problem
2022-07-23 18:07:00 【Grab】
common Redis Data loss
- DBA/RD Misoperation execution flushall/flushdb Such orders .
- Expired key deleted .
- Elimination strategy delete data .
- Because the client buffer memory is used too much , Cause a large number of keys to be LRU Eliminate .
- Auto restart after main library failure , Possible data loss .
- The problem of network partition , It may cause short-term write data loss .
- Data loss due to asynchronous replication .
- Data loss due to cleft brain .
Because the client buffer memory is used too much , Cause a large number of keys to be LRU Eliminate
The memory size of the client buffer is difficult to limit , The amount of memory they consume will be calculated in used_memory Inside ; If not used properly , This leads to excessive buffer memory usage , achieve maxmemory Limit ;( Caching scenarios ) Will cause a large number of keys to be eliminated , At worst, all keys will be cleaned up , Buffer keyless can be eliminated , Write failure . Equivalent to the entire buffer failure , Great impact on business .
Auto restart after main library failure , Possible data loss .
Point in time T1, The main library is closed due to failure , Because there is a daemon for automatic restart , Point in time T2 The main library is pulled up again , because (T2-T1) The time interval is too small , Not up to Redis The master-slave switching judgment duration of the cluster or sentinel ; In this way, the main database is found from the database runid Changed or disconnected , The main database will be fully synchronized rdb clear , And clean up your own data . To ensure performance ,Redis The main database often does not set data persistence , So at what time T2 Start the main library , It is likely to be an empty instance ( Or a long time ago rdb file ). The time interval between such problems , Generally less than 1 minute , The monitoring alarm may not be perceptible .
The problem of network partition , It may cause short-term write data loss .
This kind of problem occurs, and data loss is rare , Network partition ,Redis The cluster or sentinel is judging the time window of failover , Data written to the original master database during this period ,5 second ~15 Write volume in seconds .
Data loss due to asynchronous replication .
because master->slave Replication of is asynchronous , So maybe some data hasn't been copied to slave,master It's down. , At this point, some of the data is lost .
Data loss due to cleft brain .
Some master The machine is suddenly out of the normal network , With others slave The machine can't be connected , But actually master Still running . At this point the sentry might think master It's down. , Then open the election and the others slave Switch to master. There will be two in the cluster master, It's called cleft brain .
At this time, although some slave It's switched to master, But maybe client There's no time to switch to the new master, Still keep writing to the old master Data may have been lost . So old master When we recover again , Will be treated as a slave Hang on to the new master Up , Your data will be cleared , From the new master Copy the data .
Solution :
By means of redis.conf Configure and control synchronization time to reduce data loss .
# It requires at least 1 individual slave, Data replication and synchronization delays cannot exceed 10 second
min-slaves-to-write 1
# If it's all slave, The latency of data replication and synchronization exceeds 10 Second , that master Will refuse to accept any request
min-slaves-max-lag 10边栏推荐
猜你喜欢

MySQL foundation and performance optimization

TwinCAT 3 first run error 4115

TYPE-C 转OTG(USB2.0传输数据)+PD充电协议芯片 乐得瑞LDR6028/LDR6023SS

leetcode:剑指 Offer II 115. 重建序列【图论思维 + 入度考虑 + 拓扑排序】

(十一)STM32——IO引脚复用与映射

【216】go语言标准库包名

Static distribution and dynamic distribution in trust

MySQL六十六问,两万字+五十图详解含(答案解析)

Do you still have certificates to participate in the open source community?

Trust guessing numbers game
随机推荐
MySQL field modification
一台Linux机器上启动多个redis实例
Qt多线程实例与connect第五个参数[通俗易懂]
Seata
微服务雪崩问题及解决方案
El input usage
Rust中的函数function与方法method的区别
Test and development experience
Keras II classification problem
MySQL执行Alter table xx add column报Duplicate entry错误
topology.yaml中指定端口号
Multithreaded programming
强化学习---马尔可夫决策过程 MP MRP MDP
Microservice avalanche problems and Solutions
CreateFileMapping 函数「建议收藏」
传奇架设 GEE引擎教程 配置微端
Page return update
配置Gom引擎登錄器出現錯誤提示:沒有發現必備補丁文件!
MySQL六十六问,两万字+五十图详解含(答案解析)
Specify the port number in topology.yaml