OceanBase Database enables Global Timestamp Service (GTS) for each tenant. When OceanBase Database commits transactions, OceanBase Database uses GTS of each tenant to retrieve the transaction versions to ensure that transactions are committed based on the order of their versions.
GTS is the core of a cluster and must be highly available.
- For tenants, OceanBase Database takes the leader of the tenant-level internal table __all_dummy as the GTS provider. Timestamps come from the local clock of the leader. GTS contains three replicas by default, and its high availability (HA) level is the same as that of standard tables. GTS ensures a recovery time objective (RTO) of less than 30s in the event of single point of failure (SPOF).
GTS is globally incremental. This ensures that timestamps remain accurate even if exceptions occur.
Re-election with a leader
The original leader proactively initiates the re-election process. This is called a re-election with a leader. Before a new leader takes effect, it retrieves the latest authorized timestamp of the old leader and uses the timestamp as the baseline for timestamp authorization. Therefore, in this scenario, the timestamp provided by GTS does not roll back.
Election without a leader
The original leader is isolated from most followers. After the lease expires, original followers will re-elect the leader. This is called an election without a leader. In the scenario of an election without a leader, the lease of the new leader is different from that of the original leader. Therefore, the local clock value is greater than the latest timestamp provided by the original leader. The new leader can ensure that the timestamp provided by GTS does not roll back.
In OceanBase Database V3.x or earlier, the timestamps generated by GTS are not persisted. Timestamp correctness is ensured on the basis that the point in time when the system is recovered from downtime is later than the latest possible point in time when clock hopping happens. Later OceanBase Database versions will persist the timestamps generated by GTS to eliminate the dependency on clock hopping.