提交 11e7b073 编写于 作者: O oceanoverflow 提交者: ob-robot

add defend for backup to check against medium info

上级 e0293389
......@@ -107,6 +107,11 @@ int ObBackupUtils::get_sstables_by_data_type(const storage::ObTabletHandle &tabl
ret = OB_ERR_UNEXPECTED;
LOG_WARN("last major sstable should not be null", K(ret), K(tablet_handle));
}
} else if (tablet_handle.get_obj()->get_medium_compaction_info_list().get_last_compaction_scn() > 0
&& tablet_handle.get_obj()->get_medium_compaction_info_list().get_last_compaction_scn() != last_major_sstable_ptr->get_snapshot_version()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("medium list is invalid for last major sstable", K(ret), "medium_list", tablet_handle.get_obj()->get_medium_compaction_info_list(),
KPC(last_major_sstable_ptr), K(tablet_handle));
} else if (OB_FAIL(sstable_array.push_back(last_major_sstable_ptr))) {
LOG_WARN("failed to push back", K(ret), KPC(last_major_sstable_ptr));
}
......@@ -1864,7 +1869,7 @@ int ObBackupTabletProvider::hold_tablet_handle_(
}
int ObBackupTabletProvider::fetch_tablet_sstable_array_(const common::ObTabletID &tablet_id,
storage::ObTabletHandle &tablet_handle, const share::ObBackupDataType &backup_data_type,
const storage::ObTabletHandle &tablet_handle, const share::ObBackupDataType &backup_data_type,
common::ObIArray<storage::ObITable *> &sstable_array)
{
int ret = OB_SUCCESS;
......
......@@ -275,7 +275,7 @@ private:
const common::ObTabletID &tablet_id, share::ObBackupSkippedType &skipped_type);
int report_tablet_skipped_(const common::ObTabletID &tablet_id, const share::ObBackupSkippedType &skipped_type);
int hold_tablet_handle_(const common::ObTabletID &tablet_id, storage::ObTabletHandle &tablet_handle);
int fetch_tablet_sstable_array_(const common::ObTabletID &tablet_id, storage::ObTabletHandle &tablet_handle,
int fetch_tablet_sstable_array_(const common::ObTabletID &tablet_id, const storage::ObTabletHandle &tablet_handle,
const share::ObBackupDataType &backup_data_type, common::ObIArray<storage::ObITable *> &sstable_array);
int prepare_tablet_logic_id_reader_(const common::ObTabletID &tablet_id, const storage::ObTabletHandle &tablet_handle,
const storage::ObITable::TableKey &table_key, const blocksstable::ObSSTable &sstable,
......
......@@ -1344,7 +1344,7 @@ int ObAdaptiveMergePolicy::find_meta_major_tables(
}
#ifdef ERRSIM
if (OB_NO_NEED_MERGE = ret) {
if (OB_NO_NEED_MERGE == ret) {
ret = OB_E(EventTable::EN_SCHEDULE_MEDIUM_COMPACTION) ret;
if (OB_FAIL(ret) && tablet.get_tablet_meta().tablet_id_.id() > ObTabletID::MIN_USER_TABLET_ID) {
FLOG_INFO("set schedule medium with errsim", "tablet_id", tablet.get_tablet_meta().tablet_id_);
......
......@@ -1420,13 +1420,13 @@ int ObCopySSTableInfoRestoreReader::get_tablet_meta_(
LOG_WARN("tablet should not be NULL", K(ret), KP(tablet), K(tablet_id));
} else if (OB_FAIL(tablet->build_migration_tablet_param(tablet_meta))) {
LOG_WARN("failed to build migration tablet param", K(ret), K(tablet_id));
} else if (OB_FAIL(may_update_tablet_meta_(tablet_id, tablet_handle, tablet_meta))) {
} else if (OB_FAIL(update_tablet_meta_if_restore_major_(tablet_id, tablet_handle, tablet_meta))) {
LOG_WARN("may update tablet meta failed", K(ret), K(tablet_id));
}
return ret;
}
int ObCopySSTableInfoRestoreReader::may_update_tablet_meta_(
int ObCopySSTableInfoRestoreReader::update_tablet_meta_if_restore_major_(
const common::ObTabletID &tablet_id,
ObTabletHandle &tablet_handle,
ObMigrationTabletParam &tablet_meta)
......@@ -1437,14 +1437,8 @@ int ObCopySSTableInfoRestoreReader::may_update_tablet_meta_(
backup::ObBackupTabletMeta backup_tablet_meta;
if (OB_FAIL(get_backup_major_tablet_meta_(tablet_id, backup_tablet_meta))) {
LOG_WARN("failed to get major tablet storage schema", K(ret), K(tablet_id));
} else if (OB_FAIL(compare_storage_schema_(tablet_id, tablet_handle, backup_tablet_meta, need_update_storage_schema))) {
LOG_WARN("failed to compare storage schema", K(ret), K(tablet_id));
} else if (need_update_storage_schema) {
tablet_meta.storage_schema_.reset();
if (OB_FAIL(tablet_meta.storage_schema_.init(tablet_meta.allocator_,
backup_tablet_meta.tablet_meta_.storage_schema_))) {
LOG_WARN("failed to init storage schema", K(ret), K(tablet_meta), K(backup_tablet_meta));
}
} else if (OB_FAIL(tablet_meta.assign(backup_tablet_meta.tablet_meta_))) {
LOG_WARN("failed to assign tablet meta", K(ret), K(backup_tablet_meta));
}
}
return ret;
......
......@@ -363,7 +363,7 @@ private:
int get_tablet_meta_(
const common::ObTabletID &tablet_id,
ObMigrationTabletParam &tablet_meta);
int may_update_tablet_meta_(
int update_tablet_meta_if_restore_major_(
const common::ObTabletID &tablet_id,
ObTabletHandle &tablet_handle,
ObMigrationTabletParam &tablet_meta);
......
......@@ -2714,6 +2714,8 @@ int ObTabletFinishRestoreTask::process()
LOG_WARN("failed to update data status", K(ret), KPC(tablet_restore_ctx_));
} else if (OB_FAIL(update_restore_status_())) {
LOG_WARN("failed to update restore status", K(ret), KPC(tablet_restore_ctx_));
} else if (OB_FAIL(check_tablet_valid_())) {
LOG_WARN("failed to check tablet valid", K(ret), KPC(tablet_restore_ctx_));
}
if (OB_SUCCESS != (tmp_ret = record_server_event_())) {
......@@ -2795,6 +2797,26 @@ int ObTabletFinishRestoreTask::update_restore_status_()
return ret;
}
int ObTabletFinishRestoreTask::check_tablet_valid_()
{
int ret = OB_SUCCESS;
ObTabletHandle tablet_handle;
ObTablet *tablet = nullptr;
const int64_t timeout_us = ObTabletCommon::NO_CHECK_GET_TABLET_TIMEOUT_US;
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("tablet finish restore task do not init", K(ret));
} else if (OB_FAIL(ls_->get_tablet(tablet_restore_ctx_->tablet_id_, tablet_handle, timeout_us))) {
LOG_WARN("failed to get tablet", K(ret), KPC(tablet_restore_ctx_), K(timeout_us));
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("tablet should not be NULL", K(ret), KP(tablet), KPC(tablet_restore_ctx_));
} else if (OB_FAIL(tablet->check_valid())) {
LOG_WARN("failed to check valid", K(ret), KPC(tablet));
}
return ret;
}
int ObTabletFinishRestoreTask::record_server_event_()
{
int ret = OB_SUCCESS;
......
......@@ -457,6 +457,7 @@ public:
private:
int update_data_status_();
int update_restore_status_();
int check_tablet_valid_();
int record_server_event_();
private:
......
......@@ -3369,5 +3369,22 @@ int ObTablet::remove_memtables_from_data_checkpoint()
return ret;
}
int ObTablet::check_valid() const
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K_(is_inited));
} else if (OB_FAIL(check_max_sync_schema_version())) {
LOG_WARN("fialed to check max sync schema version", K(ret), KPC(this));
} else if (OB_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), KPC(this));
} else if (OB_FAIL(check_sstable_column_checksum())) {
LOG_WARN("failed to check sstable column checksum", K(ret), KPC(this));
}
return ret;
}
} // namespace storage
} // namespace oceanbase
......@@ -389,6 +389,9 @@ public:
const ObMigrationTabletParam *tablet_meta);
int clear_memtables_on_table_store(); // be careful to call this func, will destroy memtables array on table_store
int remove_memtables_from_data_checkpoint();
// different from the is_valid() function
// typically used for check valid for migration or restore
int check_valid() const;
TO_STRING_KV(KP(this), K_(wash_score), K_(ref_cnt), K_(tablet_meta), K_(table_store), K_(storage_schema),
K_(medium_info_list));
private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册