From 5b5c04ff4954b448ce7b6cba52b6b8249c7a984b Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 19 Jul 2021 21:39:13 +0800 Subject: [PATCH] cherry-pick from 3_1_x_release to 3.1_opensource_release --- src/observer/ob_service.cpp | 34 ++++++++++++++++---- src/storage/ob_multi_version_table_store.cpp | 3 -- src/storage/ob_multi_version_table_store.h | 1 + src/storage/ob_partition_store.cpp | 11 ++++++- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/observer/ob_service.cpp b/src/observer/ob_service.cpp index 029f71d085..217f858902 100644 --- a/src/observer/ob_service.cpp +++ b/src/observer/ob_service.cpp @@ -920,7 +920,6 @@ int ObService::submit_pt_update_task( { int ret = OB_SUCCESS; const bool is_remove = false; - const int64_t version = 0; const ObSSTableChecksumUpdateType update_type = ObSSTableChecksumUpdateType::UPDATE_ALL; if (!inited_) { ret = OB_NOT_INIT; @@ -930,12 +929,35 @@ int ObService::submit_pt_update_task( LOG_WARN("invalid argument", K(part_key), K(ret)); } else if (OB_FAIL(partition_table_updater_.async_update(part_key, with_role))) { LOG_WARN("async_update failed", K(part_key), K(ret)); - } else if (need_report_checksum && !part_key.is_pg() && - OB_FAIL(checksum_updater_.add_task(part_key, is_remove, update_type))) { - LOG_WARN("fail to async update sstable checksum", K(ret)); - } else { - // do nothing + } else if (need_report_checksum) { + if (part_key.is_pg()) { + ObPartitionArray pkeys; + ObIPartitionGroupGuard guard; + if (OB_FAIL(gctx_.par_ser_->get_partition(part_key, guard))) { + if (OB_PARTITION_NOT_EXIST == ret) { + ret = OB_SUCCESS; + } else { + LOG_WARN("fail to get partition", K(ret), K(part_key)); + } + } else if (OB_ISNULL(guard.get_partition_group())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("error unexpected, partition must not be NULL", K(ret)); + } else if (OB_FAIL(guard.get_partition_group()->get_all_pg_partition_keys(pkeys))) { + LOG_WARN("get pg partition fail", K(ret), K(part_key)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < pkeys.count(); ++i) { + if (OB_FAIL(checksum_updater_.add_task(pkeys.at(i), is_remove, update_type))) { + LOG_WARN("failt to async update sstable checksum", K(ret), K(pkeys.at(i))); + } + } + } + } else { + if (OB_FAIL(checksum_updater_.add_task(part_key, is_remove, update_type))) { + LOG_WARN("fail to async update sstable checksum", K(ret)); + } + } } + return ret; } diff --git a/src/storage/ob_multi_version_table_store.cpp b/src/storage/ob_multi_version_table_store.cpp index 61afcf0586..64b4f3c854 100644 --- a/src/storage/ob_multi_version_table_store.cpp +++ b/src/storage/ob_multi_version_table_store.cpp @@ -1432,9 +1432,6 @@ int ObMultiVersionTableStore::get_schema_version(int64_t& schema_version) if (OB_FAIL(table_store->get_schema_version(schema_version))) { LOG_WARN("failed to get_schema_version", K(ret)); } - } else if (create_schema_version_ <= 0) { - ret = OB_ERR_SYS; - LOG_WARN("create_schema_version should be valid when no table exist", K(ret)); } else { schema_version = create_schema_version_; } diff --git a/src/storage/ob_multi_version_table_store.h b/src/storage/ob_multi_version_table_store.h index 2cadc056f6..bb549d76e5 100644 --- a/src/storage/ob_multi_version_table_store.h +++ b/src/storage/ob_multi_version_table_store.h @@ -112,6 +112,7 @@ public: int set_drop_schema_info(const int64_t drop_schema_version); int get_drop_schema_info(int64_t& drop_schema_version, int64_t& drop_schema_refreshed_ts); int get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle& handle); + void set_create_schema_version(const int64_t schema_version) { create_schema_version_ = schema_version; } DECLARE_VIRTUAL_TO_STRING; diff --git a/src/storage/ob_partition_store.cpp b/src/storage/ob_partition_store.cpp index 949abe7b96..1d038ceba4 100644 --- a/src/storage/ob_partition_store.cpp +++ b/src/storage/ob_partition_store.cpp @@ -749,7 +749,16 @@ int ObPartitionStore::create_multi_version_store_( if (OB_HASH_EXIST != ret) { LOG_WARN("failed to set table store to map", K(ret), K(table_id)); } else { - ret = OB_ENTRY_EXIST; + ObMultiVersionTableStore *get_table_store = nullptr; + if (OB_FAIL(store_map_->get(table_id, get_table_store))) { + LOG_WARN("get store map failed", K(ret), K(table_id)); + } else if (OB_ISNULL(get_table_store)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("error unexpected, get table store must not be nullptr", K(ret)); + } else { + get_table_store->set_create_schema_version(schema_version); + ret = OB_ENTRY_EXIST; + } } } else { LOG_INFO("succeed to create multi version table store", KPC(tmp_table_store), KP(tmp_table_store), K(table_id)); -- GitLab