Redis restore from rdb: all keys are persistent - redis

I have a Redis instance with some persistent keys and a lot of keys that have expired. Then I execute the bgsave command to get an rdb file. As a result the file contains all keys - persistent and not persistent.
When I restart Redis all the non-persistent keys turned into persistent keys.
How can I avoid this?
I want all non-persistent keys stay non-persistent.

Related

Can I prevent Redis from expiring any keys?

I'm importing an old Redis backup in order to browse its databases.
However upon launching Redis with the imported dump.rdb a lot of data is missing.
My guess is because Redis immediately expires all the old keys.
Is there a configuration setting to prevent Redis from expiring anything?
Redis doesn't do that, but you can try setting the server's clock to some time in the distant past before loading the RDB.

Redis persistence on master slave configuration

I have configured two slaves and one master using sentinel.
I have turned off persistence on all the servers. Now the sync happens between master and slave using BGSAVE command.
So shall i assume that though i have persistence off redis is still persisting since it created rdb file for syncing data?
I guess you just have to use replication diskless to avoid Redis using BGSAVE. In fact diskless replication use socket instead of the file to send data on their slaves
https://deepsource.io/blog/redis-diskless-replication/
regard,

Redis Replication: Does slave ever read from snapshot?

I have a redis setup with sentinels and multiple slaves, each slave as well as the master writes persistently to a snapshot file.
When I restart the system, every slave has more keys in their instance than the master has (but less keys than are present in their snapshot file), and I do not understand why?
1) My question, does a slave ever read the snapshot file at startup or it only synch with the master?
2) I never copy my snapshot files, does this lead to overwrite problems?
3) If I have keys with EXPIRATION, are those removed form the snapshot file at the corresponding time?
1) My question, does a slave ever read the snapshot file at startup or it only synch with the master?
When a slave restarts, it loads snapshot(RDB) file from disk if there's no AOF file.
2) I never copy my snapshot files, does this lead to overwrite problems?
It has nothing to do with copying.
3) If I have keys with EXPIRATION, are those removed form the snapshot file at the corresponding time?
When Redis loads the RDB file, if a key has expiration, Redis will add the key value to dict and set expiration for that key. No matter whether the key has already expired (the key will be removed later).
When I restart the system, every slave has more keys in their instance than the master has
The slaves might NOT full sync with the master before they are shutdown, and some keys have been deleted from the master. After re-syncing with the master, those keys will be deleted from slaves.

How can you disable snapshotting on a running Redis for certain DBs?

How to disable Save for some DBs and allow for the others in the Redis
You cannot. An RDB snapshot is a single file that contains the data of all dbs.
You can send a FLUSHDB on the dbs you do not want to restore after the RDB is loaded.
If you'll use a dedicated Redis process for each db you could configure each one differently with a dedicated redis.conf file, and a SAVE and BGSAVE commands will only create a snapshot of the Redis process it was issued on.

flushdb not clear all keys in redis?

It seems there are still some keys left after i ran redis SHELL command flushdb,
what are these keys used for and why flushdb does not work?
When Redis runs flushdb command, it blocks any new writings to the database, and flushes all keys in the database. However, when Redis finishes the flushdb command, it can receive new writings, i.e. other Redis client can put new keys into the database.
In your case, I think there're other clients constantly writing to the database. So after you flush the database, new keys are put into Redis by other clients.
If you want to stop any further writing, you have to shutdown Redis server.