Tweak mvcc time format so rollovers are not an issue
Former-commit-id: 14d01ec7bd6f20aea1ed51a1056d02d99583c6d2
This commit is contained in:
parent
d6be236697
commit
fd65ef689a
@ -4887,14 +4887,14 @@ uint64_t getMvccTstamp()
|
|||||||
|
|
||||||
void incrementMvccTstamp()
|
void incrementMvccTstamp()
|
||||||
{
|
{
|
||||||
uint64_t msPrev = server.mvcc_tstamp >> 22;
|
uint64_t msPrev = server.mvcc_tstamp >> 20;
|
||||||
if (msPrev >= (uint64_t)server.mstime) // we can be greater if the count overflows
|
if (msPrev >= (uint64_t)server.mstime) // we can be greater if the count overflows
|
||||||
{
|
{
|
||||||
atomicIncr(server.mvcc_tstamp, 1);
|
atomicIncr(server.mvcc_tstamp, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server.mvcc_tstamp = ((uint64_t)server.mstime) << 22;
|
server.mvcc_tstamp = ((uint64_t)server.mstime) << 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1524,6 +1524,10 @@ struct redisServer {
|
|||||||
unsigned char uuid[UUID_BINARY_LEN]; /* This server's UUID - populated on boot */
|
unsigned char uuid[UUID_BINARY_LEN]; /* This server's UUID - populated on boot */
|
||||||
|
|
||||||
struct fastlock flock;
|
struct fastlock flock;
|
||||||
|
|
||||||
|
// Format:
|
||||||
|
// Lower 20 bits: a counter incrementing for each command executed in the same millisecond
|
||||||
|
// Upper 44 bits: mstime (least significant 44-bits) enough for ~500 years before rollover from date of addition
|
||||||
uint64_t mvcc_tstamp;
|
uint64_t mvcc_tstamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user