Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c41183e4
Commit
c41183e4
authored
Feb 28, 2023
by
Vitaly Arbuzov
Browse files
Fix RANDOMKEY bug
parent
f3e96854
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
c41183e4
...
...
@@ -363,19 +363,19 @@ void setKey(client *c, redisDb *db, robj *key, robj *val, int flags) {
robj *dbRandomKey(redisDb *db) {
dictEntry *de;
int maxtries = 100;
dict
*
randomDict
=
getRandomDict
(
db
);
int allvolatile = dbSize(db) == dictSize(db->expires
);
while(1) {
sds key;
robj *keyobj;
dict *randomDict = getRandomDict(db);
de = dictGetFairRandomKey(randomDict);
if (de == NULL) return NULL; // TODO consider other non-empty slot buckets.
key = dictGetKey(de);
keyobj = createStringObject(key,sdslen(key));
if (dictFind(db->expires,key)) {
if
(
server
.
masterhost
&&
--
maxtries
==
0
)
{
if (
allvolatile &&
server.masterhost && --maxtries == 0) {
/* If the DB is composed only of keys with an expire set,
* it could happen that all the keys are already logically
* expired in the slave, so the function cannot stop because
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment