From ab27c671cbbd9259f166f5292174d719b397ffad Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 28 Oct 2022 07:09:52 +0000 Subject: [PATCH] Fix copy after start scn all sstable checker bug --- .../high_availability/ob_storage_ha_dag.cpp | 25 +--------- .../ob_storage_ha_reader.cpp | 48 +++++++++++++++++++ .../high_availability/ob_storage_ha_reader.h | 2 + 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/storage/high_availability/ob_storage_ha_dag.cpp b/src/storage/high_availability/ob_storage_ha_dag.cpp index 80a1315007..ad0747b95a 100644 --- a/src/storage/high_availability/ob_storage_ha_dag.cpp +++ b/src/storage/high_availability/ob_storage_ha_dag.cpp @@ -648,30 +648,7 @@ int ObStorageHATaskUtils::check_minor_sstable_need_copy_( } if (OB_SUCC(ret) && !found) { - const int64_t start_log_ts = minor_sstables.at(0)->get_start_log_ts(); - const int64_t end_log_ts = minor_sstables.at(minor_sstables.count() - 1)->get_end_log_ts(); - if (param.table_key_.log_ts_range_.start_log_ts_ >= start_log_ts - && param.table_key_.log_ts_range_.end_log_ts_ <= end_log_ts) { - need_copy = false; - } else { - need_copy = true; - } - } - - if (OB_SUCC(ret) && !need_copy) { - const ObSSTableArray &minor_sstable_array = tablet->get_table_store().get_minor_sstables(); - bool has_remote_logical_sstable = false; - for (int64_t i = 0; OB_SUCC(ret) && i < minor_sstable_array.count(); ++i) { - ObITable *table = minor_sstable_array.get_table(i); - if (OB_ISNULL(table)) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("table should not be NULL", K(ret), KP(table)); - } else if (table->is_remote_logical_minor_sstable()) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("tablet still has remote logical minor sstable, cannot reuse local sstable", - K(ret), KPC(tablet), K(param)); - } - } + need_copy = true; } } return ret; diff --git a/src/storage/high_availability/ob_storage_ha_reader.cpp b/src/storage/high_availability/ob_storage_ha_reader.cpp index 0a72c9a2fe..3a36ef5d27 100644 --- a/src/storage/high_availability/ob_storage_ha_reader.cpp +++ b/src/storage/high_availability/ob_storage_ha_reader.cpp @@ -1455,6 +1455,7 @@ int ObCopyTabletsSSTableInfoObProducer::get_next_tablet_sstable_info( ObCopySSTableInfoObProducer::ObCopySSTableInfoObProducer() : is_inited_(false), + ls_id_(), tablet_sstable_info_(), tablet_handle_(), iter_(), @@ -1505,6 +1506,7 @@ int ObCopySSTableInfoObProducer::init( if (OB_FAIL(ret)) { } else { + ls_id_ = ls->get_ls_id(); tablet_sstable_info_ = tablet_sstable_info; is_inited_ = true; } @@ -1674,6 +1676,15 @@ int ObCopySSTableInfoObProducer::get_copy_tablet_sstable_header( } else if (OB_FAIL(get_copy_sstable_count_(copy_header.sstable_count_))) { LOG_WARN("failed to get copy sstable count", K(ret), K(tablet_sstable_info_)); } + } else if (ObCopyTabletStatus::TABLET_NOT_EXIST == status_) { + if (OB_FAIL(fake_deleted_tablet_meta_(copy_header.tablet_meta_))) { + LOG_WARN("failed to fake deleted tablet meta", K(ret), K(copy_header)); + } else { + copy_header.sstable_count_ = 0; + } + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("copy tablet status is unexpected", K(ret), K(status_), K(tablet_sstable_info_)); } } return ret; @@ -1697,6 +1708,43 @@ int ObCopySSTableInfoObProducer::get_tablet_meta_(ObMigrationTabletParam &tablet return ret; } +int ObCopySSTableInfoObProducer::fake_deleted_tablet_meta_( + ObMigrationTabletParam &tablet_meta) +{ + int ret = OB_SUCCESS; + tablet_meta.reset(); + const ObTabletRestoreStatus::STATUS restore_status = ObTabletRestoreStatus::FULL; + const ObTabletDataStatus::STATUS data_status = ObTabletDataStatus::COMPLETE; + + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("copy sstable info ob producer do not init", K(ret)); + } else { + tablet_meta.ls_id_ = ls_id_; + tablet_meta.tablet_id_ = tablet_sstable_info_.tablet_id_; + tablet_meta.data_tablet_id_ = tablet_sstable_info_.tablet_id_; + tablet_meta.start_scn_ = ObTabletMeta::INIT_CLOG_CHECKPOINT_TS; + tablet_meta.clog_checkpoint_ts_ = INT64_MAX; + tablet_meta.compat_mode_ = lib::Worker::get_compatibility_mode(); + tablet_meta.multi_version_start_ = 0; + tablet_meta.snapshot_version_ = 0; + tablet_meta.tx_data_.tablet_status_ = ObTabletStatus::DELETED; + + if (OB_FAIL(tablet_meta.ha_status_.set_restore_status(restore_status))) { + LOG_WARN("failed to set restore status", K(ret), K(restore_status)); + } else if (OB_FAIL(tablet_meta.ha_status_.set_data_status(data_status))) { + LOG_WARN("failed to set data status", K(ret), K(data_status)); + } else if (OB_FAIL(ObMigrationTabletParam::construct_placeholder_storage_schema(tablet_meta.allocator_, + tablet_meta.storage_schema_))) { + LOG_WARN("failed to construct placeholder storage schema"); + } else if (!tablet_meta.is_valid()) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("create deleted tablet meta is invalid", K(ret), K(tablet_meta)); + } + } + return ret; +} + ObCopySSTableMacroObReader::ObCopySSTableMacroObReader() : is_inited_(false), diff --git a/src/storage/high_availability/ob_storage_ha_reader.h b/src/storage/high_availability/ob_storage_ha_reader.h index 09f678b3d2..db4637bc41 100644 --- a/src/storage/high_availability/ob_storage_ha_reader.h +++ b/src/storage/high_availability/ob_storage_ha_reader.h @@ -415,9 +415,11 @@ private: bool &need_copy_sstable); int get_copy_sstable_count_(int64_t &sstable_count); int get_tablet_meta_(ObMigrationTabletParam &tablet_meta); + int fake_deleted_tablet_meta_(ObMigrationTabletParam &tablet_meta); private: bool is_inited_; + share::ObLSID ls_id_; obrpc::ObCopyTabletSSTableInfoArg tablet_sstable_info_; ObTabletHandle tablet_handle_; ObTableStoreIterator iter_; -- GitLab