This topic describes the concepts and internal logic of log archiving.
Log archiving architecture
Log archiving is the process of storing redo logs generated in the database to other media such as S3, so that the complete redo operation history of the database can be retained for a longer period. OceanBase AI Database is a multi-tenant database. You can separately enable log archiving for each tenant. Log archiving operations in different tenants are independent of each other.
In addition, OceanBase AI Database is a native distributed database. Therefore, archiving operations for different log streams within a tenant are also independent of each other. For a single log stream, the log stream leader is responsible for log archiving, and each log is archived only once. During archiving, the RS Leader calculates the archiving progress of the current tenant based on the archiving progress of each log stream.
The following figure shows the log archiving architecture.

Log archiving modes
Two log archiving modes are supported: archive (ARCHIVELOG) and non-archive (NOARCHIVELOG). This mode acts as a switch for the log archiving feature. You can initiate a log archiving job for a tenant only when the tenant is in archive mode.
Archiving status
Log archiving uses a finite-state set to describe the archiving status of the archive destination. The sys tenant can view this status through the STATUS field in the oceanbase.CDB_OB_ARCHIVELOG view, while user tenants can view it through the STATUS field in the oceanbase.DBA_OB_ARCHIVELOG view.
The following table describes the archiving status.
Status |
Description |
|---|---|
| PREPARE | Log archiving is being prepared. This is the initial state for enabling log archiving. |
| BEGINNING | Log archiving is being started. In this state, each log stream is instructed to start archiving. |
| DOING | Log archiving is in progress. In this state, the log checkpoint constantly advances consecutively. In other words, the value of checkpoint_scn increments consecutively. |
| INTERRUPTED | Log archiving is interrupted. The log archiving state machine enters this state when log archiving is interrupted for at least one log stream. |
| SUSPENDING | Log archiving is being suspended. |
| SUSPEND | Log archiving is suspended. |
| STOPPING | Log archiving is being stopped. |
| STOP | Log archiving is stopped. |
Organization of archived logs
Log group
In OceanBase AI Database, each archive log is a collection of log entries and is therefore called a Log Group. Each Log Entry has a system change number (SCN). A Log Group also has an SCN, which is the largest one of the SCNs of all Log Entries. Log archiving is essentially to manage and organize Log Groups in the archive media.
Piece
OceanBase AI Database organizes and manages archive logs by piece. A piece is a complete collection of logs of a tenant within a consecutive period. The range of SCNs of logs in a piece is a left-closed and right-open interval. This implies the following points:
One piece contains the logs within a consecutive period, which can be
1dor another duration such as2d. This period is specified by thepiece_switch_intervalattribute in theLOG_ARCHIVE_DESTparameter.The logs in a piece are complete. The log groups generated by all log streams of the tenant within the period are organized in this piece.
Assume that the piece_switch_interval attribute in the LOG_ARCHIVE_DEST parameter is set to 1d. OceanBase AI Database generates a piece every other day. Except for the last piece in each round of archiving, each piece contains the complete logs of one day. All logs of the day are archived to the piece based on the specified rules. For example, after log archiving is enabled at '2022-06-01 06:00:00.000000', the range of SCNs of logs in the first complete piece generated for the current tenant is ['2022-06-01 06:00:00.000000', '2022-06-02 06:00:00.000000').
Key attributes of a piece
A piece has the following attributes: START_SCN, END_SCN, CHECKPOINT_SCN, STATUS, and FILE_STATUS.
START_SCN
The START_SCN field describes the start SCN of consecutive logs in the piece.
END_SCN
The END_SCN field describes the end SCN of the piece. The value of END_SCN minus the value of START_SCN is equal to the value of the piece_switch_interval attribute.
For example, if the piece_switch_interval attribute in the LOG_ARCHIVE_DEST parameter is set to 1d, and log archiving is enabled at 2022-06-01 06:00:00, then for the first piece generated during this round of archiving, START_SCN is '2022-06-01 06:00:00', and END_SCN is '2022-06-02 06:00:00'. All log groups generated at '2022-06-01 06:00:00' or later but earlier than '2022-06-02 06:00:00' are archived to this piece. For the second piece, START_SCN is '2022-06-02 06:00:00', and END_SCN is '2022-06-03 06:00:00'.
In the same round of archiving, log groups whose SCNs fall within the range of [START_SCN, END_SCN) belong to the same piece, but log entries whose SCNs fall within the range of [START_SCN, END_SCN) do not necessarily belong to the same piece.
For example, if [START_SCN, END_SCN) of Piece 1 is ['2022-06-01 06:00:00', '2022-06-02 06:00:00'), and a Log Group contains two Log Entries whose SCNs are respectively '2022-06-02 05:59:59' (within the range) and '2022-06-02 06:00:01' (outside the range), the SCN of the Log Group is the larger one of the SCNs of the two Log Entries and therefore is '2022-06-02 06:00:01'. Because this value exceeds the END_SCN of Piece 1, all Log Entries in the Log Group belong to the next piece.
CHECKPOINT_SCN
The CHECKPOINT_SCN field describes the largest SCN of consecutive logs in the piece, namely, the largest SCN of all log groups in the piece. All log groups whose SCNs fall within the range of [START_SCN, CHECKPOINT_SCN] have been archived to this piece.
STATUS
The STATUS field describes the status of a piece. The following table describes the possible statuses.
Status |
Description |
|---|---|
| ACTIVE | An active piece, to which the system is archiving logs. |
| FROZEN | A frozen piece. The logs in the piece are complete and no more logs will be archived to it. |
FILE_STATUS
The FILE_STATUS field describes the file status of a piece. The following table describes the possible statuses.
Status |
Description |
|---|---|
| AVAILABLE | The data in the piece is intact and complete, not cleaned or damaged. |
| INCOMPLETE | The data in the piece is incomplete. The data of some log streams is missing. |
| DELETING | The piece has expired and is being cleaned up. |
| DELETED | The piece has been cleaned up. |
| BROKEN | The data in the piece is damaged. |