首批通过分布式安全可靠测评,为关键业务系统打造
索引状态为 unable/error 的数据表,备份后恢复时失败
更新时间:2025-06-23 08:32
问题描述
OceanBase 数据库 V2.2.77 版本的 OceanBase 集群,租户恢复报错 -4016 异常,物理恢复失败。
日志报错信息如下。
WARN [RESTORE_ARCHIVE] locate_piece_ (ob_archive_restore_engine.cpp:1579) [xxxxx][xxxxx][xxxxx-xxxxx] [lt=19] [dc=0] archive_key_content is corrupted(ret=-4016, restore_pg_key={tid:xxxxxx, partition_id:0, part_cnt:0}, archive_pg_key={tid:xxxxx, partition_id:0, part_cnt:0}, start_log_id=1, archive_key_content={magic_:16715, version_:1, reserved_:0, is_first_piece_:0, max_index_file_id_:0, index_info_:{magic_:16713, record_len_:144, version_:1, is_effective_:1, data_file_id_:1, input_bytes_:0, output_bytes_:0, clog_epoch_id_:1668677094016903, accum_checksum_:625740463, min_log_id_:5237, min_log_ts_:1671960511471988, max_log_id_:5284, max_checkpoint_ts_:1672046092753813, max_log_submit_ts_:1672046092927589, round_start_ts_:1, round_start_log_id_:1, round_snapshot_version_:0, round_log_submit_ts_:1662522306527971, round_clog_epoch_id_:1, round_accum_checksum_:0, checksum_:1395460110}, checksum_:3605077853}, idx=0, total_piece_cnt=2, start_piece_idx=-1, end_piece_idx=-1)
WARN [RESTORE_ARCHIVE] locate_log (ob_archive_restore_engine.cpp:1363) [xxxxx][xxxxx][xxxxx-xxxxx] [lt=29] [dc=0] failed to locate_piece(ret=-4016, archive_pg_key={tid:xxxxx, partition_id:0, part_cnt:0}, archive_pg_key={tid:xxxxx, partition_id:0, part_cnt:0}, start_log_id=1)
OceanBase 数据库 V3.x 版本 OceanBase 集群,跨集群恢复租户物理恢复拉取归档日志报错 -4016,期望从 log_id=1 开始拉,而归档的起始 log_id 已经是 3791。
日志报错信息如下。
WARN [PHYSICAL_RESTORE_ARCHIVE] locate_piece_ (ob_archive_restore_engine.cpp:1504) [xxxxx][xxxxx][xxxxx-xxxxx] [lt=19] [dc=0] archive_key_content is corrupted(ret=-4016, restore_pg_key={tid:xxxxxx, partition_id:0, part_cnt:0}, archive_pg_key={tid:xxxxx, partition_id:0, part_cnt:0}, start_log_id=1, archive_key_content={magic_:16715, version_:1, reserved_:0, is_first_piece_:0, max_index_file_id_:0, index_info_:{magic_:16713, record_len_:144, version_:1, is_effective_:1, data_file_id_:2, input_bytes_:0, output_bytes_:0, clog_epoch_id_:1676823418224047, accum_checksum_:2415648818, min_log_id_:3957, min_log_ts_:1676822651079418, max_log_id_:4002, max_checkpoint_ts_:1676465021564472, max_log_submit_ts_:1676907440618869, round_start_ts_:1676465021564472, round_start_log_id_:3791, round_snapshot_version_:1676467842000317, round_log_submit_ts_:1676465021564472, round_clog_epoch_id_:1672734743435039, round_accum_checksum_:2268327802, checksum_:3712916946}, checksum_:1366003194}, idx=0, total_piece_cnt=1, start_piece_idx=-1, end_piece_idx=-1)
WARN [PHYSICAL_RESTORE_ARCHIVE] locate_log (ob_archive_restore_engine.cpp:1281) [xxxxx][xxxxx][xxxxx-xxxxx] [lt=29] [dc=0] failed to locate_piece(ret=-4016, archive_pg_key={tid:xxxxx, partition_id:0, part_cnt:0}, archive_pg_key={tid:xxxxx, partition_id:0, part_cnt:0}, start_log_id=1)
恢复的表在备份集群是一个 unable 的全局索引,索引状态为 7 (unable)。
obclient > SELECT * FROM oceanbase.__all_virtual_table WHERE table_id= xxxxxxxxx\G;
截取关键输出内容如下。
************** 1. row *************
block_size : xxxxx
collation_type: xx
data_table_id: xxxxxxxxxx
index_status: 7
tablegroup_id: x
progressive_merge_num: x
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。
问题原因
OceanBase 数据库 V3.x 及之前的版本未考虑这种索引状态为 unable 及 error 的索引的备份及恢复。该环境的表现是发起了分区恢复,但是没有基线,恢复状态推进到拉归档日志后,需要从 log_id=1 开始拉,但是给出的 piece 列表里的 Clog 是从 5000+ 开始的,不连续。
解决方法
OceanBase 数据库 V2.2.x 及之前版本的解决方法
升级至问题已修复版本。目前已修复的版本包括 OceanBase 数据库 V2.2.77 BP17 (oceanbase-2.2.77-117000112023051914) 及之后的版本。
在备份集群删掉 unable 和 error 的索引,之后重建这些索引。再进行每日合并和基线备份。
OceanBase 数据库 V3.x 版本的解决方法
升级至问题已修复版本。目前已修复的版本包括 OceanBase 数据库 V3.1.2 BP11 Hotfix (oceanbase-3.1.2-111010012023081616) 及其之后的版本、V3.2.3 BP5 (oceanbase-3.2.3.2-105000062022090916) 及其之后的版本、V3.2.4 BP4 Hotfix (oceanbase-3.2.4.4-104050012023073116) 版本。
在备份集群删掉 unable 和 error 的索引,之后重建这些索引。再进行每日合并和基线备份。