-
Notifications
You must be signed in to change notification settings - Fork 225
Timestamps
TiKV uses timestamps to determine the order in which transactions are run. All timestamps are assigned from PD. Normally, each transaction needs to be bound to 2 timestamps, called StartTS and CommitTS.
The timestamp is a 64-bit unsigned integer, which is devided into a physical part and a login part. The physical part occupies the high 18 bits and takes to unix ephoch with millisecond precision, while the logical part is a counter starting from 0.
oracle
package provides some tool functions for generating timestamps or parsing timestamps. For example, you can use these functions to infer the physical time of a transaction, or to construct a new timestamp using the physical time as GC safetime.
Example:
physical := oracle.ExtarctPhysical(ts)
logical := oracle.ExtractLogical(ts)
t := oracle.GetTimeFromTS(ts)
ts := oracle.GoTimeToTS(time.Now()-24*time.Hour)
Feel free to help improving! Minor changes are warmly welcomed. Just simply click edit!
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Contents
- Client-Go Wiki
- Compatibility
- API V2
- Transactional API
- RawKV API
- Configurations
- Utilities