This topic describes basic concepts about replicas and the replica types supported by OceanBase Database.
Basic information about replicas
To understand what a replica is, read the following points:
Log: in this topic, log refers to the Clog related to transactions.
MemTable: data modified by a read or write operation and stored in the memory.
SSTable: the baseline data stored on the disk. When a transaction reads or modifies data, the data is temporarily stored in the MemTable. In a major compaction, data in the MemTable is compacted with data in the SSTable to form a new SSTable.
OceanBase Database manages data in the granularity of partitions. To ensure data security and provide high-availability data services, OceanBase Database stores multiple copies of the partition data at different locations. Each copy of the partition data is referred to as a replica. Each replica may contain three major types of data: static data stored in the SSTable on the disk, incremental data stored in the MemTable in the memory, and logs that record transactions. OceanBase provides several types of replicas that contain different data categories to offer more choices in terms of data security, performance, elasticity, availability, and costs.
Replica type
OceanBase Database supports the following types of replicas:
Full-featured replica
A general-purpose replica that has a full set of data types and features, including transaction logs, a MemTable, and an SSTable. A full-featured replica can switch to the leader role efficiently to provide services.
Log replica
A replica that contains only logs. It has no MemTable or SSTable. It provides log services for external applications and participates in log voting. It can facilitate the recovery of other replicas, but it cannot be switched to the leader role to provide database services.
Encrypted voting replica
A replica that contains only encrypted logs. It has no MemTable or SSTable. It provides log services for external applications and participates in log voting. It can facilitate the recovery of other replicas, but it cannot be switched to the leader role to provide database services.
The encrypted voting replicas can be deployed only on encrypted zones. For more information about encrypted zones, see Add or delete an encrypted zone.
Read-only replica
Contains full logs, a MemTable, and an SSTable. Its logging feature is special. It does not participate in elections as a Paxos group member. Instead, it tracks in real time the logs of Paxos group members and locally plays back the logs. If an application does not require high consistency in data reading, this type of replicas can provide read-only services. They are not part of the Paxos group. Therefore, they do not increase the latency of transaction commit because the voting membership is not expanded.
The following table describes the features of these replicas.
| Feature | Full-featured replica | Log replica | Encrypted voting replica | Read-only replica |
|---|---|---|---|---|
| LOG | It has logs and participates in voting (SYNC_CLOG). | It has logs and participates in voting (SYNC_CLOG). | It has logs and participates in voting (SYNC_CLOG). | It has logs. However, it is only a listener (ASYNC_CLOG) instead of a member of the Paxos group. |
| MemTables | It has MemTables (WITH_MEMSTORE). | It has no MemTable (WITHOUT_MEMSTORE). | It has no MemTable (WITHOUT_MEMSTORE). | It has MemTables (WITH_MEMSTORE). |
| SSTable | It has SSTables (WITH_SSSTORE). | It has no SSTable (WITHOUT_SSSTORE). | It has no SSTable (WITHOUT_SSSTORE). | It has SSTables (WITH_SSSTORE). |
| Data Security | High | Low | High | Medium |
| Time to become the leader | Short | Not supported | Not supported | Not supported |
| Resource cost | High | Low | Low | High |
| Service | Provides data read and write services as the leader and non-consistent read services as a follower. | Not readable or writable. | Not readable or writable. | Non-consistent read service |
| Name (abbreviation) | FULL (F) | LOGONLY (L) | EncryptVote (E) | READONLY (R) |
| Replica type value | 0 | 5 | 261 | 16 |
Note
The value of
replica_typeis the ID of a replica type. Different types of replicas are identified based on this ID in the internal code. If the value ofreplica_typeis a varchar, the name of the replica type is returned. If the value is an int, the value of the replica type is returned.