OceanBase Database enables Global Timestamp Service (GTS) for each tenant. When OceanBase Database commits transactions, it uses GTS of each tenant to retrieve the transaction versions. This ensures that the transactions are committed in the order of their versions.
High availability of services
GTS is the core of a cluster and must be highly available.
For user tenants, OceanBase Database takes the leader of the __all_dummy internal table at tenant level as the GTS provider. The time is from the local clock of the leader. GTS contains three replicas by default, and the high availability capability is the same as that of standard tables.
For the SYS tenant, OceanBase Database takes the leader of
__all_core_tableas the GTS provider. The high availability capability is the same as that of normal tables.
Assurance of correct timestamps
GTS provides globally incremental timestamps, which ensures the correctness of timestamps if one of the following exceptions occurs:
Re-election with leader
The original leader proactively initiates the re-election. This is called re-election with a leader. Before a new leader takes effect, it retrieves the last authorized timestamp of the old leader and uses the timestamp as the baseline for its timestamp authorization. Therefore, in this scenario, the timestamp provided by GTS does not roll back.
Election without 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 maximum timestamp provided by the original leader. The new leader can ensure that the timestamp provided by GTS does not roll back.
GTS retrieval optimization
Statement snapshot retrieval optimization: Transactions update the Global Committed Version of the located server during their commit. If the query of a statement only points to one server, the statement directly uses the Global Committed Version of the server as the Read Version, to reduce the request pressure on GTS.
Transaction commit version retrieval optimization: Multiple transactions can uniformly obtain the global timestamp. You can send requests to obtain the timestamp in advance to shorten the transaction commit time.