I used the sorted set of Redis to store some data in RAM. The scores of elements in the sorted set keep updating.
My question is if we may get such a case:
At last, in the snapshot, A appears two times in the same sorted set.
If the Redis snapshot is atomic, I should never see A twice in shapshot.
Yes, it's atomic.
When Redis creates a snapshot, it forks a child process to do the dump work, and parent process does copy-on-write for the data set in memory.
So the case you described should not happen, i.e. you never see A twice in snapshot. Instead, once it creates a child process to dump snapshot, new writes in parent process won't be written to the snapshot.