From ba524159bf3cad1bfc8e0a0188c39af224c56da9 Mon Sep 17 00:00:00 2001 From: ZenoWang Date: Thu, 25 Apr 2024 12:14:26 +0000 Subject: [PATCH] [FIX] check is direct_load_memtable or data_memtable before static cast --- src/storage/access/ob_multiple_merge.cpp | 7 +++-- src/storage/access/ob_sample_iter_helper.cpp | 15 +++++---- src/storage/access/ob_sample_iter_helper.h | 2 +- src/storage/access/ob_table_estimator.cpp | 4 +++ src/storage/checkpoint/ob_data_checkpoint.cpp | 9 ++++-- .../ob_tablet_backfill_tx.cpp | 8 +++-- .../ob_transfer_backfill_tx.cpp | 8 +++-- src/storage/ls/ob_ls_tablet_service.cpp | 11 +++++-- src/storage/ob_partition_range_spliter.cpp | 28 +++++++++++------ src/storage/tablet/ob_tablet.cpp | 31 +++++++++++++------ 10 files changed, 84 insertions(+), 39 deletions(-) diff --git a/src/storage/access/ob_multiple_merge.cpp b/src/storage/access/ob_multiple_merge.cpp index 72c90bbc3..82c8c84fb 100644 --- a/src/storage/access/ob_multiple_merge.cpp +++ b/src/storage/access/ob_multiple_merge.cpp @@ -1321,10 +1321,11 @@ int ObMultipleMerge::prepare_tables_from_iterator(ObTableStoreIterator &table_it LOG_DEBUG("cur table is empty", K(ret), KPC(table_ptr)); continue; } else if (table_ptr->is_memtable()) { - read_released_memtable = read_released_memtable || - TabletMemtableFreezeState::RELEASED == (static_cast(table_ptr))->get_freeze_state(); ++memtable_cnt; - if (table_ptr->is_direct_load_memtable()) { + if (table_ptr->is_data_memtable()) { + read_released_memtable = read_released_memtable || + TabletMemtableFreezeState::RELEASED == (static_cast(table_ptr))->get_freeze_state(); + } else if (table_ptr->is_direct_load_memtable()) { ObDDLMemtable *ddl_memtable = nullptr; if (OB_FAIL((static_cast(table_ptr)->get_first_ddl_memtable(ddl_memtable)))) { if (ret == OB_ENTRY_NOT_EXIST) { diff --git a/src/storage/access/ob_sample_iter_helper.cpp b/src/storage/access/ob_sample_iter_helper.cpp index 615219a37..1d76d69d9 100644 --- a/src/storage/access/ob_sample_iter_helper.cpp +++ b/src/storage/access/ob_sample_iter_helper.cpp @@ -64,7 +64,7 @@ int ObGetSampleIterHelper::can_retire_to_memtable_row_sample_(bool &retire, ObIA if (get_table_param_.is_valid()) { int64_t memtable_row_count = 0; int64_t sstable_row_count = 0; - common::ObSEArray memtables; + common::ObSEArray memtables; // iter all tables to estimate row count get_table_param_.tablet_iter_.table_iter()->resume(); @@ -78,12 +78,15 @@ int ObGetSampleIterHelper::can_retire_to_memtable_row_sample_(bool &retire, ObIA } else { STORAGE_LOG(WARN, "Fail to get next table iter", K(ret), K(get_table_param_.tablet_iter_.table_iter())); } - } else if (table->is_memtable()) { - if (OB_FAIL(memtables.push_back(table))) { + } else if (table->is_data_memtable()) { + memtable::ObMemtable *memtable = static_cast(table); + if (OB_FAIL(memtables.push_back(memtable))) { STORAGE_LOG(WARN, "push back memtable failed", KR(ret)); } else { - memtable_row_count += static_cast(table)->get_physical_row_cnt(); + memtable_row_count += memtable->get_physical_row_cnt(); } + } else if (table->is_direct_load_memtable()) { + // FIXEM : @suzhi.yt support direct load memtable get_row_count(); } else if (table->is_sstable()) { sstable_row_count += static_cast(table)->get_row_count(); } @@ -112,7 +115,7 @@ int ObGetSampleIterHelper::can_retire_to_memtable_row_sample_(bool &retire, ObIA return ret; } -int ObGetSampleIterHelper::get_memtable_sample_ranges_(const ObIArray &memtables, +int ObGetSampleIterHelper::get_memtable_sample_ranges_(const ObIArray &memtables, ObIArray &sample_ranges) { int ret = OB_SUCCESS; @@ -121,7 +124,7 @@ int ObGetSampleIterHelper::get_memtable_sample_ranges_(const ObIArray(memtables.at(i)); + memtable::ObMemtable *memtable = memtables.at(i); int tmp_ret = OB_SUCCESS; if (OB_ISNULL(memtable)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/storage/access/ob_sample_iter_helper.h b/src/storage/access/ob_sample_iter_helper.h index 03adf1f8f..16bdc7a0f 100644 --- a/src/storage/access/ob_sample_iter_helper.h +++ b/src/storage/access/ob_sample_iter_helper.h @@ -48,7 +48,7 @@ private: // if need retire to row sample, sample_memtable_ranges must not be null int can_retire_to_memtable_row_sample_(bool &retire, ObIArray &sample_ranges); - int get_memtable_sample_ranges_(const ObIArray &memtables, + int get_memtable_sample_ranges_(const ObIArray &memtables, ObIArray &sample_ranges); private: diff --git a/src/storage/access/ob_table_estimator.cpp b/src/storage/access/ob_table_estimator.cpp index 22aa10013..aa18e22b8 100644 --- a/src/storage/access/ob_table_estimator.cpp +++ b/src/storage/access/ob_table_estimator.cpp @@ -153,6 +153,10 @@ int ObTableEstimator::estimate_multi_scan_row_count( } } } + } else if (current_table->is_direct_load_memtable()) { + // FIXME : @suzhi.yt + ret = OB_NOT_SUPPORTED; + LOG_WARN("not supported memtable", KR(ret), KPC(current_table)); } else { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected table type", K(ret), K(*current_table)); diff --git a/src/storage/checkpoint/ob_data_checkpoint.cpp b/src/storage/checkpoint/ob_data_checkpoint.cpp index 53e1ca08a..607d8741a 100644 --- a/src/storage/checkpoint/ob_data_checkpoint.cpp +++ b/src/storage/checkpoint/ob_data_checkpoint.cpp @@ -929,9 +929,12 @@ void ObDataCheckpoint::add_diagnose_info_for_ls_frozen_() RLOCK(LS_FROZEN); ls_frozen_list_.get_iterator(iterator); while (iterator.has_next()) { - memtable::ObMemtable *memtable = static_cast(iterator.get_next()); - if (!memtable->is_active_checkpoint()) { - memtable->report_memtable_diagnose_info(memtable::ObMemtable::AddCheckpointDiagnoseInfoForMemtable()); + ObITabletMemtable *tablet_memtable = static_cast(iterator.get_next()); + if (tablet_memtable->is_data_memtable()) { + if (!tablet_memtable->is_active_checkpoint()) { + (static_cast(tablet_memtable)) + ->report_memtable_diagnose_info(memtable::ObMemtable::AddCheckpointDiagnoseInfoForMemtable()); + } } } } diff --git a/src/storage/high_availability/ob_tablet_backfill_tx.cpp b/src/storage/high_availability/ob_tablet_backfill_tx.cpp index 2fa751768..3908f8ea5 100644 --- a/src/storage/high_availability/ob_tablet_backfill_tx.cpp +++ b/src/storage/high_availability/ob_tablet_backfill_tx.cpp @@ -581,10 +581,14 @@ int ObTabletBackfillTXTask::get_backfill_tx_memtables_( } else { for (int64_t i = 0; OB_SUCC(ret) && i < memtables.count(); ++i) { ObITable *table = memtables.at(i).get_table(); - memtable::ObMemtable *memtable = static_cast(table); - if (OB_ISNULL(table) || !table->is_data_memtable()) { + memtable::ObMemtable *memtable = nullptr; + if (OB_ISNULL(table) || !table->is_tablet_memtable()) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be NULL or table type is unexpected", K(ret), KP(table)); + } else if (table->is_direct_load_memtable()) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("find a direct load memtable", KR(ret), K(tablet_info_.tablet_id_), KPC(table)); + } else if (FALSE_IT(memtable = static_cast(table))) { } else if (table->get_start_scn() >= backfill_tx_ctx_->log_sync_scn_ && memtable->not_empty() && !memtable->get_rec_scn().is_max()) { diff --git a/src/storage/high_availability/ob_transfer_backfill_tx.cpp b/src/storage/high_availability/ob_transfer_backfill_tx.cpp index 9e61c4b9a..1e0690841 100644 --- a/src/storage/high_availability/ob_transfer_backfill_tx.cpp +++ b/src/storage/high_availability/ob_transfer_backfill_tx.cpp @@ -1300,10 +1300,14 @@ int ObTransferReplaceTableTask::check_src_memtable_is_empty_( } else if (!memtables.empty()) { for (int64_t i = 0; OB_SUCC(ret) && i < memtables.count(); ++i) { ObITable *table = memtables.at(i).get_table(); - memtable::ObMemtable *memtable = static_cast(table); - if (OB_ISNULL(table) || !table->is_memtable()) { + memtable::ObMemtable *memtable = nullptr; + if (OB_ISNULL(table) || !table->is_tablet_memtable()) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be NULL or table type is unexpected", K(ret), KP(table)); + } else if (table->is_direct_load_memtable()) { + ret = OB_TRANSFER_SYS_ERROR; + LOG_ERROR("find a direct load memtable", K(ret), KPC(table)); + } else if (FALSE_IT(memtable = static_cast(table))) { } else if (memtable->is_active_memtable()) { if (memtable->not_empty()) { ret = OB_TRANSFER_SYS_ERROR; diff --git a/src/storage/ls/ob_ls_tablet_service.cpp b/src/storage/ls/ob_ls_tablet_service.cpp index b44cf5987..32d8b7588 100644 --- a/src/storage/ls/ob_ls_tablet_service.cpp +++ b/src/storage/ls/ob_ls_tablet_service.cpp @@ -5763,9 +5763,12 @@ void ObLSTabletService::dump_diag_info_for_old_row_loss( } else if (table->is_sstable()) { FLOG_INFO("Found rowkey in the sstable", KPC(row), KPC(reinterpret_cast(table))); - } else { + } else if (table->is_data_memtable()) { FLOG_INFO("Found rowkey in the memtable", - KPC(row), KPC(reinterpret_cast(table))); + KPC(row), KPC(static_cast(table))); + } else if (table->is_direct_load_memtable()) { + FLOG_INFO("Found rowkey in the direct load memtable", + KPC(row), KPC(static_cast(table))); } // ignore error in the loop @@ -6059,7 +6062,9 @@ int ObLSTabletService::estimate_block_count_and_row_count( } else if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null table", K(ret), K(tablet_iter.table_iter())); - } else if (table->is_memtable()) { + } else if (table->is_direct_load_memtable()) { + // FIXME : @suzhi.yt + } else if (table->is_data_memtable()) { memtable_row_count += static_cast(table)->get_physical_row_cnt(); } else if (table->is_sstable()) { sstable = static_cast(table); diff --git a/src/storage/ob_partition_range_spliter.cpp b/src/storage/ob_partition_range_spliter.cpp index 798698462..94d5edf6f 100644 --- a/src/storage/ob_partition_range_spliter.cpp +++ b/src/storage/ob_partition_range_spliter.cpp @@ -931,7 +931,11 @@ int ObPartitionRangeSpliter::get_single_range_info(const ObStoreRange &store_ran if (OB_ISNULL(table)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "Invalid table pointer", K(ret), KP(table)); - } else if (!table->is_sstable()) { + } else if (table->is_direct_load_memtable()) { + // FIXME : @suzhi.yt + ret = OB_NOT_SUPPORTED; + STORAGE_LOG(WARN, "get single range from direct load memtable not supported", KR(ret), KPC(table)); + } else if (table->is_data_memtable()) { memtable::ObMemtable *memtable = static_cast(table); int64_t row_count = 0; if (OB_FAIL(memtable->estimate_phy_size(&store_range.get_start_key(), @@ -940,7 +944,7 @@ int ObPartitionRangeSpliter::get_single_range_info(const ObStoreRange &store_ran row_count))) { STORAGE_LOG(WARN, "Failed to get single range info from memtable", K(ret), K(store_range)); } - } else { + } else if (table->is_sstable()) { ObSSTable *sstable = static_cast(table); if (store_range.is_whole_range()) { ObSSTableMetaHandle meta_handle; @@ -1073,26 +1077,30 @@ int ObPartitionRangeSpliter::split_ranges(ObRangeSplitInfo &range_info, return ret; } - int ObPartitionRangeSpliter::split_ranges_memtable(ObRangeSplitInfo &range_info, ObIAllocator &allocator, ObIArray &range_array) { int ret = OB_SUCCESS; - + ObITable *table = range_info.tables_->at(0); if (OB_UNLIKELY(!range_info.is_valid() || range_info.is_sstable())) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "Invalid range info to split ranges for memtable", K(ret)); } else if (OB_UNLIKELY(range_info.tables_->count() != 1)) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "Unexpected table count for memtable range info", K(ret), K(range_info)); - } else { + } else if (OB_ISNULL(table)) { + ret = OB_ERR_UNEXPECTED; + STORAGE_LOG(WARN, "Unexpected null table", K(ret), KP(table), K(range_info)); + } else if (table->is_direct_load_memtable()) { + // FIXME : @suzhi.yt support direct load memtable? + ret = OB_NOT_SUPPORTED; + STORAGE_LOG(WARN, "not supported memtable", KR(ret), KPC(table)); + } else if (table->is_data_memtable()) { ObSEArray store_ranges; - memtable::ObMemtable *memtable = static_cast(range_info.tables_->at(0)); - if (OB_ISNULL(memtable)) { - ret = OB_ERR_UNEXPECTED; - STORAGE_LOG(WARN, "Unexpected null memtable", K(ret), KP(memtable), K(range_info)); - } else if (OB_FAIL(memtable->get_split_ranges( + memtable::ObMemtable *memtable = static_cast(table); + + if (OB_FAIL(memtable->get_split_ranges( &range_info.store_range_->get_start_key(), &range_info.store_range_->get_end_key(), range_info.parallel_target_count_, diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index 78ad31b2b..a4251dbe7 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -4219,11 +4219,17 @@ int ObTablet::get_newest_schema_version(int64_t &schema_version) const int64_t max_schema_version_on_memtable = 0; int64_t unused_max_column_cnt_on_memtable = 0; for (int64_t idx = 0; OB_SUCC(ret) && idx < memtables.count(); ++idx) { - memtable::ObMemtable *memtable = static_cast(memtables.at(idx)); - if (OB_FAIL(memtable->get_schema_info( - store_column_cnt_in_schema, - max_schema_version_on_memtable, unused_max_column_cnt_on_memtable))) { - LOG_WARN("failed to get schema info from memtable", KR(ret), KPC(memtable)); + ObITable *table = memtables.at(idx); + if (table->is_data_memtable()) { + ObMemtable *memtable = static_cast(table); + if (OB_FAIL(memtable->get_schema_info( + store_column_cnt_in_schema, max_schema_version_on_memtable, unused_max_column_cnt_on_memtable))) { + LOG_WARN("failed to get schema info from memtable", KR(ret), KPC(table)); + } + } else if (table->is_direct_load_memtable()) { + // FIXME : @suzhi.yt + // ret = OB_NOT_SUPPORTED; + LOG_INFO("find a direct load memtable", KR(ret)); } } if (OB_SUCC(ret)) { @@ -5557,12 +5563,19 @@ int ObTablet::get_storage_schema_for_transfer_in( if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table in tables_handle is invalid", K(ret), KP(table)); - } else if (OB_FAIL(static_cast(table)->get_schema_info( - store_column_cnt_in_schema, - max_schema_version_in_memtable, max_column_cnt_in_memtable))) { - LOG_WARN("failed to get schema info from memtable", KR(ret), KPC(table)); + } else if (table->is_data_memtable()) { + ObMemtable *memtable = static_cast(table); + if (OB_FAIL(memtable->get_schema_info( + store_column_cnt_in_schema, max_schema_version_in_memtable, max_column_cnt_in_memtable))) { + LOG_WARN("failed to get schema info from memtable", KR(ret), KPC(table)); + } + } else if (table->is_direct_load_memtable()) { + // FIXME : @suzhi.yt + // ret = OB_NOT_SUPPORTED; + LOG_INFO("find a direct load memtable", KR(ret)); } } + } if (OB_FAIL(ret)) {