• Binbin's avatar
    Fix DB iterator not resetting pauserehash causing dict being unable to rehash (#12757) · fe363063
    Binbin authored
    When using DB iterator, it will use dictInitSafeIterator to init a old safe
    dict iterator. When dbIteratorNext is used, it will jump to the next slot db
    dict when we are done a dict. During this process, we do not have any calls to
    dictResumeRehashing, which causes the dict's pauserehash to always be > 0.
    
    And at last, it will be returned directly in dictRehashMilliseconds, which causes
    us to have slot dict in a state where rehash cannot be completed.
    
    In the "expire scan should skip dictionaries with lot's of empty buckets" test,
    adding a `keys *` can reproduce the problem stably. `keys *` will call dbIteratorNext
    to trigger a traversal of all slot dicts.
    
    Added dbReleaseIterator and dbIteratorInitNextSafeIterator methods to call dictResetIterator.
    Issue was introduced in #11695.
    fe363063
db.c 111 KB