diff --git a/src/storage/backup/ob_backup_utils.cpp b/src/storage/backup/ob_backup_utils.cpp index 2ec4589bcb..68b3c8828f 100644 --- a/src/storage/backup/ob_backup_utils.cpp +++ b/src/storage/backup/ob_backup_utils.cpp @@ -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 &sstable_array) { int ret = OB_SUCCESS; diff --git a/src/storage/backup/ob_backup_utils.h b/src/storage/backup/ob_backup_utils.h index 010de1971e..0e61d047b1 100644 --- a/src/storage/backup/ob_backup_utils.h +++ b/src/storage/backup/ob_backup_utils.h @@ -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 &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, diff --git a/src/storage/compaction/ob_partition_merge_policy.cpp b/src/storage/compaction/ob_partition_merge_policy.cpp index 34b1f89b76..0433b29c23 100644 --- a/src/storage/compaction/ob_partition_merge_policy.cpp +++ b/src/storage/compaction/ob_partition_merge_policy.cpp @@ -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_); diff --git a/src/storage/high_availability/ob_storage_ha_reader.cpp b/src/storage/high_availability/ob_storage_ha_reader.cpp index 5280710820..88e54c760d 100644 --- a/src/storage/high_availability/ob_storage_ha_reader.cpp +++ b/src/storage/high_availability/ob_storage_ha_reader.cpp @@ -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; diff --git a/src/storage/high_availability/ob_storage_ha_reader.h b/src/storage/high_availability/ob_storage_ha_reader.h index 55d4330665..c3ebc4e5f8 100644 --- a/src/storage/high_availability/ob_storage_ha_reader.h +++ b/src/storage/high_availability/ob_storage_ha_reader.h @@ -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); diff --git a/src/storage/high_availability/ob_tablet_group_restore.cpp b/src/storage/high_availability/ob_tablet_group_restore.cpp index b99cf373c6..03c0c83229 100644 --- a/src/storage/high_availability/ob_tablet_group_restore.cpp +++ b/src/storage/high_availability/ob_tablet_group_restore.cpp @@ -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; diff --git a/src/storage/high_availability/ob_tablet_group_restore.h b/src/storage/high_availability/ob_tablet_group_restore.h index 34bdab0c98..58928f1a68 100644 --- a/src/storage/high_availability/ob_tablet_group_restore.h +++ b/src/storage/high_availability/ob_tablet_group_restore.h @@ -457,6 +457,7 @@ public: private: int update_data_status_(); int update_restore_status_(); + int check_tablet_valid_(); int record_server_event_(); private: diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index ed6656d83c..e749c92f6d 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -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 diff --git a/src/storage/tablet/ob_tablet.h b/src/storage/tablet/ob_tablet.h index eea59361c0..67d6e87f93 100644 --- a/src/storage/tablet/ob_tablet.h +++ b/src/storage/tablet/ob_tablet.h @@ -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: