docs/en/sql-reference/sql-statements/cluster-management/tablet_replica/ADMIN_REPAIR.md
Attempts to repair the specified table or partitions.
For native tables in shared-nothing clusters, this statement attempts to prioritize scheduling the replica repairing operation.
For cloud-native tables in shared-data clusters, it attempts to rollback to a historical available version when metadata or data files are lost. Please note that this may result in the loss of the latest data for some tablets.
:::tip
This operation requires the SYSTEM-level OPERATE privilege. You can follow the instructions in GRANT to grant this privilege.
:::
ADMIN REPAIR TABLE table_name [PARTITION (p1,...)] [PROPERTIES ("key" = "value", ...)]
Note:
PROPERTIES in the statement. Currently, only cloud-native tables in shared-data clusters support PROPERTIES.PROPERTIES
enforce_consistent_version: Whether to enforce all tablets in a partition to roll back to a consistent version. Default: true. If this item is set to true, the system will search for a consistent version in the history that is valid for all tablets to perform the rollback, ensuring data version alignment across the partition. If it is set to false, each tablet in the partition is allowed to rollback to its latest available valid version. The versions of different tablets may be inconsistent, but this maximizes data preservation.allow_empty_tablet_recovery: Whether to allow recovery by creating empty tablets. Default: false. This item takes effect only when enforce_consistent_version is false. If this item is set to true, when metadata is missing for all versions of some tablets but valid metadata exists for at least one tablet, the system attempts to create empty tablets to fill the missing versions. If metadata for all versions of all tablets is lost, recovery is impossible.dry_run: Whether to return the repair plan without actually executing the repair. Default: false. If set to true, the system evaluates the recoverability of each partition and returns the repair plan without performing any actual metadata rollback. The result set contains the following columns:
PartitionId: Partition ID.VisibleVersion: Current visible version.RepairStatus: Repair status. Valid values: NORMAL (all tablets are healthy, no repair needed), RECOVERABLE (missing metadata or data files but recoverable), UNRECOVERABLE (missing metadata or data files and unrecoverable), UNKNOWN (an exception occurred during probing).TabletRecoverInfo: JSON array listing the version each tablet will roll back to. Only populated when status is RECOVERABLE.ErrorMsg: Error message. Only populated when status is UNRECOVERABLE or UNKNOWN.Attempt to repair specified tables
ADMIN REPAIR TABLE tbl1;
Attempt to fix specified partition
ADMIN REPAIR TABLE tbl1 PARTITION (p1, p2);
Attempt to repair a shared-data table, allowing inconsistent versions and creating empty tablets for recovery
ADMIN REPAIR TABLE cloud_tbl PROPERTIES (
"enforce_consistent_version" = "false",
"allow_empty_tablet_recovery" = "true"
);
Preview the repair plan for a shared-data table without executing it
ADMIN REPAIR TABLE cloud_tbl PARTITION (p1) PROPERTIES ("dry_run" = "true");