Skip to main content
This topic describes how to recover the metadata in your clusters when FE nodes encounter different exceptions. Generally, you may have to resort to metadata recovery when and only when one of the following issues occurs: Check the issue you encountered, follow the solution provided in the corresponding section, and perform any recommended actions. In the following procedures, <image_dir> means the non-empty image_dir configured in fe.conf, or <meta_dir>/image when image_dir is unset or empty. Replace this placeholder in commands with the resolved path. BDB journals remain under <meta_dir>/bdb, while ROLE, VERSION, and image files, including format subdirectories such as v2, are under <image_dir>. Complete metadata backups and restores must include both locations.

FE fails to restart

FE nodes may fail to restart if the metadata is damaged or incompatible with the cluster after rollback.

Metadata incompatibility after rollback

When you downgrade your cluster, FEs may fail to restart if the metadata is incompatible with that before the downgrade. You can identify this issue if you encounter the following exception while downgrading the cluster:
You can follow these steps to recover the metadata and start FE:
  1. Stop all FE nodes.
  2. Back up the metadata directories meta_dir of all FE nodes. Include each node’s <image_dir> if it is stored outside meta_dir.
  3. Add the configuration metadata_ignore_unknown_operation_type = true to the configuration files fe.conf of all FE nodes.
  4. Start all FE nodes, and check whether your data and metadata are intact.
  5. If both your data and metadata are intact, execute the following statement to create an image file for your metadata:
  6. After the new image file is transmitted to the directory <image_dir> of all FE nodes, you can remove the configuration metadata_ignore_unknown_operation_type= true from all FE configuration files and restart the FE nodes.

Metadata damage

Both damage to BDBJE metadata and the database metadata will cause failures to restart.

BDBJE metadata damage

VLSN Bug
You can identify the VLSN bug based on the following error message:
You can follow these steps to fix this issue:
  1. Clear the metadata directory meta_dir of the FE node that throws this exception. Also clear its <image_dir> if it is stored outside meta_dir.
  2. Restart the FE node using the Leader FE node as the helper.
Tip
  • This bug has been fixed in StarRocks v3.1. You can avoid this issue by upgrading your cluster to v3.1 or later.
  • This solution does not apply if more than half of the FE nodes have encountered this issue. You must follow the instructions provided in Measure of the last resort to fix the issue.
RollbackException
You can identify this issue based on the following error message:
This issue occurs when the Leader FE node writes BDBJE metadata but fails to synchronize it to Follower FE nodes before it hangs. After being restarted, the original Leader becomes a Follower, corrupting the metadata. To solve this issue, you only need to restart this node again to wipe out the dirty metadata.
ReplicaWriteException
You can identify this issue based on the keyword removeReplicaDb from the FE log fe.log.
This issue occurs when the BDBJE version of the failed FE node (v18.3.*) mismatches that of the Leader FE node (v7.3.7). You can follow these steps to fix this issue:
  1. Drop the failed Follower or Observer node.
  2. Add the failed node back to the cluster.
  3. Clear the metadata directory meta_dir of the failed node. Also clear its <image_dir> if it is stored outside meta_dir.
  4. Restart the failed node using the Leader FE node as the helper.
  5. After the failed node recovers to a healthy status, you need to upgrade the BDBJE packages in your cluster to starrocks-bdb-je-18.3.16.jar (or upgrade your cluster to v3.0 or later), following the order of Followers first and then the Leader.
InsufficientLogException
You can identify this issue based on the following error message:
This issue occurs when the Follower node requires full metadata synchronization. It may occur when one of the following situations happens:
  • The metadata on the Follower node lags behind that of the Leader node, which has already done a CheckPoint of metadata within itself. The Follower node cannot perform incremental updates on its metadata, thus full metadata synchronization is required.
  • The original Leader node writes and checkpoints its metadata, but fails to synchronize it to Follower FE nodes before it hangs. After being restarted, it becomes a Follower node. With dirty metadata checkpointed, the Follower node cannot perform incremental deletion of its metadata, thus full metadata synchronization is required.
Please note that this exception will be thrown when a new Follower node is added to the cluster. In this case, you do not need to take any action. If this exception is thrown for an existing Follower node or the Leader node, you only need to restart the node.
HANDSHAKE_ERROR: Error during the handshake between two nodes
You can identify this issue based on the following error message:
This issue occurs when the original Leader node hangs and becomes alive again while the surviving Follower nodes are trying to elect a new Leader node. The Follower nodes will try to establish a new connection with the original Leader node. However, the Leader node will reject the connection request because the old connection still exists. Once the request is rejected, the Follower node will set the environment as invalid and throw this exception. To solve this issue, you can either increase the JVM heap size or use the G1 GC algorithm.
DatabaseNotFoundException
You can identify this issue based on the following error message:
This issue occurs when you add the configuration metadata_failure_recovery = true in the FE configuration file fe.conf. To solve this issue, you need to remove the configuration and restart the node.

The database metadata damage

You can identify the database metadata damage issue based on one of the following error messages:
Or
Warning Before proceeding to recover the metadata by following the solution provided below, you are strongly advised to seek assistance from the technical experts in the StarRocks community, because this solution may lead to data loss. You can follow these steps to fix this issue:
Ignore Error Journal ID (Preferred)
  1. Shut down all FE nodes.
  2. Back up the metadata directories meta_dir of all FE nodes. Include each node’s <image_dir> if it is stored outside meta_dir.
  3. Locate the erroneous journal ID in the logs. xxx in the following log represents the erroneous journal ID.
  4. Add the following configuration to all fe.conf files and start the FE nodes.
  5. If the startup still again, identify the new failed journal ID through Step 3, add it to the fe.conf, and then restart the nodes with the previous configurations unchanged.
  6. If the system still fails to start after the above steps, or if there are too many failed journal IDs, proceed to Recovery Mode.
Recovery Mode
  1. Stop all FE nodes.
  2. Back up the metadata directories meta_dir of all FE nodes. Include each node’s <image_dir> if it is stored outside meta_dir.
  3. Add the configuration metadata_enable_recovery_mode = true to the configuration files fe.conf of all FE nodes. Note that data loading is forbidden in this mode.
  4. Start all FE nodes, and query tables in the cluster to check whether your data is intact. You must wait until metadata recovery is completed if the following error is returned when you query these tables:
    You can execute the following statement from the Leader FE node to view the progress of metadata recovery:
    This statement will show the partitions that failed to be recovered. You can follow the advice returned to recover the partitions. If nothing is returned, it indicates the recovery is successful.
  5. If both your data and metadata are intact, execute the following statement to create an image file for your metadata:
  6. After the new image file is transmitted to the directory <image_dir> of all FE nodes, you can remove the configuration metadata_enable_recovery_mode = true from all FE configuration files and restart the FE nodes.

FE fails to provide services

FE will not provide services when Follower FE nodes fail to perform Leader election. When this issue occurs, you may find the following log record repeating:
A variety of exceptions may cause this issue. You are strongly advised to troubleshoot the issue step by step following the sections below. Applying inappropriate solutions will deteriorate the problem and probably lead to data loss.

1. The majority of Follower nodes are not running

If the majority of the Follower nodes are not running, the FE group will not provide services. Here, ‘majority’ indicates 1 + (Follower node count/2). Please note that the Leader FE node itself is a Follower, but Observer nodes are not Followers.
  • You can identify the role of each FE node from the <image_dir>/ROLE file:
  • You can view the total number of Follower nodes from the BDBJE log:
To solve this issue, you need to start all Follower nodes in the cluster. If they cannot be restarted, please refer to The measure of last resort.

2. Node IP is changed

If the priority_networks of the node is not configured, the FE node will randomly select an available IP address once it is restarted. If the IP address recorded in the BDBJE metadata is different from that used to start the node, the FE will not provide services.
  • You can view the IP address recorded in the BDBJE metadata from the <image_dir>/ROLE file:
    The value 172.26.92.154 before the first underscore is the IP address recorded in the BDBJE metadata.
  • You can view the IP address used to start the node from the FE log:
To solve this issue, you need to set the priority_networks of the node in the FE configuration file fe.conf to the IP address recorded in <image_dir>/ROLE, and restart the node.

3. System clock among nodes is not synchronized

You can identify this issue based on the following error message from fe.out, fe.log or fe/meta//bdb/je.info.0:
You must synchronize the system clock among all nodes.

4. Available disk space is insufficient

After you upgrade the database to v3.0 or later, or upgrade BDBJE to v18 or later, the node may fail to restart when the available space of the disk that stores meta_dir is less than 5 GB. You can view the BDBJE version from the .jar package under the directory fe/lib. To solve this issue, you can scale up the disk, or allocate a dedicated disk with larger capacity for the FE metadata.

5. edit_log_port is changed

If the edit_log_port recorded in the BDBJE metadata is different from that configured in fe.conf, the FE will not provide services. You can view the edit_log_port recorded in the BDBJE metadata from the <image_dir>/ROLE file:
The value 9312 before the second underscore is the edit_log_port recorded in the BDBJE metadata. To solve this issue, you need to set the edit_log_port of the node in the FE configuration file fe.conf to the edit_log_port recorded in <image_dir>/ROLE, and restart the node.

6. JVM heap size is insufficient

You can view the JVM memory usage using the jstat command:
If the percentages shown in field O remain high, it indicates that the JVM heap size is insufficient. To solve this issue, you must increase the JVM heap size.

7. Latch timeout. com.sleepycat.je.log.LogbufferPool_FullLatch

You can identify this issue based on the following error message:
This issue occurs when there is excessive pressure on the local disk of the FE node. To solve this issue, you can allocate a dedicated disk for the FE metadata, or replace the disk with a high-performance one.

8. InsufficientReplicasException

You can identify this issue based on the following error message:
This issue occurs when the Leader FE node or Follower FE nodes use excessive memory resources, leading to Full GC. To solve this issue, you can either increase the JVM heap size or use the G1 GC algorithm.

9. UnknownMasterException

You can identify this issue based on the following error message:
When executing SHOW FRONTENDS, if the Leader FE node cannot be found, there could be several reasons:
  • If it is observed that more than half of the FE nodes are undergoing Full GC, and the duration is notably long.
  • Or if the log contains the keyword java.lang.OutOfMemoryError: Java heap space.
It is because there is insufficient memory. You need to increase the JVM memory allocation.

10. Measure of the last resort

Warning You can try the following solution as the last resort only when none of the preceding solutions works. This solution is designed only for extreme cases, such as:
  • The majority of Follower nodes cannot be restarted.
  • Follower nodes cannot perform Leader election due to bugs of BDBJE.
  • Exceptions other than those mentioned in preceding sections.
Follow these steps to recover the metadata:
  1. Stop all FE nodes.
  2. Back up the metadata directories meta_dir of all FE nodes. Include each node’s <image_dir> if it is stored outside meta_dir.
  3. Run the following commands on all the servers that host the FE nodes to identify the node with the latest metadata.
    Example output:
    The node with the largest lastVLSN value has the latest metadata.
  4. Find the role (Follower or Observer) of the FE node that has the latest metadata from the <image_dir>/ROLE file:
    If multiple nodes have the latest metadata, it is recommended to proceed with a Follower node. If multiple Follower nodes have the latest metadata, you can proceed with any of them.
  5. Perform the corresponding operations based on the role of the FE node you chose in the previous step.
Proceed with Follower Node If a Follower node has the latest metadata, perform the following operations:
  1. Add the following configurations to fe.conf:
  2. Restart the node, and check whether your data and metadata are intact.
  3. Check whether the current FE node is the Leader FE node.
    • If the field Alive is true, this FE node is properly started and added to the cluster.
    • If the field Role is LEADER, this FE node is the Leader FE node.
  4. If the data and metadata are intact, and the role of the node is Leader, you can remove the configuration you added earlier and restart the node.
Proceed with Observer Node If an Observer node has the latest metadata, perform the following operations:
  1. Change the role of the FE node from OBSERVER to FOLLOWER in the <image_dir>/ROLE file.
  2. Add the following configurations to fe.conf:
  3. Restart the node, and check whether your data and metadata are intact.
  4. Check whether the current FE node is the Leader FE node.
    • If the field Alive is true, this FE node is properly started and added to the cluster.
    • If the field Role is LEADER, this FE node is the Leader FE node.
  5. If the data and metadata are intact, and the role of the node is Leader, you can remove the configuration you added earlier. However, do not restart the node.
  6. Add a new Follower node (on a new server) to the cluster.
  7. Start a new FE node on the new server using the temporary Leader FE node as the helper.
  8. Once the new FE node is started successfully, check the status and roles of both FE nodes:
    • If the field Alive is true, this FE node is properly started and added to the cluster.
    • If the field Role is FOLLOWER, this FE node is a Follower FE node.
    • If the field Role is LEADER, this FE node is the Leader FE node.
  9. If the new Follower is successfully running in the cluster, you can then stop all nodes.
  10. Add the following configurations to the fe.conf of the new Follower only:
    • For StarRocks v2.5, v3.0, v3.1.9 and earlier patch versions, and v3.2.4 and earlier patch versions:
    • For StarRocks v3.1.10 and later patch versions, v3.2.5 and later patch versions, and v3.3 and later:
  11. Restart the new Follower node, and check whether your data and metadata are intact.
  12. Check whether the current FE node is the Leader FE node.
    • If the field Alive is true, this FE node is properly started and added to the cluster.
    • If the field Role is LEADER, this FE node is the Leader FE node.
  13. If the data and metadata are intact, and the role of the node is Leader, you can remove the configuration you added earlier and restart the node.
  14. Clear the metadata directories meta_dir of the FE nodes that you want to add back to the cluster. Also clear their <image_dir> directories if they are stored outside meta_dir.
  15. Start new Follower nodes using the new Leader FE node as the helper.
  16. Add the Follower nodes back to the cluster.
After all nodes are added back to the cluster, the metadata is successfully recovered.

Recover metadata on a new FE node with metadata backup

Follow these steps if you want to start a new FE node with the metadata backup:
  1. Copy the backed-up meta_dir and any separately stored <image_dir> to the new FE node. Set meta_dir and image_dir in fe.conf to match the restored locations.
  2. In the configuration file of the FE node, set bdbje_reset_election_group to true.
  3. Start the FE node.
  4. Check whether the current FE node is the Leader FE node.
    If the field Role is LEADER, this FE node is the Leader FE node. Make sure its IP address is the that of the current FE node.
  5. If the data and metadata are intact, and the role of the node is Leader, you must remove the configuration bdbje_reset_election_group and restart the node.
  6. Now you have successfully start a new Leader FE node with the metadata backup. You can add new Follower nodes using the new Leader FE node as the helper.
Tip You must remove the following configuration once the metadata recovery is completed.