diff --git a/src/rootserver/ob_schema_history_recycler.cpp b/src/rootserver/ob_schema_history_recycler.cpp index 18d70a6c97eea74fd1cf29ec7819067f232d774e..98015c75464778fcfd9c3ffaf4cbda997a89a812 100644 --- a/src/rootserver/ob_schema_history_recycler.cpp +++ b/src/rootserver/ob_schema_history_recycler.cpp @@ -17,6 +17,7 @@ #include "rootserver/ob_schema_history_recycler.h" #include "rootserver/ob_rs_async_rpc_proxy.h" #include "rootserver/ob_rs_event_history_table_operator.h" +#include "storage/ob_freeze_info_snapshot_mgr.h" namespace oceanbase { namespace rootserver { @@ -658,6 +659,19 @@ int ObSchemaHistoryRecycler::get_recycle_schema_version_by_global_stat( K(reserved_schema_version)); } } + if (OB_SUCC(ret)) { + int64_t schema_version = 0; + for (int64_t i = 0; OB_SUCC(ret) && i < tenant_ids.count(); i++) { + const uint64_t tenant_id = tenant_ids.at(i); + if (OB_FAIL(storage::ObFreezeInfoMgrWrapper::get_instance().get_restore_point_min_schema_version( + tenant_id, schema_version))) { + LOG_WARN("fail to get restore point min_schema_version", K(ret), K(tenant_id)); + } else if (INT64_MAX != schema_version && + OB_FAIL(fill_recycle_schema_versions(tenant_id, schema_version, recycle_schema_versions))) { + LOG_WARN("fail to fill recycle schema versions", KR(ret), K(tenant_id), K(schema_version)); + } + } + } } return ret; } diff --git a/src/storage/ob_freeze_info_snapshot_mgr.cpp b/src/storage/ob_freeze_info_snapshot_mgr.cpp index 149993db72a1a93d86b2b9b77ec6a991581751b9..094663ad5b4df6b15704ae9746a66050717dafc9 100644 --- a/src/storage/ob_freeze_info_snapshot_mgr.cpp +++ b/src/storage/ob_freeze_info_snapshot_mgr.cpp @@ -560,7 +560,22 @@ int ObFreezeInfoSnapshotMgr::get_reserve_points(const int64_t tenant_id, const s return ret; } -int ObFreezeInfoSnapshotMgr::get_latest_freeze_version(int64_t& freeze_version) +int ObFreezeInfoSnapshotMgr::get_restore_point_min_schema_version(const int64_t tenant_id, int64_t &schema_version) +{ + int ret = OB_SUCCESS; + schema_version = INT64_MAX; + RLockGuard lock_guard(lock_); + ObIArray &snapshots = snapshots_[cur_idx_]; + for (int64_t i = 0; i < snapshots.count() && OB_SUCC(ret); ++i) { + const ObSnapshotInfo &snapshot = snapshots.at(i); + if (snapshot.snapshot_type_ == SNAPSHOT_FOR_RESTORE_POINT && tenant_id == snapshot.tenant_id_) { + schema_version = std::min(snapshot.schema_version_, schema_version); + } + } + return ret; +} + +int ObFreezeInfoSnapshotMgr::get_latest_freeze_version(int64_t &freeze_version) { int ret = OB_SUCCESS; diff --git a/src/storage/ob_freeze_info_snapshot_mgr.h b/src/storage/ob_freeze_info_snapshot_mgr.h index b8b64d933c38f5f12364bfd80085e02588d77eea..cd6909374e72436e8564b0d16e28ff718d51f605 100644 --- a/src/storage/ob_freeze_info_snapshot_mgr.h +++ b/src/storage/ob_freeze_info_snapshot_mgr.h @@ -148,30 +148,51 @@ public: int64_t get_latest_frozen_timestamp(); // no schema version is returned if you do not give the tenant id - int get_freeze_info_by_major_version(const int64_t major_version, FreezeInfoLite& freeze_info); - int get_freeze_info_by_major_version(const uint64_t table_id, const int64_t major_version, FreezeInfo& freeze_info); - int get_freeze_info_by_major_version( - const int64_t major_version, FreezeInfoLite& freeze_info, bool& is_first_major_version); - int get_freeze_info_behind_major_version(const int64_t major_version, common::ObIArray& freeze_infos); - - int get_tenant_freeze_info_by_major_version( - const uint64_t tenant_id, const int64_t major_version, FreezeInfo& freeze_info); - - int get_freeze_info_by_snapshot_version(const int64_t snapshot_version, FreezeInfoLite& freeze_info); - int get_freeze_info_by_snapshot_version( - const uint64_t table_id, const int64_t snapshot_version, FreezeInfo& freeze_info); - - int get_neighbour_major_freeze(const int64_t snapshot_version, NeighbourFreezeInfoLite& info); - int get_neighbour_major_freeze(const uint64_t table_id, const int64_t snapshot_version, NeighbourFreezeInfo& info); - - int get_min_reserved_snapshot(const common::ObPartitionKey& pkey, const int64_t merged_version, - const int64_t schema_version, int64_t& snapshot_version, int64_t& backup_snapshot_version); - int get_reserve_points(const int64_t tenant_id, const share::ObSnapShotType snapshot_type, - common::ObIArray& restore_points, int64_t& snapshot_gc_ts); - int update_info(const int64_t snapshot_gc_ts, const common::ObIArray& gc_schema_version, - const common::ObIArray& info_list, const common::ObIArray& snapshots, - const int64_t backup_snapshot_version, const int64_t delay_delete_snapshot_version, - const int64_t min_major_version, bool& changed); + int get_freeze_info_by_major_version(const int64_t major_version, + FreezeInfoLite &freeze_info); + int get_freeze_info_by_major_version(const uint64_t table_id, + const int64_t major_version, + FreezeInfo &freeze_info); + int get_freeze_info_by_major_version(const int64_t major_version, + FreezeInfoLite &freeze_info, + bool &is_first_major_version); + int get_freeze_info_behind_major_version(const int64_t major_version, + common::ObIArray &freeze_infos); + + int get_tenant_freeze_info_by_major_version(const uint64_t tenant_id, + const int64_t major_version, + FreezeInfo &freeze_info); + + int get_freeze_info_by_snapshot_version(const int64_t snapshot_version, + FreezeInfoLite &freeze_info); + int get_freeze_info_by_snapshot_version(const uint64_t table_id, + const int64_t snapshot_version, + FreezeInfo &freeze_info); + + int get_neighbour_major_freeze(const int64_t snapshot_version, + NeighbourFreezeInfoLite &info); + int get_neighbour_major_freeze(const uint64_t table_id, + const int64_t snapshot_version, + NeighbourFreezeInfo &info); + + int get_min_reserved_snapshot(const common::ObPartitionKey &pkey, + const int64_t merged_version, + const int64_t schema_version, + int64_t &snapshot_version, + int64_t &backup_snapshot_version); + int get_reserve_points(const int64_t tenant_id, + const share::ObSnapShotType snapshot_type, + common::ObIArray &restore_points, + int64_t &snapshot_gc_ts); + int get_restore_point_min_schema_version(const int64_t tenant_id, int64_t &schema_version); + int update_info(const int64_t snapshot_gc_ts, + const common::ObIArray &gc_schema_version, + const common::ObIArray &info_list, + const common::ObIArray &snapshots, + const int64_t backup_snapshot_version, + const int64_t delay_delete_snapshot_version, + const int64_t min_major_version, + bool& changed); int64_t get_snapshot_gc_ts(); int get_local_backup_snapshot_version(int64_t& backup_snapshot_version);