Files
redis/src
Oran Agra b458b2999b Fix LRU blue moon bug in RESTORE, RDB loading, module API (#9279)
The `lru_clock` and `lru` bits in `robj` save the least significant 24 bits of the unixtime (seconds since 1/1/1970),
and wrap around every 194 days.
The `objectSetLRUOrLFU` function, which is used in RESTORE with IDLETIME argument, and also in replica
or master loading an RDB that contains LRU, and by a module API had a bug that's triggered when that happens.

The scenario was that the idle time that came from the user, let's say RESTORE command is about 1000 seconds
(e.g. in the `RESTORE can set LRU` test we have), and the current `lru_clock` just wrapped around and is less than
1000 (i.e. a period of 1000 seconds once in some 6 months), the expression in that function would produce a negative
value and the code (and comment) specified that the best way to solve that is push the idle time backwards into the
past by 3 months. i.e. an idle time of 3 months instead of 1000 seconds.

instead, the right thing to do is to unwrap it, and put it near LRU_CLOCK_MAX. since now `lru_clock` is smaller than
`obj->lru` it will be unwrapped again by `estimateObjectIdleTime`.

bug was introduced by 052e03495f, but the code before it also seemed wrong.
2021-07-29 12:11:29 +03:00
..
2020-04-24 17:11:21 -07:00
2020-10-27 15:04:18 +02:00
2020-05-05 23:35:08 -04:00
2019-11-19 17:23:47 +08:00
2021-07-15 16:01:11 -07:00
2019-10-02 11:30:20 +02:00
2021-07-10 10:04:54 -05:00
2021-04-27 14:25:02 +03:00
2020-07-21 08:13:05 +03:00