chore: fix bugs in stream_family (#4237)

1. Use transaction time in streams code, similarly to how we do it in other commands.
   Stop using mstime() and delete unused redis code.
2. Check for sequence overflow issue when passing huge sequence ids.
   Add a test.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-12-02 11:57:31 +02:00 committed by GitHub
parent ada96d9041
commit 91aff49fcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 105 additions and 459 deletions

View file

@ -92,34 +92,6 @@ void _serverAssert(const char *estr, const char *file, int line);
#define serverAssert(_e) ((_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),_exit(1)))
typedef long long mstime_t; /* millisecond time type. */
long long ustime(void);
/* Return the current time in minutes, just taking the least significant
* 16 bits. The returned time is suitable to be stored as LDT (last decrement
* time) for the LFU implementation. */
static inline unsigned long LFUGetTimeInMinutesT(size_t sec) {
return (sec / 60) & 65535;
}
static inline unsigned long LFUGetTimeInMinutes() {
return LFUGetTimeInMinutesT(time(NULL));
}
/* Given an object last access time, compute the minimum number of minutes
* that elapsed since the last access. Handle overflow (ldt greater than
* the current 16 bits minutes time) considering the time as wrapping
* exactly once. */
static inline unsigned long LFUTimeElapsed(time_t sec, unsigned long ldt) {
unsigned long now = LFUGetTimeInMinutesT(sec);
if (now >= ldt) return now-ldt;
return 65535-ldt+now;
}
/* Return the UNIX time in milliseconds */
static inline mstime_t mstime(void) {
return ustime()/1000;
}
#endif