diff --git a/deps/oblib/src/lib/restore/ob_storage.cpp b/deps/oblib/src/lib/restore/ob_storage.cpp index 5999c6bb3f405366fa523c41e78cff6b39503bf0..89bea4680fefe0cb939be5750d76a06901d0eaa0 100644 --- a/deps/oblib/src/lib/restore/ob_storage.cpp +++ b/deps/oblib/src/lib/restore/ob_storage.cpp @@ -18,10 +18,10 @@ namespace oceanbase { namespace common { -const char* OB_STORAGE_TYPES_STR[] = {"OSS", "FILE", "COS"}; +const char *OB_STORAGE_TYPES_STR[] = {"OSS", "FILE", "COS"}; void print_access_storage_log( - const char* msg, const common::ObString& uri, const int64_t start_ts, const int64_t size, bool* is_slow) + const char *msg, const common::ObString &uri, const int64_t start_ts, const int64_t size, bool *is_slow) { if (NULL != is_slow) { *is_slow = false; @@ -48,7 +48,7 @@ void print_access_storage_log( } } -int get_storage_type_from_path(const common::ObString& uri, ObStorageType& type) +int get_storage_type_from_path(const common::ObString &uri, ObStorageType &type) { int ret = OB_SUCCESS; type = OB_STORAGE_MAX_TYPE; @@ -66,9 +66,9 @@ int get_storage_type_from_path(const common::ObString& uri, ObStorageType& type) return ret; } -const char* get_storage_type_str(const ObStorageType& type) +const char *get_storage_type_str(const ObStorageType &type) { - const char* str = "UNKNOWN"; + const char *str = "UNKNOWN"; STATIC_ASSERT( static_cast(OB_STORAGE_MAX_TYPE) == ARRAYSIZEOF(OB_STORAGE_TYPES_STR), "ObStorageType count mismatch"); if (type >= 0 && type < OB_STORAGE_MAX_TYPE) { @@ -82,7 +82,7 @@ bool is_io_error(const int result) return OB_IO_ERROR == result || OB_OSS_ERROR == result; } -int get_storage_type_from_name(const char* type_str, ObStorageType& type) +int get_storage_type_from_name(const char *type_str, ObStorageType &type) { int ret = OB_SUCCESS; type = ObStorageType::OB_STORAGE_MAX_TYPE; @@ -131,11 +131,11 @@ ObStorageUtil::ObStorageUtil(const bool need_retry, const int64_t max_retry_dura } } -int ObStorageUtil::is_exist(const common::ObString& uri, const common::ObString& storage_info, bool& exist) +int ObStorageUtil::is_exist(const common::ObString &uri, const common::ObString &storage_info, bool &exist) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; exist = false; #ifdef ERRSIM @@ -156,11 +156,11 @@ int ObStorageUtil::is_exist(const common::ObString& uri, const common::ObString& } int ObStorageUtil::get_file_length( - const common::ObString& uri, const common::ObString& storage_info, int64_t& file_length) + const common::ObString &uri, const common::ObString &storage_info, int64_t &file_length) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; file_length = -1; int64_t retry_times = 0; bool need_retry = true; @@ -203,11 +203,11 @@ int ObStorageUtil::get_file_length( return ret; } -int ObStorageUtil::del_file(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageUtil::del_file(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; #ifdef ERRSIM ret = E(EventTable::EN_BACKUP_IO_BEFORE_DEL_FILE) OB_SUCCESS; @@ -252,11 +252,11 @@ int ObStorageUtil::del_file(const common::ObString& uri, const common::ObString& return ret; } -int ObStorageUtil::mkdir(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageUtil::mkdir(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; STORAGE_LOG(DEBUG, "mkdir", K(uri)); #ifdef ERRSIM @@ -280,7 +280,7 @@ int ObStorageUtil::mkdir(const common::ObString& uri, const common::ObString& st return ret; } -int ObStorageUtil::mk_parent_dir(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageUtil::mk_parent_dir(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; char path[OB_MAX_URI_LENGTH]; @@ -318,8 +318,8 @@ int ObStorageUtil::mk_parent_dir(const common::ObString& uri, const common::ObSt return ret; } -int ObStorageUtil::read_single_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, - const int64_t buf_size, int64_t& read_size) +int ObStorageUtil::read_single_file(const common::ObString &uri, const common::ObString &storage_info, char *buf, + const int64_t buf_size, int64_t &read_size) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); @@ -354,8 +354,8 @@ int ObStorageUtil::read_single_file(const common::ObString& uri, const common::O return ret; } -int ObStorageUtil::do_read_single_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, - const int64_t buf_size, int64_t& read_size) +int ObStorageUtil::do_read_single_file(const common::ObString &uri, const common::ObString &storage_info, char *buf, + const int64_t buf_size, int64_t &read_size) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -384,7 +384,7 @@ int ObStorageUtil::do_read_single_file(const common::ObString& uri, const common // has '\0' in the end int ObStorageUtil::read_single_text_file( - const common::ObString& uri, const common::ObString& storage_info, char* buf, const int64_t buf_size) + const common::ObString &uri, const common::ObString &storage_info, char *buf, const int64_t buf_size) { int ret = OB_SUCCESS; int64_t read_size = -1; @@ -404,11 +404,11 @@ int ObStorageUtil::read_single_text_file( return ret; } -int ObStorageUtil::update_file_modify_time(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageUtil::update_file_modify_time(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -446,12 +446,12 @@ int ObStorageUtil::update_file_modify_time(const common::ObString& uri, const co return ret; } -int ObStorageUtil::list_files(const common::ObString& uri, const common::ObString& storage_info, - common::ObIAllocator& allocator, common::ObIArray& file_names) +int ObStorageUtil::list_files(const common::ObString &uri, const common::ObString &storage_info, + common::ObIAllocator &allocator, common::ObIArray &file_names) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -492,11 +492,11 @@ int ObStorageUtil::list_files(const common::ObString& uri, const common::ObStrin } int ObStorageUtil::write_single_file( - const common::ObString& uri, const common::ObString& storage_info, const char* buf, const int64_t size) + const common::ObString &uri, const common::ObString &storage_info, const char *buf, const int64_t size) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -544,7 +544,7 @@ int ObStorageUtil::write_single_file( return ret; } -int ObStorageUtil::get_util(const common::ObString& uri, ObIStorageUtil*& util) +int ObStorageUtil::get_util(const common::ObString &uri, ObIStorageUtil *&util) { int ret = OB_SUCCESS; ObStorageType type = OB_STORAGE_MAX_TYPE; @@ -568,8 +568,8 @@ int ObStorageUtil::get_util(const common::ObString& uri, ObIStorageUtil*& util) return ret; } -int ObStorageUtil::read_part_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, - const int64_t buf_size, const int64_t offset, int64_t& read_size) +int ObStorageUtil::read_part_file(const common::ObString &uri, const common::ObString &storage_info, char *buf, + const int64_t buf_size, const int64_t offset, int64_t &read_size) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); @@ -600,8 +600,8 @@ int ObStorageUtil::read_part_file(const common::ObString& uri, const common::ObS return ret; } -int ObStorageUtil::do_read_part_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, - const int64_t buf_size, const int64_t offset, int64_t& read_size) +int ObStorageUtil::do_read_part_file(const common::ObString &uri, const common::ObString &storage_info, char *buf, + const int64_t buf_size, const int64_t offset, int64_t &read_size) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -623,11 +623,11 @@ int ObStorageUtil::do_read_part_file(const common::ObString& uri, const common:: return ret; } -int ObStorageUtil::del_dir(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageUtil::del_dir(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -657,11 +657,11 @@ int ObStorageUtil::del_dir(const common::ObString& uri, const common::ObString& } int ObStorageUtil::get_pkeys_from_dir( - const common::ObString& uri, const common::ObString& storage_info, common::ObIArray& pkeys) + const common::ObString &uri, const common::ObString &storage_info, common::ObIArray &pkeys) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -695,11 +695,11 @@ int ObStorageUtil::get_pkeys_from_dir( return ret; } -int ObStorageUtil::delete_tmp_files(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageUtil::delete_tmp_files(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -738,7 +738,7 @@ int ObStorageUtil::delete_tmp_files(const common::ObString& uri, const common::O } int ObStorageUtil::check_backup_dest_lifecycle( - const common::ObString& path, const common::ObString& storage_info, bool& is_set_lifecycle) + const common::ObString &path, const common::ObString &storage_info, bool &is_set_lifecycle) { int ret = OB_NOT_SUPPORTED; @@ -785,12 +785,12 @@ int ObStorageUtil::check_backup_dest_lifecycle( } int ObStorageUtil::is_empty_directory( - const common::ObString& uri, const common::ObString& storage_info, bool& is_empty_directory) + const common::ObString &uri, const common::ObString &storage_info, bool &is_empty_directory) { int ret = OB_SUCCESS; is_empty_directory = false; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -819,12 +819,12 @@ int ObStorageUtil::is_empty_directory( return ret; } -int ObStorageUtil::list_directories(const common::ObString& uri, const common::ObString& storage_info, - common::ObIAllocator& allocator, common::ObIArray& directory_names) +int ObStorageUtil::list_directories(const common::ObString &uri, const common::ObString &storage_info, + common::ObIAllocator &allocator, common::ObIArray &directory_names) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); - ObIStorageUtil* util = NULL; + ObIStorageUtil *util = NULL; int64_t retry_times = 0; bool need_retry = true; @@ -857,8 +857,7 @@ int ObStorageUtil::list_directories(const common::ObString& uri, const common::O return ret; } -ObStorageReader::ObStorageReader() - : file_length_(-1), reader_(NULL), start_ts_(0) +ObStorageReader::ObStorageReader() : file_length_(-1), reader_(NULL), start_ts_(0) { uri_[0] = '\0'; } @@ -870,7 +869,7 @@ ObStorageReader::~ObStorageReader() } } -int ObStorageReader::open(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageReader::open(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -921,7 +920,7 @@ int ObStorageReader::open(const common::ObString& uri, const common::ObString& s return ret; } -int ObStorageReader::pread(char* buf, const int64_t buf_size, int64_t offset, int64_t& read_size) +int ObStorageReader::pread(char *buf, const int64_t buf_size, int64_t offset, int64_t &read_size) { int ret = OB_SUCCESS; read_size = 0; @@ -987,7 +986,7 @@ ObStorageWriter::~ObStorageWriter() } } -int ObStorageWriter::open(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageWriter::open(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1035,7 +1034,7 @@ int ObStorageWriter::open(const common::ObString& uri, const common::ObString& s return ret; } -int ObStorageWriter::write(const char* buf, const int64_t size) +int ObStorageWriter::write(const char *buf, const int64_t size) { int ret = OB_SUCCESS; @@ -1103,7 +1102,7 @@ ObStorageAppender::~ObStorageAppender() } int ObStorageAppender::open( - const common::ObString& uri, const common::ObString& storage_info, const AppenderParam& param) + const common::ObString &uri, const common::ObString &storage_info, const AppenderParam ¶m) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1156,7 +1155,7 @@ int ObStorageAppender::open( return ret; } -int ObStorageAppender::open_deprecated(const common::ObString& uri, const common::ObString& storage_info) +int ObStorageAppender::open_deprecated(const common::ObString &uri, const common::ObString &storage_info) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1206,7 +1205,7 @@ int ObStorageAppender::open_deprecated(const common::ObString& uri, const common return ret; } -int ObStorageAppender::write(const char* buf, const int64_t size) +int ObStorageAppender::write(const char *buf, const int64_t size) { int ret = OB_SUCCESS; @@ -1235,7 +1234,7 @@ int ObStorageAppender::write(const char* buf, const int64_t size) return ret; } -int ObStorageAppender::pwrite(const char* buf, const int64_t size, const int64_t offset) +int ObStorageAppender::pwrite(const char *buf, const int64_t size, const int64_t offset) { int ret = OB_SUCCESS; @@ -1294,11 +1293,11 @@ ObStorageMetaWrapper::ObStorageMetaWrapper() : file_meta_() ObStorageMetaWrapper::~ObStorageMetaWrapper() {} -int ObStorageMetaWrapper::get(const common::ObString& uri, const common::ObString& storage_info, char* buf, - const int64_t buf_size, int64_t& read_size) +int ObStorageMetaWrapper::get(const common::ObString &uri, const common::ObString &storage_info, char *buf, + const int64_t buf_size, int64_t &read_size) { int ret = OB_SUCCESS; - ObIStorageMetaWrapper* meta = NULL; + ObIStorageMetaWrapper *meta = NULL; const int64_t start_ts = ObTimeUtility::current_time(); if (ObStorageGlobalIns::get_instance().is_io_prohibited()) { @@ -1320,10 +1319,10 @@ int ObStorageMetaWrapper::get(const common::ObString& uri, const common::ObStrin } int ObStorageMetaWrapper::set( - const common::ObString& uri, const common::ObString& storage_info, const char* buf, const int64_t size) + const common::ObString &uri, const common::ObString &storage_info, const char *buf, const int64_t size) { int ret = OB_SUCCESS; - ObIStorageMetaWrapper* meta = NULL; + ObIStorageMetaWrapper *meta = NULL; const int64_t start_ts = ObTimeUtility::current_time(); if (ObStorageGlobalIns::get_instance().is_io_prohibited()) { @@ -1344,7 +1343,7 @@ int ObStorageMetaWrapper::set( return ret; } -int ObStorageMetaWrapper::get_meta(const common::ObString& uri, ObIStorageMetaWrapper*& meta) +int ObStorageMetaWrapper::get_meta(const common::ObString &uri, ObIStorageMetaWrapper *&meta) { int ret = OB_SUCCESS; ObStorageType type = OB_STORAGE_MAX_TYPE; diff --git a/deps/oblib/src/lib/utility/ob_tracepoint.h b/deps/oblib/src/lib/utility/ob_tracepoint.h index 1c7999edf686d866d822f805f5a3194f8eee7e48..8bce12634ac6140b2544b40c1736b23829d6f241 100644 --- a/deps/oblib/src/lib/utility/ob_tracepoint.h +++ b/deps/oblib/src/lib/utility/ob_tracepoint.h @@ -66,7 +66,7 @@ #define TRACEPOINT_CALL(name, ...) \ ({ \ - static void** func_ptr = ::oceanbase::common::tracepoint_get(name); \ + static void **func_ptr = ::oceanbase::common::tracepoint_get(name); \ (NULL != func_ptr) ? TP_CALL_FUNC(func_ptr, ##__VA_ARGS__) : 0; \ }) @@ -77,13 +77,13 @@ #define OB_I(...) #endif -bool& get_tp_switch(); +bool &get_tp_switch(); #define TP_SWITCH_GUARD(v) ::oceanbase::lib::ObSwitchGuard osg_##__COUNTER__##_(v) namespace oceanbase { namespace lib { -using GetSwitchFunc = bool&(); +using GetSwitchFunc = bool &(); template class ObSwitchGuard { @@ -130,23 +130,23 @@ private: } #define TP_SET(file_name, func_name, key, trace_func) \ - *::oceanbase::common::tracepoint_get(refine_tp_key(file_name, func_name, key)) = (void*)(trace_func) + *::oceanbase::common::tracepoint_get(refine_tp_key(file_name, func_name, key)) = (void *)(trace_func) #define TP_SET_ERROR(file_name, func_name, key, err) \ TP_SET(file_name, func_name, key, (int (*)()) & tp_const_error<(err)>) namespace oceanbase { namespace common { -inline const char* tp_basename(const char* path) +inline const char *tp_basename(const char *path) { - const char* ret = OB_ISNULL(path) ? NULL : strrchr(path, '/'); + const char *ret = OB_ISNULL(path) ? NULL : strrchr(path, '/'); return (NULL == ret) ? path : ++ret; } -inline const char* refine_tp_key(const char* s1, const char* s2, const char* s3) +inline const char *refine_tp_key(const char *s1, const char *s2, const char *s3) { const int32_t BUFFER_SIZE = 256; static RLOCAL(lib::ByteBuf, buffer); - const char* cret = nullptr; + const char *cret = nullptr; if (OB_ISNULL(s1) || OB_ISNULL(s2) || OB_ISNULL(s3)) { } else { s1 = tp_basename(s1); @@ -168,13 +168,13 @@ public: {} ~TPSymbolTable() {} - void** get(const char* name) + void **get(const char *name) { return (NULL != name) ? do_get(name) : NULL; } private: - static uint64_t BKDRHash(const char* str); + static uint64_t BKDRHash(const char *str); enum { SYMBOL_SIZE_LIMIT = 128, SYMBOL_COUNT_LIMIT = 64 * 1024 }; struct SymbolEntry { @@ -186,19 +186,19 @@ private: ~SymbolEntry() {} - bool find(const char* name); + bool find(const char *name); int lock_; - void* value_; + void *value_; char name_[SYMBOL_SIZE_LIMIT]; }; - void** do_get(const char* name); + void **do_get(const char *name); SymbolEntry symbol_table_[SYMBOL_COUNT_LIMIT]; }; -inline void** tracepoint_get(const char* name) +inline void **tracepoint_get(const char *name) { static TPSymbolTable symbol_table; return symbol_table.get(name); @@ -233,7 +233,7 @@ struct EventItem { }; struct NamedEventItem : public ObDLinkBase { - NamedEventItem(const char* name, ObDList& l) : name_(name) + NamedEventItem(const char *name, ObDList &l) : name_(name) { l.add_last(this); } @@ -242,7 +242,7 @@ struct NamedEventItem : public ObDLinkBase { return item_.call(); } - const char* name_; + const char *name_; EventItem item_; }; @@ -442,6 +442,9 @@ public: EN_BACKUP_AFTER_UPDATE_EXTERNAL_BOTH_PIECE_INFO_FOR_SYS = 180, EN_BACKUP_BACKUPPIECE_FINISH_UPDATE_EXTERN_AND_INNER_INFO = 181, EN_BACKUP_BACKUPPIECE_DO_SCHEDULE = 182, + EN_BACKUP_UPDATE_START_REPLAY_LOG_TS = 183, + EN_BACKUP_BACKUPSET_DO_SCHEDULE = 184, + EN_BACKUP_CHECK_BACKUP_POINT_EXIST = 185, // 下面请从201开始 EN_CHECK_STANDBY_CLUSTER_SCHEMA_CONDITION = 201, EN_ALLOCATE_LOB_BUF_FAILED = 202, @@ -507,14 +510,14 @@ public: } /* set an event value */ - inline void set_event(int64_t index, const EventItem& item) + inline void set_event(int64_t index, const EventItem &item) { if (index >= 0 && index < SIZE_OF_EVENT_TABLE) { event_table_[index] = item; } } - static inline void set_event(const char* name, const EventItem& item) + static inline void set_event(const char *name, const EventItem &item) { DLIST_FOREACH_NORET(i, global_item_list()) { @@ -524,13 +527,13 @@ public: } } - static ObDList& global_item_list() + static ObDList &global_item_list() { static ObDList g_list; return g_list; } - static EventTable& instance() + static EventTable &instance() { static EventTable et; return et; @@ -545,7 +548,7 @@ private: }; inline void event_access(int64_t index, /* tracepoint number */ - EventItem& item, bool is_get) /* is a 'get' */ + EventItem &item, bool is_get) /* is a 'get' */ { if (is_get) item = EventTable::instance().get_event(index); diff --git a/deps/oblib/unittest/lib/restore/test_storage_oss.cpp b/deps/oblib/unittest/lib/restore/test_storage_oss.cpp index cee2498d9db834fa8fd4157169546bda1b6246e7..2d5a1bc4573573400908bcf96b6360c6a98f213d 100644 --- a/deps/oblib/unittest/lib/restore/test_storage_oss.cpp +++ b/deps/oblib/unittest/lib/restore/test_storage_oss.cpp @@ -55,7 +55,7 @@ TEST_F(TestStorageOss, test_del) databuff_printf( storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_)); const ObString storage_info(storage_infos); - const char* dir_name = "test"; + const char *dir_name = "test"; char test_content[OB_MAX_URI_LENGTH] = "just_for_test"; int64_t read_size = 0; @@ -79,8 +79,9 @@ TEST_F(TestStorageOss, test_get_pkey_from_path) char storage_infos[OB_MAX_URI_LENGTH]; ObArenaAllocator allocator; - ASSERT_EQ(OB_SUCCESS, databuff_printf(storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", - oss_host_, oss_id_, oss_key_)); + ASSERT_EQ(OB_SUCCESS, + databuff_printf( + storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_)); const ObString storage_info(storage_infos); const char *dir_name = "test/pkeys"; char test_content[OB_MAX_URI_LENGTH] = "just_for_test"; @@ -88,7 +89,14 @@ TEST_F(TestStorageOss, test_get_pkey_from_path) const ObPartitionKey pkey(1100611139403779, 0, 0); ObArray pkeys; - ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/%s/%lu/%ld/test_file", test_oss_bucket_, dir_name, pkey.get_table_id(), pkey.get_partition_id())); + ASSERT_EQ(OB_SUCCESS, + databuff_printf(uri, + sizeof(uri), + "%s/%s/%lu/%ld/test_file", + test_oss_bucket_, + dir_name, + pkey.get_table_id(), + pkey.get_partition_id())); ASSERT_EQ(OB_SUCCESS, databuff_printf(dir_uri, sizeof(dir_uri), "%s/%s/", test_oss_bucket_, dir_name)); STORAGE_LOG(INFO, "uri and dir uri", K(uri), K(dir_uri)); @@ -114,8 +122,9 @@ TEST_F(TestStorageOss, test_get_bucket_lifecycle) ObArenaAllocator allocator; bool is_set_lifecycle = false; - ASSERT_EQ(OB_SUCCESS, databuff_printf(storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", - oss_host_, oss_id_, oss_key_)); + ASSERT_EQ(OB_SUCCESS, + databuff_printf( + storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_)); const ObString storage_info(storage_infos); ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/xuanyi_61/hahaha", test_oss_bucket_)); @@ -123,7 +132,66 @@ TEST_F(TestStorageOss, test_get_bucket_lifecycle) ASSERT_EQ(true, is_set_lifecycle); } +TEST_F(TestStorageOss, test_get_pkey_from_path) +{ + ObStorageUtil util(false); + char uri[OB_MAX_URI_LENGTH]; + char dir_uri[OB_MAX_URI_LENGTH]; + char storage_infos[OB_MAX_URI_LENGTH]; + ObArenaAllocator allocator; + + ASSERT_EQ(OB_SUCCESS, + databuff_printf( + storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_)); + const ObString storage_info(storage_infos); + const char *dir_name = "test/pkeys"; + char test_content[OB_MAX_URI_LENGTH] = "just_for_test"; + int64_t read_size = 0; + const ObPartitionKey pkey(1100611139403779, 0, 0); + ObArray pkeys; + ASSERT_EQ(OB_SUCCESS, + databuff_printf(uri, + sizeof(uri), + "%s/%s/%lu/%ld/test_file", + test_oss_bucket_, + dir_name, + pkey.get_table_id(), + pkey.get_partition_id())); + ASSERT_EQ(OB_SUCCESS, databuff_printf(dir_uri, sizeof(dir_uri), "%s/%s/", test_oss_bucket_, dir_name)); + STORAGE_LOG(INFO, "uri and dir uri", K(uri), K(dir_uri)); + + ASSERT_EQ(OB_SUCCESS, util.write_single_file(uri, storage_info, test_content, 0)); + ASSERT_EQ(OB_SUCCESS, util.get_file_length(uri, storage_info, read_size)); + ASSERT_EQ(OB_SUCCESS, util.get_pkeys_from_dir(dir_uri, storage_info, pkeys)); + ASSERT_TRUE(!pkeys.empty()); + bool found = false; + for (int64_t i = 0; pkeys.count() && !found; ++i) { + const ObPartitionKey &tmp_pkey = pkeys.at(i); + if (tmp_pkey == pkey) { + found = true; + } + } + ASSERT_TRUE(found); +} + +TEST_F(TestStorageOss, test_get_bucket_lifecycle) +{ + ObStorageUtil util(false); + char uri[OB_MAX_URI_LENGTH]; + char storage_infos[OB_MAX_URI_LENGTH]; + ObArenaAllocator allocator; + bool is_set_lifecycle = false; + + ASSERT_EQ(OB_SUCCESS, + databuff_printf( + storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_)); + const ObString storage_info(storage_infos); + ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/xuanyi_61/hahaha", test_oss_bucket_)); + + ASSERT_EQ(OB_SUCCESS, util.check_bucket_lifecycle(uri, storage_info, is_set_lifecycle)); + ASSERT_EQ(true, is_set_lifecycle); +} int main(int argc, char **argv) { diff --git a/src/observer/ob_server_reload_config.cpp b/src/observer/ob_server_reload_config.cpp index a5d0d1692eb2a3531f0615c41f872625d65c40e5..8ab051630fe37cd2921cb6c43e7928eeb844f133 100644 --- a/src/observer/ob_server_reload_config.cpp +++ b/src/observer/ob_server_reload_config.cpp @@ -207,6 +207,74 @@ int ObServerReloadConfig::operator()() } } + // backup zone and region support + { + ObString backup_zone_str = GCONF.backup_zone.get_value_string(); + ObString backup_region_str = GCONF.backup_region.get_value_string(); + + bool prev_io_stat = ObStorageGlobalIns::get_instance().is_io_prohibited(); + bool prohibited = true; + LOG_INFO("backup zone and region", K(backup_zone_str), K(backup_region_str)); + + if (backup_zone_str.empty() && backup_region_str.empty()) { + // Both backup region and zone are not set, IO operation is allowed. + prohibited = false; + } else if (!backup_zone_str.empty() && !backup_region_str.empty()) { + // Both backup region and zone exist, not allowed, something wrong unexpected. + ret = OB_ERR_UNEXPECTED; + LOG_WARN("backup region and zone both are set, which are unexpected.", K(ret), K(backup_zone_str), K(backup_region_str)); + } else if (!backup_zone_str.empty()) { + // Backup zone is set. + ObArray backup_zone; + if (OB_FAIL(ObBackupUtils::parse_backup_format_input(backup_zone_str, MAX_ZONE_LENGTH, backup_zone))) { + LOG_WARN("failed to parse backup zone format", K(ret), K(backup_zone_str)); + } else if (backup_zone.empty()) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("backup zone is empty", K(ret), K(backup_zone_str)); + } else { + const ObZone zone = GCONF.zone.str(); + LOG_INFO("set backup zone", K(zone), K(backup_zone_str), K(backup_zone)); + for (int64_t i = 0; i < backup_zone.count(); i++) { + // I am in black list, IO operations are allowed. + if (zone == backup_zone[i].zone_) { + prohibited = false; + break; + } + } + } + } else { + // Backup region is set. + ObArray backup_region; + ObRegion region; + if (OB_FAIL(ObBackupUtils::parse_backup_format_input(backup_region_str, MAX_REGION_LENGTH, backup_region))) { + LOG_WARN("failed to parse backup region format", K(ret), K(backup_region_str)); + } else if (backup_region.empty()) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("backup region is empty", K(ret), K(backup_region_str)); + } else if (OB_FAIL(ObServer::get_instance().get_partition_service().get_locality_manager()->load_region())) { + LOG_WARN("get local region failed", K(ret), K(backup_region_str)); + } else if (OB_FAIL(ObServer::get_instance().get_partition_service().get_locality_manager()->get_local_region(region))) { + LOG_WARN("get local region failed", K(ret), K(backup_region_str)); + } else { + LOG_INFO("set backup region", K(region), K(backup_region_str), K(backup_region)); + for (int64_t i = 0; i < backup_region.count(); i++) { + // I am in black list, IO operations are allowed. + if (region == backup_region[i].region_) { + prohibited = false; + break; + } + } + } + } + + if (OB_SUCC(ret) && prev_io_stat != prohibited) { + ObStorageGlobalIns::get_instance().set_io_prohibited(prohibited); + if (prev_io_stat != prohibited) { + FLOG_WARN("backup set_io_prohibited", K(ret), K(prohibited), K(prev_io_stat)); + } + } + } + const int64_t cache_size = GCONF.memory_chunk_cache_size; const int cache_cnt = cache_size > 0 ? cache_size / INTACT_ACHUNK_SIZE : INT32_MAX; lib::AChunkMgr::instance().set_max_chunk_cache_cnt(cache_cnt); diff --git a/src/observer/ob_service.cpp b/src/observer/ob_service.cpp index f4aaf891a7d4da4f8c7602953d7cabc30a1b42cd..71acfbb3274ff0f62051df38da1c93753f226bd9 100644 --- a/src/observer/ob_service.cpp +++ b/src/observer/ob_service.cpp @@ -1916,7 +1916,18 @@ int ObService::migrate_replica_batch(const obrpc::ObMigrateReplicaBatchArg& arg) int ObService::standby_cutdata_batch_task(const obrpc::ObStandbyCutDataBatchTaskArg& arg) { int ret = OB_SUCCESS; - LOG_INFO("receive standby_cutdata_batch_task request", K(arg)); + LOG_INFO("receive standby cut data batch request", K(arg)); + if (!inited_) { + ret = OB_NOT_INIT; + LOG_WARN("ObService not init", K(ret)); + } else if (!arg.is_valid()) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid arg", K(arg), K(ret)); + } else if (OB_FAIL(gctx_.par_ser_->standby_cut_data_batch(arg))) { + LOG_WARN("add migrate batch fail", K(arg), K(ret)); + } else { + LOG_INFO("standby cut data batch successfully", K(arg)); + } return ret; } @@ -3728,3 +3739,4 @@ int ObService::broadcast_locations(const obrpc::ObPartitionBroadcastArg& arg, ob } // end namespace observer } // end namespace oceanbase + diff --git a/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp b/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp index 63ba543267875eb432283ee3d4d11223fba0776d..ea1ae25da3ff1ae957268ffb8184e55bc8c60987 100644 --- a/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp +++ b/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp @@ -104,7 +104,7 @@ bool ObLogArchiveRound::is_valid() const copy_id_ >= 0 && piece_infos_.count() >= 0 && copies_num_ >= 0; } -int ObLogArchiveRound::add_simpe_piece_info(const ObSimplePieceInfo& piece_info) +int ObLogArchiveRound::add_simpe_piece_info(const ObSimplePieceInfo &piece_info) { int ret = OB_SUCCESS; if (!piece_info.is_valid()) { @@ -116,7 +116,7 @@ int ObLogArchiveRound::add_simpe_piece_info(const ObSimplePieceInfo& piece_info) return ret; } -int ObLogArchiveRound::assign(const ObLogArchiveRound& log_archive_round) +int ObLogArchiveRound::assign(const ObLogArchiveRound &log_archive_round) { int ret = OB_SUCCESS; if (!log_archive_round.is_valid()) { @@ -129,6 +129,7 @@ int ObLogArchiveRound::assign(const ObLogArchiveRound& log_archive_round) checkpoint_ts_ = log_archive_round.checkpoint_ts_; start_piece_id_ = log_archive_round.start_piece_id_; copy_id_ = log_archive_round.copy_id_; + copies_num_ = log_archive_round.copies_num_; if (OB_FAIL(piece_infos_.assign(log_archive_round.piece_infos_))) { LOG_WARN("failed to assign piece infos", K(ret), K(log_archive_round)); } @@ -152,12 +153,12 @@ void ObBackupDataCleanElement::reset() } bool ObBackupDataCleanElement::is_same_element( - const int64_t cluster_id, const int64_t incarnation, const ObBackupDest& backup_dest) const + const int64_t cluster_id, const int64_t incarnation, const ObBackupDest &backup_dest) const { return cluster_id_ == cluster_id && incarnation_ == incarnation && backup_dest_ == backup_dest; } -int ObBackupDataCleanElement::set_backup_set_id(const ObBackupSetId& backup_set_id) +int ObBackupDataCleanElement::set_backup_set_id(const ObBackupSetId &backup_set_id) { int ret = OB_SUCCESS; if (!is_valid()) { @@ -172,7 +173,7 @@ int ObBackupDataCleanElement::set_backup_set_id(const ObBackupSetId& backup_set_ return ret; } -int ObBackupDataCleanElement::set_log_archive_round(const ObLogArchiveRound& log_archive_round) +int ObBackupDataCleanElement::set_log_archive_round(const ObLogArchiveRound &log_archive_round) { int ret = OB_SUCCESS; if (!log_archive_round.is_valid()) { @@ -215,8 +216,8 @@ void ObBackupDataCleanTenant::reset() } int ObBackupDataCleanTenant::set_backup_clean_backup_set_id(const int64_t cluster_id, const int64_t incarnation, - const share::ObBackupDest& backup_dest, const ObBackupSetId backup_set_id, - const ObBackupDestOpt& backup_dest_option) + const share::ObBackupDest &backup_dest, const ObBackupSetId backup_set_id, + const ObBackupDestOpt &backup_dest_option) { int ret = OB_SUCCESS; if (!is_valid()) { @@ -235,7 +236,7 @@ int ObBackupDataCleanTenant::set_backup_clean_backup_set_id(const int64_t cluste } else { bool found_same_elemnt = false; for (int64_t i = 0; OB_SUCC(ret) && i < backup_element_array_.count() && !found_same_elemnt; ++i) { - ObBackupDataCleanElement& backup_element = backup_element_array_.at(i); + ObBackupDataCleanElement &backup_element = backup_element_array_.at(i); if (backup_element.is_same_element(cluster_id, incarnation, backup_dest)) { if (OB_FAIL(backup_element.backup_set_id_array_.push_back(backup_set_id))) { LOG_WARN("failed to push backup set id into array", K(ret), K(backup_set_id)); @@ -262,8 +263,8 @@ int ObBackupDataCleanTenant::set_backup_clean_backup_set_id(const int64_t cluste } int ObBackupDataCleanTenant::set_backup_clean_archive_round(const int64_t cluster_id, const int64_t incarnation, - const share::ObBackupDest& backup_dest, const ObLogArchiveRound& archive_round, - const ObBackupDestOpt& backup_dest_option) + const share::ObBackupDest &backup_dest, const ObLogArchiveRound &archive_round, + const ObBackupDestOpt &backup_dest_option) { int ret = OB_SUCCESS; if (!is_valid()) { @@ -282,7 +283,7 @@ int ObBackupDataCleanTenant::set_backup_clean_archive_round(const int64_t cluste } else { bool found_same_elemnt = false; for (int64_t i = 0; OB_SUCC(ret) && i < backup_element_array_.count() && !found_same_elemnt; ++i) { - ObBackupDataCleanElement& backup_element = backup_element_array_.at(i); + ObBackupDataCleanElement &backup_element = backup_element_array_.at(i); if (backup_element.is_same_element(cluster_id, incarnation, backup_dest)) { if (OB_FAIL(backup_element.log_archive_round_array_.push_back(archive_round))) { LOG_WARN("failed to push backup set id into array", K(ret), K(archive_round)); @@ -312,7 +313,7 @@ bool ObBackupDataCleanTenant::has_clean_backup_set(const int64_t backup_set_id, { bool b_ret = false; for (int64_t i = 0; i < backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& backup_element = backup_element_array_.at(i); + const ObBackupDataCleanElement &backup_element = backup_element_array_.at(i); for (int64_t j = 0; j < backup_element.backup_set_id_array_.count(); ++j) { const int64_t tmp_backup_set_id = backup_element.backup_set_id_array_.at(j).backup_set_id_; const int64_t tmp_copy_id = backup_element.backup_set_id_array_.at(j).copy_id_; @@ -348,7 +349,7 @@ void ObBackupDataCleanStatics::reset() deleted_clog_files_ts_ = 0; } -ObBackupDataCleanStatics& ObBackupDataCleanStatics::operator+=(const ObBackupDataCleanStatics& clean_statics) +ObBackupDataCleanStatics &ObBackupDataCleanStatics::operator+=(const ObBackupDataCleanStatics &clean_statics) { touched_base_data_files_ += clean_statics.touched_base_data_files_; deleted_base_data_files_ += clean_statics.deleted_base_data_files_; @@ -361,9 +362,70 @@ ObBackupDataCleanStatics& ObBackupDataCleanStatics::operator+=(const ObBackupDat return *this; } -int ObBackupDataCleanUtil::get_backup_path_info(const ObBackupDest& backup_dest, const int64_t incarnation, +ObSimplePieceKey::ObSimplePieceKey() : incarnation_(0), round_id_(0), backup_piece_id_(0), copy_id_(0) +{} + +void ObSimplePieceKey::reset() +{ + incarnation_ = 0; + round_id_ = 0; + backup_piece_id_ = 0; + copy_id_ = 0; +} + +bool ObSimplePieceKey::is_valid() const +{ + return incarnation_ > 0 && round_id_ > 0 && backup_piece_id_ >= 0 && copy_id_ >= 0; +} + +uint64_t ObSimplePieceKey::hash() const +{ + uint64_t hash_val = 0; + hash_val = murmurhash(&incarnation_, sizeof(incarnation_), hash_val); + hash_val = murmurhash(&round_id_, sizeof(round_id_), hash_val); + hash_val = murmurhash(&backup_piece_id_, sizeof(backup_piece_id_), hash_val); + hash_val = murmurhash(©_id_, sizeof(copy_id_), hash_val); + return hash_val; +} + +bool ObSimplePieceKey::operator==(const ObSimplePieceKey &other) const +{ + return (incarnation_ == other.incarnation_ && round_id_ == other.round_id_ && + backup_piece_id_ == other.backup_piece_id_ && copy_id_ == other.copy_id_); +} + +ObSimpleArchiveRound::ObSimpleArchiveRound() : incarnation_(0), round_id_(0), copy_id_(0) +{} + +void ObSimpleArchiveRound::reset() +{ + incarnation_ = 0; + round_id_ = 0; + copy_id_ = 0; +} + +bool ObSimpleArchiveRound::is_valid() const +{ + return incarnation_ > 0 && round_id_ > 0 && copy_id_ >= 0; +} + +uint64_t ObSimpleArchiveRound::hash() const +{ + uint64_t hash_val = 0; + hash_val = murmurhash(&incarnation_, sizeof(incarnation_), hash_val); + hash_val = murmurhash(&round_id_, sizeof(round_id_), hash_val); + hash_val = murmurhash(©_id_, sizeof(copy_id_), hash_val); + return hash_val; +} + +bool ObSimpleArchiveRound::operator==(const ObSimpleArchiveRound &other) const +{ + return (incarnation_ == other.incarnation_ && round_id_ == other.round_id_ && copy_id_ == other.copy_id_); +} + +int ObBackupDataCleanUtil::get_backup_path_info(const ObBackupDest &backup_dest, const int64_t incarnation, const uint64_t tenant_id, const int64_t full_backup_set_id, const int64_t inc_backup_set_id, - const int64_t backup_date, const int64_t compatible, ObBackupBaseDataPathInfo& path_info) + const int64_t backup_date, const int64_t compatible, ObBackupBaseDataPathInfo &path_info) { int ret = OB_SUCCESS; if (!backup_dest.is_valid() || incarnation <= 0 || OB_INVALID_ID == tenant_id || full_backup_set_id <= 0 || @@ -390,9 +452,9 @@ int ObBackupDataCleanUtil::get_backup_path_info(const ObBackupDest& backup_dest, return ret; } -int ObBackupDataCleanUtil::touch_backup_dir_files(const ObBackupPath& path, const char* storage_info, - const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service) +int ObBackupDataCleanUtil::touch_backup_dir_files(const ObBackupPath &path, const char *storage_info, + const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::BACKUP); @@ -408,7 +470,7 @@ int ObBackupDataCleanUtil::touch_backup_dir_files(const ObBackupPath& path, cons LOG_WARN("failed to list files", K(ret), K(path)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < index_file_names.count(); ++i) { - const ObString& file_name = index_file_names.at(i); + const ObString &file_name = index_file_names.at(i); ObBackupPath tmp_path = path; if (OB_FAIL(lease_service.check_lease())) { LOG_WARN("failed to check lease", K(ret)); @@ -424,9 +486,9 @@ int ObBackupDataCleanUtil::touch_backup_dir_files(const ObBackupPath& path, cons return ret; } -int ObBackupDataCleanUtil::delete_backup_dir_files(const ObBackupPath& path, const char* storage_info, - const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service) +int ObBackupDataCleanUtil::delete_backup_dir_files(const ObBackupPath &path, const char *storage_info, + const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::BACKUP); @@ -440,7 +502,7 @@ int ObBackupDataCleanUtil::delete_backup_dir_files(const ObBackupPath& path, con LOG_WARN("failed to list files", K(ret), K(path)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < index_file_names.count(); ++i) { - const ObString& file_name = index_file_names.at(i); + const ObString &file_name = index_file_names.at(i); ObBackupPath tmp_path = path; if (OB_FAIL(lease_service.check_lease())) { LOG_WARN("failed to check lease", K(ret)); @@ -462,9 +524,9 @@ int ObBackupDataCleanUtil::delete_backup_dir_files(const ObBackupPath& path, con return ret; } -int ObBackupDataCleanUtil::touch_clog_dir_files(const ObBackupPath& path, const char* storage_info, - const uint64_t file_id, const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service, bool& has_remaining_files) +int ObBackupDataCleanUtil::touch_clog_dir_files(const ObBackupPath &path, const char *storage_info, + const uint64_t file_id, const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service, bool &has_remaining_files) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::BACKUP); @@ -485,7 +547,7 @@ int ObBackupDataCleanUtil::touch_clog_dir_files(const ObBackupPath& path, const has_remaining_files = false; } else { for (int64_t i = 0; OB_SUCC(ret) && i < index_file_names.count(); ++i) { - const ObString& file_name = index_file_names.at(i); + const ObString &file_name = index_file_names.at(i); tmp_file_id = 0; if (OB_FAIL(lease_service.check_lease())) { LOG_WARN("failed to check lease", K(ret)); @@ -513,9 +575,9 @@ int ObBackupDataCleanUtil::touch_clog_dir_files(const ObBackupPath& path, const return ret; } -int ObBackupDataCleanUtil::delete_clog_dir_files(const ObBackupPath& path, const char* storage_info, - const uint64_t file_id, const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service, bool& has_remaning_files) +int ObBackupDataCleanUtil::delete_clog_dir_files(const ObBackupPath &path, const char *storage_info, + const uint64_t file_id, const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service, bool &has_remaning_files) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::BACKUP); @@ -536,7 +598,7 @@ int ObBackupDataCleanUtil::delete_clog_dir_files(const ObBackupPath& path, const has_remaning_files = false; } else { for (int64_t i = 0; OB_SUCC(ret) && i < data_file_names.count(); ++i) { - const ObString& file_name = data_file_names.at(i); + const ObString &file_name = data_file_names.at(i); tmp_file_id = 0; if (OB_FAIL(lease_service.check_lease())) { LOG_WARN("failed to check lease", K(ret)); @@ -570,7 +632,7 @@ int ObBackupDataCleanUtil::delete_clog_dir_files(const ObBackupPath& path, const } int ObBackupDataCleanUtil::delete_backup_dir( - const ObBackupPath& path, const char* storage_info, const common::ObStorageType& device_type) + const ObBackupPath &path, const char *storage_info, const common::ObStorageType &device_type) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::BACKUP); @@ -589,7 +651,7 @@ int ObBackupDataCleanUtil::delete_backup_dir( } int ObBackupDataCleanUtil::delete_backup_file( - const ObBackupPath& path, const char* storage_info, const common::ObStorageType& device_type) + const ObBackupPath &path, const char *storage_info, const common::ObStorageType &device_type) { int ret = OB_SUCCESS; ObStorageUtil util(false /*need_retry*/); @@ -609,7 +671,7 @@ int ObBackupDataCleanUtil::delete_backup_file( } int ObBackupDataCleanUtil::touch_backup_file( - const ObBackupPath& path, const char* storage_info, const common::ObStorageType& device_type) + const ObBackupPath &path, const char *storage_info, const common::ObStorageType &device_type) { int ret = OB_SUCCESS; ObStorageUtil util(false /*need_retry*/); @@ -628,7 +690,7 @@ int ObBackupDataCleanUtil::touch_backup_file( return ret; } -int ObBackupDataCleanUtil::get_file_id(const ObString& file_name, int64_t& file_id) +int ObBackupDataCleanUtil::get_file_id(const ObString &file_name, int64_t &file_id) { int ret = OB_SUCCESS; file_id = 0 == file_name.length() ? -1 : 0; @@ -643,7 +705,7 @@ int ObBackupDataCleanUtil::get_file_id(const ObString& file_name, int64_t& file_ return ret; } -int ObBackupDataCleanUtil::delete_tmp_files(const ObBackupPath& path, const char* storage_info) +int ObBackupDataCleanUtil::delete_tmp_files(const ObBackupPath &path, const char *storage_info) { int ret = OB_SUCCESS; ObStorageUtil util(false /*need_retry*/); @@ -660,7 +722,7 @@ int ObBackupDataCleanUtil::delete_tmp_files(const ObBackupPath& path, const char } void ObBackupDataCleanUtil::check_need_retry( - const int64_t result, int64_t& retry_count, int64_t& io_limit_retry_count, bool& need_retry) + const int64_t result, int64_t &retry_count, int64_t &io_limit_retry_count, bool &need_retry) { need_retry = true; if (OB_SUCCESS == result) { @@ -683,8 +745,8 @@ ObTenantBackupDataCleanMgr::ObTenantBackupDataCleanMgr() ObTenantBackupDataCleanMgr::~ObTenantBackupDataCleanMgr() {} -int ObTenantBackupDataCleanMgr::init(const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant, - ObBackupDataClean* data_clean, common::ObMySQLProxy* sql_proxy) +int ObTenantBackupDataCleanMgr::init(const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant, + ObBackupDataClean *data_clean, common::ObMySQLProxy *sql_proxy) { int ret = OB_SUCCESS; if (is_inited_) { @@ -754,7 +816,7 @@ ObTenantBackupBaseDataCleanTask::ObTenantBackupBaseDataCleanTask() ObTenantBackupBaseDataCleanTask::~ObTenantBackupBaseDataCleanTask() {} -int ObTenantBackupBaseDataCleanTask::init(const ObBackupDataCleanTenant& clean_tenant, ObBackupDataClean* data_clean) +int ObTenantBackupBaseDataCleanTask::init(const ObBackupDataCleanTenant &clean_tenant, ObBackupDataClean *data_clean) { int ret = OB_SUCCESS; if (is_inited_) { @@ -782,8 +844,8 @@ int ObTenantBackupBaseDataCleanTask::do_clean() LOG_WARN("tenant backup base data clean task do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant_.backup_element_array_.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = clean_tenant_.simple_clean_tenant_; - const ObBackupDataCleanElement& backup_clean_element = clean_tenant_.backup_element_array_.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = clean_tenant_.simple_clean_tenant_; + const ObBackupDataCleanElement &backup_clean_element = clean_tenant_.backup_element_array_.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (OB_FAIL(do_inner_clean(simple_clean_tenant, backup_clean_element))) { @@ -801,7 +863,7 @@ int ObTenantBackupBaseDataCleanTask::do_clean() } int ObTenantBackupBaseDataCleanTask::do_inner_clean( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObBackupDataCleanElement& clean_element) + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObBackupDataCleanElement &clean_element) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -813,7 +875,7 @@ int ObTenantBackupBaseDataCleanTask::do_inner_clean( } else { // should be low backup set to high backup set for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.backup_set_id_array_.count(); ++i) { - const ObBackupSetId& backup_set_id = clean_element.backup_set_id_array_.at(i); + const ObBackupSetId &backup_set_id = clean_element.backup_set_id_array_.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (OB_FAIL(clean_backup_data(simple_clean_tenant, clean_element, backup_set_id))) { @@ -824,8 +886,8 @@ int ObTenantBackupBaseDataCleanTask::do_inner_clean( return ret; } -int ObTenantBackupBaseDataCleanTask::clean_backup_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id) +int ObTenantBackupBaseDataCleanTask::clean_backup_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id) { int ret = OB_SUCCESS; ObArray extern_backup_infos; @@ -840,7 +902,7 @@ int ObTenantBackupBaseDataCleanTask::clean_backup_data(const ObSimpleBackupDataC LOG_INFO("get extern backup infos", K(extern_backup_infos), K(backup_set_id)); for (int64_t i = 0; OB_SUCC(ret) && i < extern_backup_infos.count(); ++i) { - const ObExternBackupInfo& backup_info = extern_backup_infos.at(i); + const ObExternBackupInfo &backup_info = extern_backup_infos.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (OB_FAIL(clean_backp_set(simple_clean_tenant, clean_element, backup_set_id, backup_info))) { @@ -854,9 +916,9 @@ int ObTenantBackupBaseDataCleanTask::clean_backup_data(const ObSimpleBackupDataC return ret; } -int ObTenantBackupBaseDataCleanTask::clean_backp_set(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info) +int ObTenantBackupBaseDataCleanTask::clean_backp_set(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObArray meta_index_array; @@ -923,9 +985,9 @@ int ObTenantBackupBaseDataCleanTask::clean_backp_set(const ObSimpleBackupDataCle return ret; } -int ObTenantBackupBaseDataCleanTask::get_tenant_backup_infos(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - common::ObIArray& extern_backup_infos) +int ObTenantBackupBaseDataCleanTask::get_tenant_backup_infos(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + common::ObIArray &extern_backup_infos) { int ret = OB_SUCCESS; ObExternBackupInfoMgr extern_backup_info_mgr; @@ -945,9 +1007,9 @@ int ObTenantBackupBaseDataCleanTask::get_tenant_backup_infos(const ObSimpleBacku return ret; } -int ObTenantBackupBaseDataCleanTask::clean_backup_set_meta(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info) +int ObTenantBackupBaseDataCleanTask::clean_backup_set_meta(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObBackupBaseDataPathInfo path_info; @@ -955,9 +1017,9 @@ int ObTenantBackupBaseDataCleanTask::clean_backup_set_meta(const ObSimpleBackupD const int64_t full_backup_set_id = extern_backup_info.full_backup_set_id_; const int64_t inc_backup_set_id = extern_backup_info.inc_backup_set_id_; const uint64_t tenant_id = simple_clean_tenant.tenant_id_; - const ObBackupDest& backup_dest = clean_element.backup_dest_; + const ObBackupDest &backup_dest = clean_element.backup_dest_; const int64_t incarnation = clean_element.incarnation_; - const char* storage_info = clean_element.backup_dest_.storage_info_; + const char *storage_info = clean_element.backup_dest_.storage_info_; const int64_t backup_date = extern_backup_info.date_; const int64_t compatible = extern_backup_info.compatible_; ObClusterBackupDest cluster_backup_dest; @@ -994,10 +1056,10 @@ int ObTenantBackupBaseDataCleanTask::clean_backup_set_meta(const ObSimpleBackupD } int ObTenantBackupBaseDataCleanTask::touch_backup_set_meta( - const ObBackupDataCleanElement& clean_element, const ObBackupPath& path) + const ObBackupDataCleanElement &clean_element, const ObBackupPath &path) { int ret = OB_SUCCESS; - const char* storage_info = clean_element.backup_dest_.storage_info_; + const char *storage_info = clean_element.backup_dest_.storage_info_; const ObStorageType device_type = clean_element.backup_dest_.device_type_; if (!is_inited_) { @@ -1011,10 +1073,10 @@ int ObTenantBackupBaseDataCleanTask::touch_backup_set_meta( } int ObTenantBackupBaseDataCleanTask::delete_backup_set_meta( - const ObBackupDataCleanElement& clean_element, const ObBackupPath& path) + const ObBackupDataCleanElement &clean_element, const ObBackupPath &path) { int ret = OB_SUCCESS; - const char* storage_info = clean_element.backup_dest_.storage_info_; + const char *storage_info = clean_element.backup_dest_.storage_info_; const ObStorageType device_type = clean_element.backup_dest_.device_type_; if (!is_inited_) { @@ -1028,7 +1090,7 @@ int ObTenantBackupBaseDataCleanTask::delete_backup_set_meta( } int ObTenantBackupBaseDataCleanTask::get_table_id_list( - const storage::ObPhyRestoreMetaIndexStore::MetaIndexMap& meta_index_map, hash::ObHashSet& table_id_set) + const storage::ObPhyRestoreMetaIndexStore::MetaIndexMap &meta_index_map, hash::ObHashSet &table_id_set) { int ret = OB_SUCCESS; const int overwrite_key = 1; @@ -1038,7 +1100,7 @@ int ObTenantBackupBaseDataCleanTask::get_table_id_list( } else { storage::ObPhyRestoreMetaIndexStore::MetaIndexMap::const_iterator iter; for (iter = meta_index_map.begin(); OB_SUCC(ret) && iter != meta_index_map.end(); ++iter) { - const ObMetaIndexKey& meta_index_key = iter->first; + const ObMetaIndexKey &meta_index_key = iter->first; const int64_t table_id = meta_index_key.table_id_; if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); @@ -1053,8 +1115,8 @@ int ObTenantBackupBaseDataCleanTask::get_table_id_list( } int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_dir(const uint64_t tenant_id, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info) + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1074,8 +1136,8 @@ int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_dir(const uint64_t ten } int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_data_dir(const uint64_t tenant_id, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info) + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObBackupBaseDataPathInfo path_info; @@ -1084,10 +1146,10 @@ int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_data_dir(const uint64_ const int64_t inc_backup_set_id = extern_backup_info.inc_backup_set_id_; const int64_t backup_date = extern_backup_info.date_; const int64_t compatible = extern_backup_info.compatible_; - const ObBackupDest& backup_dest = clean_element.backup_dest_; + const ObBackupDest &backup_dest = clean_element.backup_dest_; const int64_t incarnation = clean_element.incarnation_; - const char* storage_info = clean_element.backup_dest_.storage_info_; - const ObStorageType& device_type = clean_element.backup_dest_.device_type_; + const char *storage_info = clean_element.backup_dest_.storage_info_; + const ObStorageType &device_type = clean_element.backup_dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1114,8 +1176,8 @@ int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_data_dir(const uint64_ } int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_info(const uint64_t tenant_id, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info) + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObClusterBackupDest backup_dest; @@ -1182,8 +1244,8 @@ int ObTenantBackupBaseDataCleanTask::try_clean_backup_set_info(const uint64_t te } int ObTenantBackupBaseDataCleanTask::try_clean_full_backup_set_dir(const uint64_t tenant_id, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info) + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObBackupBaseDataPathInfo path_info; @@ -1192,10 +1254,10 @@ int ObTenantBackupBaseDataCleanTask::try_clean_full_backup_set_dir(const uint64_ const int64_t inc_backup_set_id = extern_backup_info.inc_backup_set_id_; const int64_t backup_date = extern_backup_info.date_; const int64_t compatible = extern_backup_info.compatible_; - const ObBackupDest& backup_dest = clean_element.backup_dest_; + const ObBackupDest &backup_dest = clean_element.backup_dest_; const int64_t incarnation = clean_element.incarnation_; - const char* storage_info = clean_element.backup_dest_.storage_info_; - const ObStorageType& device_type = clean_element.backup_dest_.device_type_; + const char *storage_info = clean_element.backup_dest_.storage_info_; + const ObStorageType &device_type = clean_element.backup_dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1219,7 +1281,7 @@ int ObTenantBackupBaseDataCleanTask::try_clean_full_backup_set_dir(const uint64_ return ret; } -int ObTenantBackupBaseDataCleanTask::get_clean_statics(ObBackupDataCleanStatics& clean_statics) +int ObTenantBackupBaseDataCleanTask::get_clean_statics(ObBackupDataCleanStatics &clean_statics) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1238,8 +1300,8 @@ ObTenantBackupClogDataCleanTask::ObTenantBackupClogDataCleanTask() ObTenantBackupClogDataCleanTask::~ObTenantBackupClogDataCleanTask() {} -int ObTenantBackupClogDataCleanTask::init(const ObBackupCleanInfo& clean_info, - const ObBackupDataCleanTenant& clean_tenant, ObBackupDataClean* data_clean, common::ObMySQLProxy* sql_proxy) +int ObTenantBackupClogDataCleanTask::init(const ObBackupCleanInfo &clean_info, + const ObBackupDataCleanTenant &clean_tenant, ObBackupDataClean *data_clean, common::ObMySQLProxy *sql_proxy) { int ret = OB_SUCCESS; if (is_inited_) { @@ -1283,9 +1345,9 @@ int ObTenantBackupClogDataCleanTask::do_clean() if (OB_FAIL(ret)) { } else { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = clean_tenant_.simple_clean_tenant_; + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = clean_tenant_.simple_clean_tenant_; for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant_.backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& backup_clean_element = clean_tenant_.backup_element_array_.at(i); + const ObBackupDataCleanElement &backup_clean_element = clean_tenant_.backup_element_array_.at(i); pkey_set_.reuse(); if (OB_FAIL(data_clean_->check_can_do_task())) { @@ -1309,8 +1371,8 @@ int ObTenantBackupClogDataCleanTask::do_clean() return ret; } -int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const int64_t start_replay_log_ts) +int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const int64_t start_replay_log_ts) { int ret = OB_SUCCESS; ObBackupListDataMgr list_data_mgr; @@ -1327,7 +1389,7 @@ int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataClea LOG_WARN("failed to set cluster backup destt", K(ret), K(clean_element)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) { - const ObLogArchiveRound& log_archive_round = clean_element.log_archive_round_array_.at(i); + const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (clean_info_.is_delete_backup_set() && 0 != log_archive_round.start_piece_id_) { @@ -1342,8 +1404,8 @@ int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataClea } /*delete it later*/ -int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObTenantBackupTaskInfo& clog_data_clean_point) +int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; // const uint64_t tenant_id = simple_clean_tenant.tenant_id_; @@ -1371,7 +1433,7 @@ int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataClea LOG_WARN("failed ot get base data table id list", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) { - const ObLogArchiveRound& log_archive_round = clean_element.log_archive_round_array_.at(i); + const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (ObLogArchiveStatus::STOP == log_archive_round.log_archive_status_) { @@ -1411,10 +1473,10 @@ int ObTenantBackupClogDataCleanTask::do_inner_clean(const ObSimpleBackupDataClea } /*delete it later*/ -int ObTenantBackupClogDataCleanTask::clean_clog_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObTenantBackupTaskInfo& clog_data_clean_point, - const ObLogArchiveRound& log_archive_round, const common::ObIArray& table_id_array, - ObBackupDataMgr& backup_data_mgr) +int ObTenantBackupClogDataCleanTask::clean_clog_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObTenantBackupTaskInfo &clog_data_clean_point, + const ObLogArchiveRound &log_archive_round, const common::ObIArray &table_id_array, + ObBackupDataMgr &backup_data_mgr) { int ret = OB_SUCCESS; ObArray meta_index_array; @@ -1459,7 +1521,7 @@ int ObTenantBackupClogDataCleanTask::clean_clog_data(const ObSimpleBackupDataCle } /*delete it later*/ -int ObTenantBackupClogDataCleanTask::set_partition_into_set(const ObIArray& meta_index_array) +int ObTenantBackupClogDataCleanTask::set_partition_into_set(const ObIArray &meta_index_array) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1467,7 +1529,7 @@ int ObTenantBackupClogDataCleanTask::set_partition_into_set(const ObIArraycheck_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (OB_FAIL(check_and_delete_clog_data_with_round( @@ -1511,8 +1573,8 @@ int ObTenantBackupClogDataCleanTask::check_and_delete_clog_data( /*delete it later*/ int ObTenantBackupClogDataCleanTask::check_and_delete_clog_data_with_round( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObClusterBackupDest& cluster_backup_dest, - const ObLogArchiveRound& log_archive_round, const int64_t max_clean_clog_snapshot) + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObClusterBackupDest &cluster_backup_dest, + const ObLogArchiveRound &log_archive_round, const int64_t max_clean_clog_snapshot) { int ret = OB_SUCCESS; ObArray pkey_list; @@ -1532,7 +1594,7 @@ int ObTenantBackupClogDataCleanTask::check_and_delete_clog_data_with_round( const int64_t fake_piece_create_date = 0; ObSimplePieceInfo fake_backup_piece_info; for (int64_t i = 0; OB_SUCC(ret) && i < pkey_list.count(); ++i) { - const ObPartitionKey& pkey = pkey_list.at(i); + const ObPartitionKey &pkey = pkey_list.at(i); ObPartitionClogDataCleanMgr clog_data_clean_mgr; archive::ObArchiveClear archive_clear; uint64_t data_file_id = 0; @@ -1576,8 +1638,8 @@ int ObTenantBackupClogDataCleanTask::check_and_delete_clog_data_with_round( } /*delete it later*/ -int ObTenantBackupClogDataCleanTask::get_clog_pkey_list_not_in_base_data(const ObClusterBackupDest& cluster_backup_dest, - const int64_t log_archive_round, const uint64_t tenant_id, common::ObIArray& pkey_list) +int ObTenantBackupClogDataCleanTask::get_clog_pkey_list_not_in_base_data(const ObClusterBackupDest &cluster_backup_dest, + const int64_t log_archive_round, const uint64_t tenant_id, common::ObIArray &pkey_list) { int ret = OB_SUCCESS; ObBackupListDataMgr backup_list_data_mgr; @@ -1596,7 +1658,7 @@ int ObTenantBackupClogDataCleanTask::get_clog_pkey_list_not_in_base_data(const O LOG_WARN("failed to get clog pkey list", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clog_pkey_list.count(); ++i) { - const ObPartitionKey& pkey = clog_pkey_list.at(i); + const ObPartitionKey &pkey = clog_pkey_list.at(i); int hash_ret = pkey_set_.exist_refactored(pkey); if (OB_HASH_NOT_EXIST == hash_ret) { if (OB_FAIL(pkey_list.push_back(pkey))) { @@ -1615,14 +1677,14 @@ int ObTenantBackupClogDataCleanTask::get_clog_pkey_list_not_in_base_data(const O /*delete it later*/ int ObTenantBackupClogDataCleanTask::clean_interrputed_clog_data( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObBackupDataCleanElement& clean_element, - const ObLogArchiveRound& log_archive_round) + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObBackupDataCleanElement &clean_element, + const ObLogArchiveRound &log_archive_round) { int ret = OB_SUCCESS; const uint64_t tenant_id = simple_clean_tenant.tenant_id_; const int64_t round = log_archive_round.log_archive_round_; - const char* storage_info = clean_element.backup_dest_.storage_info_; - const ObStorageType& storage_type = clean_element.backup_dest_.device_type_; + const char *storage_info = clean_element.backup_dest_.storage_info_; + const ObStorageType &storage_type = clean_element.backup_dest_.device_type_; ObClusterBackupDest cluster_backup_dest; ObBackupListDataMgr backup_list_data_mgr; ObArray clog_pkey_list; @@ -1651,7 +1713,7 @@ int ObTenantBackupClogDataCleanTask::clean_interrputed_clog_data( const bool is_backup_backup = false; for (int64_t i = 0; OB_SUCC(ret) && i < clog_pkey_list.count(); ++i) { - const ObPartitionKey& pkey = clog_pkey_list.at(i); + const ObPartitionKey &pkey = clog_pkey_list.at(i); ObPartitionClogDataCleanMgr partition_clog_data_clean_mgr; ObBackupDataCleanStatics clean_statics; if (OB_FAIL(data_clean_->check_can_do_task())) { @@ -1685,9 +1747,9 @@ int ObTenantBackupClogDataCleanTask::clean_interrputed_clog_data( return ret; } -int ObTenantBackupClogDataCleanTask::try_clean_table_clog_data_dir(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const int64_t log_archive_round, const int64_t table_id, const char* storage_info, - const common::ObStorageType& device_type) +int ObTenantBackupClogDataCleanTask::try_clean_table_clog_data_dir(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const int64_t log_archive_round, const int64_t table_id, const char *storage_info, + const common::ObStorageType &device_type) { int ret = OB_SUCCESS; ObBackupPath path; @@ -1716,9 +1778,9 @@ int ObTenantBackupClogDataCleanTask::try_clean_table_clog_data_dir(const ObClust return ret; } -int ObTenantBackupClogDataCleanTask::try_clean_clog_data_dir(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const int64_t log_archive_round, const char* storage_info, - const common::ObStorageType& device_type) +int ObTenantBackupClogDataCleanTask::try_clean_clog_data_dir(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const int64_t log_archive_round, const char *storage_info, + const common::ObStorageType &device_type) { int ret = OB_SUCCESS; ObBackupPath path; @@ -1750,7 +1812,7 @@ int ObTenantBackupClogDataCleanTask::try_clean_clog_data_dir(const ObClusterBack return ret; } -int ObTenantBackupClogDataCleanTask::get_clean_statics(ObBackupDataCleanStatics& clean_statics) +int ObTenantBackupClogDataCleanTask::get_clean_statics(ObBackupDataCleanStatics &clean_statics) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1763,8 +1825,8 @@ int ObTenantBackupClogDataCleanTask::get_clean_statics(ObBackupDataCleanStatics& } int ObTenantBackupClogDataCleanTask::generate_backup_piece_tasks( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObBackupDataCleanElement& clean_element, - const ObLogArchiveRound& log_archive_round, const int64_t start_replay_log_ts) + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObBackupDataCleanElement &clean_element, + const ObLogArchiveRound &log_archive_round, const int64_t start_replay_log_ts) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1772,7 +1834,7 @@ int ObTenantBackupClogDataCleanTask::generate_backup_piece_tasks( LOG_WARN("tenant backup data clean mgr do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_round.piece_infos_.count(); ++i) { - const ObSimplePieceInfo& backup_piece_info = log_archive_round.piece_infos_.at(i); + const ObSimplePieceInfo &backup_piece_info = log_archive_round.piece_infos_.at(i); if (OB_FAIL(generate_backup_piece_pg_tasks( simple_clean_tenant, clean_element, log_archive_round, backup_piece_info, start_replay_log_ts))) { LOG_WARN("failed to generate backup piece pg tasks", @@ -1787,8 +1849,8 @@ int ObTenantBackupClogDataCleanTask::generate_backup_piece_tasks( } int ObTenantBackupClogDataCleanTask::generate_backup_piece_pg_tasks( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObBackupDataCleanElement& clean_element, - const ObLogArchiveRound& log_archive_round, const ObSimplePieceInfo& backup_piece_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObBackupDataCleanElement &clean_element, + const ObLogArchiveRound &log_archive_round, const ObSimplePieceInfo &backup_piece_info, const int64_t start_replay_log_ts) { int ret = OB_SUCCESS; @@ -1813,7 +1875,8 @@ int ObTenantBackupClogDataCleanTask::generate_backup_piece_pg_tasks( } else { delete_clog_mode.mode_ = ObBackupDeleteClogMode::DELETE_BACKUP_PIECE; } - } else if (ObLogArchiveStatus::DOING == log_archive_round.log_archive_status_ && + } else if ((ObLogArchiveStatus::DOING == log_archive_round.log_archive_status_ || + ObLogArchiveStatus::INTERRUPTED == log_archive_round.log_archive_status_) && start_replay_log_ts < log_archive_round.checkpoint_ts_ && start_replay_log_ts > 0 && log_archive_round.copies_num_ >= backup_copies) { delete_clog_mode.mode_ = ObBackupDeleteClogMode::DELETE_ARCHIVE_LOG; @@ -1850,7 +1913,7 @@ int ObTenantBackupClogDataCleanTask::generate_backup_piece_pg_tasks( LOG_WARN("failed to get clog pkey list", K(ret), K(log_archive_round), K(clean_element)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_keys.count(); ++i) { - const ObPartitionKey& pg_key = pg_keys.at(i); + const ObPartitionKey &pg_key = pg_keys.at(i); if (OB_FAIL(generate_backup_piece_pg_delete_task(simple_clean_tenant, clean_element, log_archive_round, @@ -1879,9 +1942,9 @@ int ObTenantBackupClogDataCleanTask::generate_backup_piece_pg_tasks( // is clean is false need touch clog data, so data file id and index file is both 0 int ObTenantBackupClogDataCleanTask::generate_backup_piece_pg_delete_task( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObBackupDataCleanElement& clean_element, - const ObLogArchiveRound& log_archive_round, const ObSimplePieceInfo& backup_piece_info, - const int64_t start_replay_log_ts, const ObPartitionKey& pg_key, const ObBackupDeleteClogMode& delete_clog_mode) + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObBackupDataCleanElement &clean_element, + const ObLogArchiveRound &log_archive_round, const ObSimplePieceInfo &backup_piece_info, + const int64_t start_replay_log_ts, const ObPartitionKey &pg_key, const ObBackupDeleteClogMode &delete_clog_mode) { int ret = OB_SUCCESS; ObPartitionClogDataCleanMgr partition_clog_data_clean_mgr; @@ -1940,10 +2003,10 @@ int ObTenantBackupClogDataCleanTask::generate_backup_piece_pg_delete_task( return ret; } -int ObTenantBackupClogDataCleanTask::get_clog_file_id(const ObClusterBackupDest& backup_dest, - const ObLogArchiveRound& log_archive_round, const ObSimplePieceInfo& backup_piece_info, - const ObBackupDeleteClogMode& delete_clog_mode, const int64_t start_replay_log_ts, const ObPartitionKey& pg_key, - uint64_t& data_file_id, uint64_t& index_file_id) +int ObTenantBackupClogDataCleanTask::get_clog_file_id(const ObClusterBackupDest &backup_dest, + const ObLogArchiveRound &log_archive_round, const ObSimplePieceInfo &backup_piece_info, + const ObBackupDeleteClogMode &delete_clog_mode, const int64_t start_replay_log_ts, const ObPartitionKey &pg_key, + uint64_t &data_file_id, uint64_t &index_file_id) { int ret = OB_SUCCESS; archive::ObArchiveClear archive_clear; @@ -2000,8 +2063,8 @@ int ObTenantBackupClogDataCleanTask::get_clog_file_id(const ObClusterBackupDest& } int ObTenantBackupClogDataCleanTask::handle_archive_key(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const ObBackupDeleteClogMode& delete_clog_mode, const common::ObIArray& pg_keys) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const ObBackupDeleteClogMode &delete_clog_mode, const common::ObIArray &pg_keys) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2029,8 +2092,8 @@ int ObTenantBackupClogDataCleanTask::handle_archive_key(const uint64_t tenant_id } int ObTenantBackupClogDataCleanTask::delete_archive_key(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const common::ObIArray& pg_keys) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const common::ObIArray &pg_keys) { int ret = OB_SUCCESS; ObBackupPath path; @@ -2044,7 +2107,7 @@ int ObTenantBackupClogDataCleanTask::delete_archive_key(const uint64_t tenant_id LOG_WARN("delete archive key get invalid argument", K(ret), K(cluster_backup_dest), K(backup_piece_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_keys.count(); ++i) { - const ObPGKey& pg_key = pg_keys.at(i); + const ObPGKey &pg_key = pg_keys.at(i); path.reset(); if (OB_FAIL(ObBackupPathUtil::get_clog_archive_key_path(cluster_backup_dest, tenant_id, @@ -2079,8 +2142,8 @@ int ObTenantBackupClogDataCleanTask::delete_archive_key(const uint64_t tenant_id } int ObTenantBackupClogDataCleanTask::update_archive_key_timestamp(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const common::ObIArray& pg_keys) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const common::ObIArray &pg_keys) { int ret = OB_SUCCESS; ObBackupPath path; @@ -2094,7 +2157,7 @@ int ObTenantBackupClogDataCleanTask::update_archive_key_timestamp(const uint64_t LOG_WARN("delete archive key get invalid argument", K(ret), K(cluster_backup_dest), K(backup_piece_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_keys.count(); ++i) { - const ObPGKey& pg_key = pg_keys.at(i); + const ObPGKey &pg_key = pg_keys.at(i); path.reset(); if (OB_FAIL(ObBackupPathUtil::get_clog_archive_key_path(cluster_backup_dest, tenant_id, @@ -2114,8 +2177,8 @@ int ObTenantBackupClogDataCleanTask::update_archive_key_timestamp(const uint64_t } int ObTenantBackupClogDataCleanTask::handle_single_piece_info(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const ObBackupDeleteClogMode& delete_clog_mode) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const ObBackupDeleteClogMode &delete_clog_mode) { int ret = OB_SUCCESS; ObBackupPath path; @@ -2152,14 +2215,14 @@ int ObTenantBackupClogDataCleanTask::handle_single_piece_info(const uint64_t ten } int ObTenantBackupClogDataCleanTask::handle_data_and_index_dir(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const ObBackupDeleteClogMode& delete_clog_mode, const common::ObIArray& pg_keys) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const ObBackupDeleteClogMode &delete_clog_mode, const common::ObIArray &pg_keys) { int ret = OB_SUCCESS; ObBackupPath path; hash::ObHashSet table_id_set; const int64_t MAX_BUCKET_NUM = 1024; - const ObStorageType& type = cluster_backup_dest.dest_.device_type_; + const ObStorageType &type = cluster_backup_dest.dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2177,7 +2240,7 @@ int ObTenantBackupClogDataCleanTask::handle_data_and_index_dir(const uint64_t te LOG_WARN("failed to create table id set", K(ret), K(backup_piece_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_keys.count(); ++i) { - const ObPGKey& pg_key = pg_keys.at(i); + const ObPGKey &pg_key = pg_keys.at(i); if (OB_FAIL(table_id_set.set_refactored(pg_key.get_table_id()))) { LOG_WARN("failed to set table id into set", K(ret), K(pg_key)); } @@ -2245,12 +2308,12 @@ int ObTenantBackupClogDataCleanTask::handle_data_and_index_dir(const uint64_t te } int ObTenantBackupClogDataCleanTask::handle_backup_piece_dir(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const ObBackupDeleteClogMode& delete_clog_mode) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const ObBackupDeleteClogMode &delete_clog_mode) { int ret = OB_SUCCESS; ObBackupPath path; - const ObStorageType& type = cluster_backup_dest.dest_.device_type_; + const ObStorageType &type = cluster_backup_dest.dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("tenant backup clog data clean task do not init", K(ret)); @@ -2277,8 +2340,8 @@ int ObTenantBackupClogDataCleanTask::handle_backup_piece_dir(const uint64_t tena } int ObTenantBackupClogDataCleanTask::handle_backup_clog_piece_infos(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const ObBackupDeleteClogMode& delete_clog_mode, const common::ObIArray& pg_keys) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const ObBackupDeleteClogMode &delete_clog_mode, const common::ObIArray &pg_keys) { int ret = OB_SUCCESS; @@ -2318,9 +2381,9 @@ ObTableBaseDataCleanMgr::ObTableBaseDataCleanMgr() ObTableBaseDataCleanMgr::~ObTableBaseDataCleanMgr() {} -int ObTableBaseDataCleanMgr::init(const int64_t table_id, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info, - const common::ObIArray& meta_index_array, ObBackupDataClean& data_clean) +int ObTableBaseDataCleanMgr::init(const int64_t table_id, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info, + const common::ObIArray &meta_index_array, ObBackupDataClean &data_clean) { int ret = OB_SUCCESS; const int64_t full_backup_set_id = extern_backup_info.full_backup_set_id_; @@ -2375,7 +2438,7 @@ int ObTableBaseDataCleanMgr::do_clean() LOG_WARN("tenant data clean mgr do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < meta_index_array_.count(); ++i) { - const ObBackupMetaIndex& meta_index = meta_index_array_.at(i); + const ObBackupMetaIndex &meta_index = meta_index_array_.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (OB_FAIL(clean_partition_backup_data(meta_index))) { @@ -2400,7 +2463,7 @@ int ObTableBaseDataCleanMgr::do_clean() return ret; } -int ObTableBaseDataCleanMgr::clean_partition_backup_data(const ObBackupMetaIndex& meta_index) +int ObTableBaseDataCleanMgr::clean_partition_backup_data(const ObBackupMetaIndex &meta_index) { int ret = OB_SUCCESS; ObPartitionDataCleanMgr partition_data_clean_mgr; @@ -2442,8 +2505,8 @@ int ObTableBaseDataCleanMgr::try_clean_backup_table_dir() { int ret = OB_SUCCESS; ObBackupPath path; - const char* storage_info = clean_element_.backup_dest_.storage_info_; - const ObStorageType& device_type = clean_element_.backup_dest_.device_type_; + const char *storage_info = clean_element_.backup_dest_.storage_info_; + const ObStorageType &device_type = clean_element_.backup_dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2458,7 +2521,7 @@ int ObTableBaseDataCleanMgr::try_clean_backup_table_dir() return ret; } -int ObTableBaseDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics& clean_statics) +int ObTableBaseDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics &clean_statics) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2484,9 +2547,9 @@ ObTableClogDataCleanMgr::ObTableClogDataCleanMgr() ObTableClogDataCleanMgr::~ObTableClogDataCleanMgr() {} -int ObTableClogDataCleanMgr::init(const int64_t table_id, const ObBackupDataCleanElement& clean_element, - const ObLogArchiveRound& log_archive_round, const ObTenantBackupTaskInfo& clog_data_clean_point, - const common::ObIArray& meta_index_array, ObBackupDataClean& data_clean) +int ObTableClogDataCleanMgr::init(const int64_t table_id, const ObBackupDataCleanElement &clean_element, + const ObLogArchiveRound &log_archive_round, const ObTenantBackupTaskInfo &clog_data_clean_point, + const common::ObIArray &meta_index_array, ObBackupDataClean &data_clean) { int ret = OB_SUCCESS; @@ -2530,7 +2593,7 @@ int ObTableClogDataCleanMgr::do_clean() LOG_WARN("table clog data clean mgr do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < meta_index_array_.count(); ++i) { - const ObBackupMetaIndex& meta_index = meta_index_array_.at(i); + const ObBackupMetaIndex &meta_index = meta_index_array_.at(i); if (OB_FAIL(data_clean_->check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); } else if (OB_FAIL(clean_partition_clog_backup_data(meta_index))) { @@ -2557,7 +2620,7 @@ int ObTableClogDataCleanMgr::do_clean() return ret; } -int ObTableClogDataCleanMgr::clean_partition_clog_backup_data(const ObBackupMetaIndex& meta_index) +int ObTableClogDataCleanMgr::clean_partition_clog_backup_data(const ObBackupMetaIndex &meta_index) { int ret = OB_SUCCESS; ObPartitionGroupMeta pg_meta; @@ -2572,7 +2635,7 @@ int ObTableClogDataCleanMgr::clean_partition_clog_backup_data(const ObBackupMeta LOG_WARN("failed to get partition meta", K(ret), K(meta_index)); } else { ObClusterBackupDest cluster_backup_dest; - ObBackupDest& backup_dest = clean_element_.backup_dest_; + ObBackupDest &backup_dest = clean_element_.backup_dest_; const int64_t incarnation = clean_element_.incarnation_; const uint64_t last_replay_log_id = pg_meta.storage_info_.get_clog_info().get_last_replay_log_id(); const ObPartitionKey pkey(meta_index.table_id_, meta_index.partition_id_, 0); @@ -2649,13 +2712,13 @@ int ObTableClogDataCleanMgr::try_clean_backup_table_clog_dir() { int ret = OB_SUCCESS; ObClusterBackupDest cluster_backup_dest; - ObBackupDest& backup_dest = clean_element_.backup_dest_; + ObBackupDest &backup_dest = clean_element_.backup_dest_; const int64_t incarnation = clean_element_.incarnation_; const uint64_t tenant_id = extract_tenant_id(table_id_); const int64_t round = log_archive_round_.log_archive_round_; - const char* storage_info = clean_element_.backup_dest_.storage_info_; - const ObStorageType& device_type = clean_element_.backup_dest_.device_type_; + const char *storage_info = clean_element_.backup_dest_.storage_info_; + const ObStorageType &device_type = clean_element_.backup_dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2669,7 +2732,7 @@ int ObTableClogDataCleanMgr::try_clean_backup_table_clog_dir() return ret; } -int ObTableClogDataCleanMgr::get_partition_meta(const ObBackupMetaIndex& meta_index, ObPartitionGroupMeta& pg_meta) +int ObTableClogDataCleanMgr::get_partition_meta(const ObBackupMetaIndex &meta_index, ObPartitionGroupMeta &pg_meta) { int ret = OB_SUCCESS; pg_meta.reset(); @@ -2704,7 +2767,7 @@ int ObTableClogDataCleanMgr::get_partition_meta(const ObBackupMetaIndex& meta_in return ret; } -int ObTableClogDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics& clean_statics) +int ObTableClogDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics &clean_statics) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2732,9 +2795,9 @@ ObPartitionClogDataCleanMgr::ObPartitionClogDataCleanMgr() ObPartitionClogDataCleanMgr::~ObPartitionClogDataCleanMgr() {} -int ObPartitionClogDataCleanMgr::init(const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const ObPartitionKey& pkey, const uint64_t data_file_id, - const uint64_t index_file_id, const bool is_backup_backup, ObBackupDataClean& data_clean) +int ObPartitionClogDataCleanMgr::init(const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const ObPartitionKey &pkey, const uint64_t data_file_id, + const uint64_t index_file_id, const bool is_backup_backup, ObBackupDataClean &data_clean) { int ret = OB_SUCCESS; if (is_inited_) { @@ -2846,12 +2909,12 @@ int ObPartitionClogDataCleanMgr::clean_clog_backup_data() return ret; } -int ObPartitionClogDataCleanMgr::touch_clog_data_(bool& has_remaing_files) +int ObPartitionClogDataCleanMgr::touch_clog_data_(bool &has_remaing_files) { int ret = OB_SUCCESS; - const char* storage_info = cluster_backup_dest_.get_storage_info(); + const char *storage_info = cluster_backup_dest_.get_storage_info(); const uint64_t tenant_id = pkey_.get_tenant_id(); - const ObStorageType& device = cluster_backup_dest_.dest_.device_type_; + const ObStorageType &device = cluster_backup_dest_.dest_.device_type_; ObBackupPath path; if (!is_inited_) { @@ -2878,12 +2941,12 @@ int ObPartitionClogDataCleanMgr::touch_clog_data_(bool& has_remaing_files) return ret; } -int ObPartitionClogDataCleanMgr::touch_clog_meta_(bool& has_remaing_files) +int ObPartitionClogDataCleanMgr::touch_clog_meta_(bool &has_remaing_files) { int ret = OB_SUCCESS; - const char* storage_info = cluster_backup_dest_.get_storage_info(); + const char *storage_info = cluster_backup_dest_.get_storage_info(); const uint64_t tenant_id = pkey_.get_tenant_id(); - const ObStorageType& device = cluster_backup_dest_.dest_.device_type_; + const ObStorageType &device = cluster_backup_dest_.dest_.device_type_; ObBackupPath path; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2909,12 +2972,12 @@ int ObPartitionClogDataCleanMgr::touch_clog_meta_(bool& has_remaing_files) return ret; } -int ObPartitionClogDataCleanMgr::clean_clog_data_(bool& has_remaing_files) +int ObPartitionClogDataCleanMgr::clean_clog_data_(bool &has_remaing_files) { int ret = OB_SUCCESS; - const char* storage_info = cluster_backup_dest_.get_storage_info(); + const char *storage_info = cluster_backup_dest_.get_storage_info(); const uint64_t tenant_id = pkey_.get_tenant_id(); - const ObStorageType& device = cluster_backup_dest_.dest_.device_type_; + const ObStorageType &device = cluster_backup_dest_.dest_.device_type_; ObBackupPath path; if (!is_inited_) { @@ -2945,13 +3008,13 @@ int ObPartitionClogDataCleanMgr::clean_clog_data_(bool& has_remaing_files) return ret; } -int ObPartitionClogDataCleanMgr::clean_clog_meta_(bool& has_remaing_files) +int ObPartitionClogDataCleanMgr::clean_clog_meta_(bool &has_remaing_files) { int ret = OB_SUCCESS; ObBackupPath path; - const char* storage_info = cluster_backup_dest_.get_storage_info(); + const char *storage_info = cluster_backup_dest_.get_storage_info(); const uint64_t tenant_id = pkey_.get_tenant_id(); - const ObStorageType& device = cluster_backup_dest_.dest_.device_type_; + const ObStorageType &device = cluster_backup_dest_.dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2983,7 +3046,7 @@ int ObPartitionClogDataCleanMgr::clean_clog_meta_(bool& has_remaing_files) // TODO need use schema to check partition exist int ObPartitionClogDataCleanMgr::set_need_delete_clog_dir( - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info) + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info) { int ret = OB_SUCCESS; need_clean_dir_ = false; @@ -2999,7 +3062,7 @@ int ObPartitionClogDataCleanMgr::set_need_delete_clog_dir( return ret; } -int ObPartitionClogDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics& clean_statics) +int ObPartitionClogDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics &clean_statics) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -3079,7 +3142,7 @@ int ObPartitionClogDataCleanMgr::touch_archive_key_(const bool has_remaining_fil return ret; } -int ObPartitionClogDataCleanMgr::check_can_delete_file(bool& can_delete_file) +int ObPartitionClogDataCleanMgr::check_can_delete_file(bool &can_delete_file) { int ret = OB_SUCCESS; can_delete_file = false; @@ -3112,7 +3175,7 @@ int ObPartitionClogDataCleanMgr::check_can_delete_file(bool& can_delete_file) const bool check_dropped_partition = true; bool is_dropped = false; bool is_exist = false; - ObMultiVersionSchemaService* schema_service = NULL; + ObMultiVersionSchemaService *schema_service = NULL; ObSchemaGetterGuard guard; if (NULL == (schema_service = GCTX.schema_service_)) { ret = OB_ERR_UNEXPECTED; @@ -3177,8 +3240,8 @@ ObPartitionDataCleanMgr::ObPartitionDataCleanMgr() ObPartitionDataCleanMgr::~ObPartitionDataCleanMgr() {} -int ObPartitionDataCleanMgr::init(const ObPartitionKey& pkey, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info, ObBackupDataClean& data_clean) +int ObPartitionDataCleanMgr::init(const ObPartitionKey &pkey, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info, ObBackupDataClean &data_clean) { int ret = OB_SUCCESS; const uint64_t tenant_id = pkey.get_tenant_id(); @@ -3311,12 +3374,12 @@ int ObPartitionDataCleanMgr::touch_backup_minor_data() } else if (OB_FAIL(ObBackupPathUtil::get_tenant_pg_minor_dir_path( path_info_, pkey_.get_table_id(), pkey_.get_partition_id(), minor_path))) { STORAGE_LOG(WARN, "failed to get inc backup path", K(ret)); - } else if (OB_FAIL(util.list_files( + } else if (OB_FAIL(util.list_directories( minor_path.get_ptr(), path_info_.dest_.get_storage_info(), allocator, task_id_names))) { LOG_WARN("failed to list files", K(ret), K(minor_path)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < task_id_names.count(); ++i) { - const ObString& task = task_id_names.at(i); + const ObString &task = task_id_names.at(i); task_id = 0; minor_task_path.reset(); if (OB_FAIL(ObBackupDataCleanUtil::get_file_id(task, task_id))) { @@ -3392,7 +3455,7 @@ int ObPartitionDataCleanMgr::clean_backup_minor_data() LOG_WARN("failed to list files", K(ret), K(minor_path)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < task_id_names.count(); ++i) { - const ObString& task = task_id_names.at(i); + const ObString &task = task_id_names.at(i); task_id = 0; minor_task_path.reset(); if (OB_FAIL(ObBackupDataCleanUtil::get_file_id(task, task_id))) { @@ -3415,7 +3478,7 @@ int ObPartitionDataCleanMgr::clean_backup_minor_data() return ret; } -int ObPartitionDataCleanMgr::clean_backup_data_(const ObBackupPath& path) +int ObPartitionDataCleanMgr::clean_backup_data_(const ObBackupPath &path) { int ret = OB_SUCCESS; const ObStorageType device_type = path_info_.dest_.dest_.device_type_; @@ -3435,7 +3498,7 @@ int ObPartitionDataCleanMgr::clean_backup_data_(const ObBackupPath& path) return ret; } -int ObPartitionDataCleanMgr::touch_backup_data_(const ObBackupPath& path) +int ObPartitionDataCleanMgr::touch_backup_data_(const ObBackupPath &path) { int ret = OB_SUCCESS; const ObStorageType device_type = path_info_.dest_.dest_.device_type_; @@ -3455,7 +3518,7 @@ int ObPartitionDataCleanMgr::touch_backup_data_(const ObBackupPath& path) return ret; } -int ObPartitionDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics& clean_statics) +int ObPartitionDataCleanMgr::get_clean_statics(ObBackupDataCleanStatics &clean_statics) { int ret = OB_SUCCESS; if (!is_inited_) { diff --git a/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h b/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h index dec0fd51302bfb493a59b8d8098f774967c2ddda..067d26650cdb5dd64073e312e702382cbd0c3dc0 100644 --- a/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h +++ b/src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h @@ -77,8 +77,8 @@ struct ObLogArchiveRound { virtual ~ObLogArchiveRound() = default; void reset(); bool is_valid() const; - int add_simpe_piece_info(const ObSimplePieceInfo& piece_info); - int assign(const ObLogArchiveRound& log_archvie_round); + int add_simpe_piece_info(const ObSimplePieceInfo &piece_info); + int assign(const ObLogArchiveRound &log_archvie_round); TO_STRING_KV(K_(log_archive_round), K_(log_archive_status), K_(start_ts), K_(checkpoint_ts), K_(start_piece_id), K_(copy_id), K_(piece_infos), K_(copies_num)); @@ -106,9 +106,9 @@ struct ObBackupDataCleanElement { bool is_valid() const; void reset(); bool is_same_element( - const int64_t cluster_id, const int64_t incarnation, const share::ObBackupDest& backup_dest) const; - int set_backup_set_id(const ObBackupSetId& backup_set_id); - int set_log_archive_round(const ObLogArchiveRound& log_archive_round); + const int64_t cluster_id, const int64_t incarnation, const share::ObBackupDest &backup_dest) const; + int set_backup_set_id(const ObBackupSetId &backup_set_id); + int set_log_archive_round(const ObLogArchiveRound &log_archive_round); TO_STRING_KV(K_(cluster_id), K_(incarnation), K_(backup_dest), K_(backup_set_id_array), K_(log_archive_round_array), K_(backup_dest_option)); @@ -143,11 +143,11 @@ struct ObBackupDataCleanTenant { bool is_valid() const; void reset(); int set_backup_clean_backup_set_id(const int64_t cluster_id, const int64_t incarnation, - const share::ObBackupDest& backup_dest, const ObBackupSetId backup_set_id, - const ObBackupDestOpt& backup_dest_option); + const share::ObBackupDest &backup_dest, const ObBackupSetId backup_set_id, + const ObBackupDestOpt &backup_dest_option); int set_backup_clean_archive_round(const int64_t cluster_id, const int64_t incarnation, - const share::ObBackupDest& backup_dest, const ObLogArchiveRound& archive_round, - const ObBackupDestOpt& backup_dest_option); + const share::ObBackupDest &backup_dest, const ObLogArchiveRound &archive_round, + const ObBackupDestOpt &backup_dest_option); bool has_clean_backup_set(const int64_t backup_set_id, const int64_t copy_id) const; TO_STRING_KV(K_(simple_clean_tenant), K_(backup_element_array), K_(clog_data_clean_point), K_(clog_gc_snapshot)); @@ -161,7 +161,7 @@ struct ObBackupDataCleanStatics { ObBackupDataCleanStatics(); virtual ~ObBackupDataCleanStatics() = default; void reset(); - ObBackupDataCleanStatics& operator+=(const ObBackupDataCleanStatics& clean_statics); + ObBackupDataCleanStatics &operator+=(const ObBackupDataCleanStatics &clean_statics); int64_t touched_base_data_files_; int64_t deleted_base_data_files_; @@ -195,49 +195,76 @@ struct ObBackupDeleteClogMode { MODE mode_; }; +struct ObSimplePieceKey final { + ObSimplePieceKey(); + void reset(); + bool is_valid() const; + uint64_t hash() const; + bool operator==(const ObSimplePieceKey &other) const; + + TO_STRING_KV(K_(incarnation), K_(round_id), K_(backup_piece_id), K_(copy_id)); + int64_t incarnation_; + int64_t round_id_; + int64_t backup_piece_id_; + int64_t copy_id_; +}; + +struct ObSimpleArchiveRound final { + ObSimpleArchiveRound(); + void reset(); + bool is_valid() const; + uint64_t hash() const; + bool operator==(const ObSimpleArchiveRound &other) const; + + TO_STRING_KV(K_(incarnation), K_(round_id), K_(copy_id)); + int64_t incarnation_; + int64_t round_id_; + int64_t copy_id_; +}; + class ObBackupDataCleanUtil { public: - static int get_backup_path_info(const ObBackupDest& backup_dest, const int64_t incarnation, const uint64_t tenant_id, + static int get_backup_path_info(const ObBackupDest &backup_dest, const int64_t incarnation, const uint64_t tenant_id, const int64_t full_backup_set_id, const int64_t inc_backup_set_id, const int64_t backup_date, - const int64_t compatible, ObBackupBaseDataPathInfo& path_info); - static int touch_backup_dir_files(const ObBackupPath& path, const char* storage_info, - const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service); - static int delete_backup_dir_files(const ObBackupPath& path, const char* storage_info, - const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service); - static int touch_clog_dir_files(const ObBackupPath& path, const char* storage_info, const uint64_t file_id, - const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service, bool& has_remaining_files); - static int delete_clog_dir_files(const ObBackupPath& path, const char* storage_info, const uint64_t file_id, - const common::ObStorageType& device_type, ObBackupDataCleanStatics& clean_statics, - share::ObIBackupLeaseService& lease_service, bool& has_remaining_files); + const int64_t compatible, ObBackupBaseDataPathInfo &path_info); + static int touch_backup_dir_files(const ObBackupPath &path, const char *storage_info, + const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service); + static int delete_backup_dir_files(const ObBackupPath &path, const char *storage_info, + const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service); + static int touch_clog_dir_files(const ObBackupPath &path, const char *storage_info, const uint64_t file_id, + const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service, bool &has_remaining_files); + static int delete_clog_dir_files(const ObBackupPath &path, const char *storage_info, const uint64_t file_id, + const common::ObStorageType &device_type, ObBackupDataCleanStatics &clean_statics, + share::ObIBackupLeaseService &lease_service, bool &has_remaining_files); static int delete_backup_dir( - const ObBackupPath& path, const char* storage_info, const common::ObStorageType& device_type); + const ObBackupPath &path, const char *storage_info, const common::ObStorageType &device_type); static int delete_backup_file( - const ObBackupPath& path, const char* storage_info, const common::ObStorageType& device_type); + const ObBackupPath &path, const char *storage_info, const common::ObStorageType &device_type); static int touch_backup_file( - const ObBackupPath& path, const char* storage_info, const common::ObStorageType& device_type); - static int delete_tmp_files(const ObBackupPath& path, const char* storage_info); + const ObBackupPath &path, const char *storage_info, const common::ObStorageType &device_type); + static int delete_tmp_files(const ObBackupPath &path, const char *storage_info); static void check_need_retry( - const int64_t result, int64_t& retry_count, int64_t& io_limit_retry_count, bool& need_retry); - static int get_file_id(const ObString& file_name, int64_t& file_id); + const int64_t result, int64_t &retry_count, int64_t &io_limit_retry_count, bool &need_retry); + static int get_file_id(const ObString &file_name, int64_t &file_id); }; class ObTenantBackupDataCleanMgr { public: ObTenantBackupDataCleanMgr(); virtual ~ObTenantBackupDataCleanMgr(); - int init(const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant, - ObBackupDataClean* data_clean, common::ObMySQLProxy* sql_proxy); + int init(const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant, + ObBackupDataClean *data_clean, common::ObMySQLProxy *sql_proxy); int do_clean(); private: bool is_inited_; ObBackupCleanInfo clean_info_; ObBackupDataCleanTenant clean_tenant_; - ObBackupDataClean* data_clean_; - common::ObMySQLProxy* sql_proxy_; + ObBackupDataClean *data_clean_; + common::ObMySQLProxy *sql_proxy_; private: DISALLOW_COPY_AND_ASSIGN(ObTenantBackupDataCleanMgr); @@ -247,45 +274,45 @@ class ObTenantBackupBaseDataCleanTask { public: ObTenantBackupBaseDataCleanTask(); virtual ~ObTenantBackupBaseDataCleanTask(); - int init(const ObBackupDataCleanTenant& clean_tenant, ObBackupDataClean* data_clean); + int init(const ObBackupDataCleanTenant &clean_tenant, ObBackupDataClean *data_clean); int do_clean(); - int get_clean_statics(ObBackupDataCleanStatics& clean_statics); + int get_clean_statics(ObBackupDataCleanStatics &clean_statics); private: int do_inner_clean( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, const ObBackupDataCleanElement& clean_element); - int clean_backup_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id); - int get_tenant_backup_infos(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - ObIArray& extern_backup_infos); - int clean_backp_set(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info); - - int clean_backup_set_meta(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info); - int touch_backup_set_meta(const ObBackupDataCleanElement& clean_element, const ObBackupPath& path); - int delete_backup_set_meta(const ObBackupDataCleanElement& clean_element, const ObBackupPath& path); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, const ObBackupDataCleanElement &clean_element); + int clean_backup_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id); + int get_tenant_backup_infos(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + ObIArray &extern_backup_infos); + int clean_backp_set(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info); + + int clean_backup_set_meta(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info); + int touch_backup_set_meta(const ObBackupDataCleanElement &clean_element, const ObBackupPath &path); + int delete_backup_set_meta(const ObBackupDataCleanElement &clean_element, const ObBackupPath &path); int get_table_id_list( - const storage::ObPhyRestoreMetaIndexStore::MetaIndexMap& index_map, hash::ObHashSet& table_id_set); + const storage::ObPhyRestoreMetaIndexStore::MetaIndexMap &index_map, hash::ObHashSet &table_id_set); // clean backup set - int try_clean_backup_set_dir(const uint64_t tenant_id, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info); - int try_clean_backup_set_info(const uint64_t tenant_id, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info); - int try_clean_backup_set_data_dir(const uint64_t tenant_id, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info); - int try_clean_full_backup_set_dir(const uint64_t tenant_id, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info); + int try_clean_backup_set_dir(const uint64_t tenant_id, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info); + int try_clean_backup_set_info(const uint64_t tenant_id, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info); + int try_clean_backup_set_data_dir(const uint64_t tenant_id, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info); + int try_clean_full_backup_set_dir(const uint64_t tenant_id, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info); private: bool is_inited_; ObBackupDataCleanTenant clean_tenant_; ObBackupDataCleanStatics clean_statics_; - ObBackupDataClean* data_clean_; + ObBackupDataClean *data_clean_; private: DISALLOW_COPY_AND_ASSIGN(ObTenantBackupBaseDataCleanTask); @@ -295,71 +322,71 @@ class ObTenantBackupClogDataCleanTask { public: ObTenantBackupClogDataCleanTask(); virtual ~ObTenantBackupClogDataCleanTask(); - int init(const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant, - ObBackupDataClean* data_clean, common::ObMySQLProxy* sql_proxy); + int init(const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant, + ObBackupDataClean *data_clean, common::ObMySQLProxy *sql_proxy); int do_clean(); - static int try_clean_table_clog_data_dir(const ObClusterBackupDest& backup_dest, const uint64_t tenant_id, - const int64_t log_archive_round, const int64_t table_id, const char* storage_info, - const common::ObStorageType& device_type); - int get_clean_statics(ObBackupDataCleanStatics& clean_statics); + static int try_clean_table_clog_data_dir(const ObClusterBackupDest &backup_dest, const uint64_t tenant_id, + const int64_t log_archive_round, const int64_t table_id, const char *storage_info, + const common::ObStorageType &device_type); + int get_clean_statics(ObBackupDataCleanStatics &clean_statics); private: - int do_inner_clean(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const int64_t start_replay_log_ts); + int do_inner_clean(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const int64_t start_replay_log_ts); // TODO(muwei.ym) delete later // do_inner_clean ~ try_clean_clog_data_dir - int do_inner_clean(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObTenantBackupTaskInfo& clog_data_clean_point); - int clean_clog_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObTenantBackupTaskInfo& clog_data_clean_point, - const ObLogArchiveRound& log_archive_round, const common::ObIArray& table_id_array, - ObBackupDataMgr& backup_data_mgr); - int do_clean_table_clog_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObTenantBackupTaskInfo& clog_data_clean_point, - const ObLogArchiveRound& log_archive_round, const common::ObIArray& table_id, - ObBackupDataMgr& backup_data_mgr); - int set_partition_into_set(const common::ObIArray& meta_index_array); - int check_and_delete_clog_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& backup_clean_element, const int64_t clog_gc_snapshot); - int check_and_delete_clog_data_with_round(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObClusterBackupDest& cluster_backup_dest, const ObLogArchiveRound& log_archive_round, + int do_inner_clean(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObTenantBackupTaskInfo &clog_data_clean_point); + int clean_clog_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObTenantBackupTaskInfo &clog_data_clean_point, + const ObLogArchiveRound &log_archive_round, const common::ObIArray &table_id_array, + ObBackupDataMgr &backup_data_mgr); + int do_clean_table_clog_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObTenantBackupTaskInfo &clog_data_clean_point, + const ObLogArchiveRound &log_archive_round, const common::ObIArray &table_id, + ObBackupDataMgr &backup_data_mgr); + int set_partition_into_set(const common::ObIArray &meta_index_array); + int check_and_delete_clog_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &backup_clean_element, const int64_t clog_gc_snapshot); + int check_and_delete_clog_data_with_round(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObClusterBackupDest &cluster_backup_dest, const ObLogArchiveRound &log_archive_round, const int64_t max_clean_clog_snapshot); - int get_clog_pkey_list_not_in_base_data(const ObClusterBackupDest& cluster_backup_dest, - const int64_t log_archive_round, const uint64_t tenant_id, common::ObIArray& pkey_list); - int clean_interrputed_clog_data(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObLogArchiveRound& log_archive_round); - int try_clean_clog_data_dir(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const int64_t log_archive_round, const char* storage_info, const common::ObStorageType& device_type); - int generate_backup_piece_tasks(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObLogArchiveRound& log_archive_round, + int get_clog_pkey_list_not_in_base_data(const ObClusterBackupDest &cluster_backup_dest, + const int64_t log_archive_round, const uint64_t tenant_id, common::ObIArray &pkey_list); + int clean_interrputed_clog_data(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObLogArchiveRound &log_archive_round); + int try_clean_clog_data_dir(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const int64_t log_archive_round, const char *storage_info, const common::ObStorageType &device_type); + int generate_backup_piece_tasks(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObLogArchiveRound &log_archive_round, const int64_t start_replay_log_ts); - int generate_backup_piece_pg_tasks(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObLogArchiveRound& log_archive_round, - const ObSimplePieceInfo& backup_piece_info, const int64_t start_replay_log_ts); - int generate_backup_piece_pg_delete_task(const ObSimpleBackupDataCleanTenant& simple_clean_tenant, - const ObBackupDataCleanElement& clean_element, const ObLogArchiveRound& log_archive_round, - const ObSimplePieceInfo& backup_piece_info, const int64_t start_replay_log_ts, const ObPartitionKey& pg_key, - const ObBackupDeleteClogMode& delete_clog_mode); - int get_clog_file_id(const ObClusterBackupDest& backup_dest, const ObLogArchiveRound& log_archive_round, - const ObSimplePieceInfo& backup_piece_info, const ObBackupDeleteClogMode& delete_clog_mode, - const int64_t start_replay_log_ts, const ObPartitionKey& pg_key, uint64_t& data_file_id, uint64_t& index_file_id); - int handle_archive_key(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const ObBackupDeleteClogMode& delete_clog_mode, - const common::ObIArray& pg_keys); - int handle_single_piece_info(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const ObBackupDeleteClogMode& delete_clog_mode); - int delete_archive_key(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const common::ObIArray& pg_keys); - int update_archive_key_timestamp(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const common::ObIArray& pg_keys); - int handle_data_and_index_dir(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const ObBackupDeleteClogMode& delete_clog_mode, - const common::ObIArray& pg_keys); - int handle_backup_clog_piece_infos(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObSimplePieceInfo& backup_piece_info, const ObBackupDeleteClogMode& delete_clog_mode, - const common::ObIArray& pg_keys); - int handle_backup_piece_dir(const uint64_t tenant_id, const ObClusterBackupDest& backup_dest, - const ObSimplePieceInfo& backup_piece_info, const ObBackupDeleteClogMode& delete_clog_mode); + int generate_backup_piece_pg_tasks(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObLogArchiveRound &log_archive_round, + const ObSimplePieceInfo &backup_piece_info, const int64_t start_replay_log_ts); + int generate_backup_piece_pg_delete_task(const ObSimpleBackupDataCleanTenant &simple_clean_tenant, + const ObBackupDataCleanElement &clean_element, const ObLogArchiveRound &log_archive_round, + const ObSimplePieceInfo &backup_piece_info, const int64_t start_replay_log_ts, const ObPartitionKey &pg_key, + const ObBackupDeleteClogMode &delete_clog_mode); + int get_clog_file_id(const ObClusterBackupDest &backup_dest, const ObLogArchiveRound &log_archive_round, + const ObSimplePieceInfo &backup_piece_info, const ObBackupDeleteClogMode &delete_clog_mode, + const int64_t start_replay_log_ts, const ObPartitionKey &pg_key, uint64_t &data_file_id, uint64_t &index_file_id); + int handle_archive_key(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const ObBackupDeleteClogMode &delete_clog_mode, + const common::ObIArray &pg_keys); + int handle_single_piece_info(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const ObBackupDeleteClogMode &delete_clog_mode); + int delete_archive_key(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const common::ObIArray &pg_keys); + int update_archive_key_timestamp(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const common::ObIArray &pg_keys); + int handle_data_and_index_dir(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const ObBackupDeleteClogMode &delete_clog_mode, + const common::ObIArray &pg_keys); + int handle_backup_clog_piece_infos(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObSimplePieceInfo &backup_piece_info, const ObBackupDeleteClogMode &delete_clog_mode, + const common::ObIArray &pg_keys); + int handle_backup_piece_dir(const uint64_t tenant_id, const ObClusterBackupDest &backup_dest, + const ObSimplePieceInfo &backup_piece_info, const ObBackupDeleteClogMode &delete_clog_mode); private: static const int MAX_BUCKET_NUM = 2048; @@ -368,8 +395,8 @@ private: ObBackupDataCleanTenant clean_tenant_; hash::ObHashSet pkey_set_; ObBackupDataCleanStatics clean_statics_; - ObBackupDataClean* data_clean_; - common::ObMySQLProxy* sql_proxy_; + ObBackupDataClean *data_clean_; + common::ObMySQLProxy *sql_proxy_; private: DISALLOW_COPY_AND_ASSIGN(ObTenantBackupClogDataCleanTask); @@ -379,14 +406,14 @@ class ObTableBaseDataCleanMgr { public: ObTableBaseDataCleanMgr(); virtual ~ObTableBaseDataCleanMgr(); - int init(const int64_t table_id, const ObBackupDataCleanElement& clean_element, const ObBackupSetId& backup_set_id, - const ObExternBackupInfo& extern_backup_info, const common::ObIArray& meta_index_array, - ObBackupDataClean& data_clean); + int init(const int64_t table_id, const ObBackupDataCleanElement &clean_element, const ObBackupSetId &backup_set_id, + const ObExternBackupInfo &extern_backup_info, const common::ObIArray &meta_index_array, + ObBackupDataClean &data_clean); int do_clean(); - int get_clean_statics(ObBackupDataCleanStatics& clean_statics); + int get_clean_statics(ObBackupDataCleanStatics &clean_statics); private: - int clean_partition_backup_data(const ObBackupMetaIndex& meta_index); + int clean_partition_backup_data(const ObBackupMetaIndex &meta_index); int try_clean_backup_table_dir(); private: @@ -398,7 +425,7 @@ private: common::ObArray meta_index_array_; ObBackupBaseDataPathInfo path_info_; ObBackupDataCleanStatics clean_statics_; - ObBackupDataClean* data_clean_; + ObBackupDataClean *data_clean_; private: DISALLOW_COPY_AND_ASSIGN(ObTableBaseDataCleanMgr); @@ -408,16 +435,16 @@ class ObTableClogDataCleanMgr { public: ObTableClogDataCleanMgr(); virtual ~ObTableClogDataCleanMgr(); - int init(const int64_t table_id, const ObBackupDataCleanElement& clean_element, - const ObLogArchiveRound& log_archive_round, const ObTenantBackupTaskInfo& clog_data_clean_point, - const common::ObIArray& meta_index_array, ObBackupDataClean& data_clean); + int init(const int64_t table_id, const ObBackupDataCleanElement &clean_element, + const ObLogArchiveRound &log_archive_round, const ObTenantBackupTaskInfo &clog_data_clean_point, + const common::ObIArray &meta_index_array, ObBackupDataClean &data_clean); int do_clean(); - int get_clean_statics(ObBackupDataCleanStatics& clean_statics); + int get_clean_statics(ObBackupDataCleanStatics &clean_statics); private: - int clean_partition_clog_backup_data(const ObBackupMetaIndex& meta_index); + int clean_partition_clog_backup_data(const ObBackupMetaIndex &meta_index); int try_clean_backup_table_clog_dir(); - int get_partition_meta(const ObBackupMetaIndex& meta_index, storage::ObPartitionGroupMeta& pg_meta); + int get_partition_meta(const ObBackupMetaIndex &meta_index, storage::ObPartitionGroupMeta &pg_meta); private: bool is_inited_; @@ -427,7 +454,7 @@ private: ObTenantBackupTaskInfo clog_data_clean_point_; common::ObArray meta_index_array_; ObBackupDataCleanStatics clean_statics_; - ObBackupDataClean* data_clean_; + ObBackupDataClean *data_clean_; private: DISALLOW_COPY_AND_ASSIGN(ObTableClogDataCleanMgr); @@ -437,23 +464,23 @@ class ObPartitionClogDataCleanMgr { public: ObPartitionClogDataCleanMgr(); virtual ~ObPartitionClogDataCleanMgr(); - int init(const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info, - const ObPartitionKey& pkey, const uint64_t data_file_id, const uint64_t index_file_id, - const bool is_backup_backup, ObBackupDataClean& data_clean); + int init(const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info, + const ObPartitionKey &pkey, const uint64_t data_file_id, const uint64_t index_file_id, + const bool is_backup_backup, ObBackupDataClean &data_clean); int touch_clog_backup_data(); int clean_clog_backup_data(); - int get_clean_statics(ObBackupDataCleanStatics& clean_statics); + int get_clean_statics(ObBackupDataCleanStatics &clean_statics); private: - int touch_clog_data_(bool& has_remaing_files); - int touch_clog_meta_(bool& has_remaing_files); - int clean_clog_data_(bool& has_remaing_files); - int clean_clog_meta_(bool& has_remaing_files); + int touch_clog_data_(bool &has_remaing_files); + int touch_clog_meta_(bool &has_remaing_files); + int clean_clog_data_(bool &has_remaing_files); + int clean_clog_meta_(bool &has_remaing_files); int set_need_delete_clog_dir( - const ObClusterBackupDest& cluster_backup_dest, const ObSimplePieceInfo& backup_piece_info); + const ObClusterBackupDest &cluster_backup_dest, const ObSimplePieceInfo &backup_piece_info); int clean_archive_key_(const bool has_remaining_files); int touch_archive_key_(const bool has_remaining_files); - int check_can_delete_file(bool& can_delete_file); + int check_can_delete_file(bool &can_delete_file); private: bool is_inited_; @@ -464,7 +491,7 @@ private: uint64_t index_file_id_; bool need_clean_dir_; ObBackupDataCleanStatics clean_statics_; - ObBackupDataClean* data_clean_; + ObBackupDataClean *data_clean_; bool is_backup_backup_; }; @@ -472,20 +499,20 @@ class ObPartitionDataCleanMgr { public: ObPartitionDataCleanMgr(); virtual ~ObPartitionDataCleanMgr(); - int init(const ObPartitionKey& pkey, const ObBackupDataCleanElement& clean_element, - const ObBackupSetId& backup_set_id, const ObExternBackupInfo& extern_backup_info, ObBackupDataClean& data_clean); + int init(const ObPartitionKey &pkey, const ObBackupDataCleanElement &clean_element, + const ObBackupSetId &backup_set_id, const ObExternBackupInfo &extern_backup_info, ObBackupDataClean &data_clean); int do_clean(); - int get_clean_statics(ObBackupDataCleanStatics& clean_statics); + int get_clean_statics(ObBackupDataCleanStatics &clean_statics); private: int touch_backup_data(); int clean_backup_data(); int clean_backup_major_data(); int clean_backup_minor_data(); - int clean_backup_data_(const ObBackupPath& path); + int clean_backup_data_(const ObBackupPath &path); int touch_backup_major_data(); int touch_backup_minor_data(); - int touch_backup_data_(const ObBackupPath& path); + int touch_backup_data_(const ObBackupPath &path); private: bool is_inited_; @@ -493,7 +520,7 @@ private: ObBackupSetId backup_set_id_; ObBackupBaseDataPathInfo path_info_; ObBackupDataCleanStatics clean_statics_; - ObBackupDataClean* data_clean_; + ObBackupDataClean *data_clean_; ObBackupDestOpt backup_dest_option_; private: diff --git a/src/rootserver/ob_backup_data_clean.cpp b/src/rootserver/ob_backup_data_clean.cpp index 6344c16a1159a797595f527f7c8d76fc34c0c47e..902bf9381c453a7fac049db7f128d3967a2dfca4 100644 --- a/src/rootserver/ob_backup_data_clean.cpp +++ b/src/rootserver/ob_backup_data_clean.cpp @@ -55,14 +55,16 @@ ObBackupDataClean::ObBackupDataClean() is_update_reserved_backup_timestamp_(false), inner_table_version_(OB_BACKUP_INNER_TABLE_VMAX), sys_tenant_deleted_backup_set_(), - retry_count_(0) + retry_count_(0), + sys_tenant_deleted_backup_round_(), + sys_tenant_deleted_backup_piece_() {} ObBackupDataClean::~ObBackupDataClean() {} -int ObBackupDataClean::init(share::schema::ObMultiVersionSchemaService& schema_service, ObMySQLProxy& sql_proxy, - share::ObIBackupLeaseService& backup_lease_service) +int ObBackupDataClean::init(share::schema::ObMultiVersionSchemaService &schema_service, ObMySQLProxy &sql_proxy, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; const int root_backup_thread_cnt = 1; @@ -75,6 +77,10 @@ int ObBackupDataClean::init(share::schema::ObMultiVersionSchemaService& schema_s LOG_WARN("create thread failed", K(ret), K(root_backup_thread_cnt)); } else if (OB_FAIL(sys_tenant_deleted_backup_set_.create(MAX_BUCKET_NUM))) { LOG_WARN("failed to create backup set map", K(ret)); + } else if (OB_FAIL(sys_tenant_deleted_backup_round_.create(MAX_BUCKET_NUM))) { + LOG_WARN("failed to create sys tenant deleted backup round", K(ret)); + } else if (OB_FAIL(sys_tenant_deleted_backup_piece_.create(MAX_BUCKET_NUM))) { + LOG_WARN("failed to create sys tenant deleted backup piece", K(ret)); } else { schema_service_ = &schema_service; sql_proxy_ = &sql_proxy; @@ -143,6 +149,9 @@ void ObBackupDataClean::run3() ret = OB_SUCCESS; data_clean_tenants.reset(); inner_error_ = OB_SUCCESS; + sys_tenant_deleted_backup_set_.reuse(); + sys_tenant_deleted_backup_round_.reuse(); + sys_tenant_deleted_backup_piece_.reuse(); ObCurTraceId::init(GCONF.self_addr_); if (OB_FAIL(set_current_backup_dest())) { @@ -170,7 +179,7 @@ void ObBackupDataClean::run3() is_working_ = false; } -int ObBackupDataClean::get_need_clean_tenants(ObIArray& clean_tenants) +int ObBackupDataClean::get_need_clean_tenants(ObIArray &clean_tenants) { int ret = OB_SUCCESS; ObArray server_clean_tenants; @@ -201,7 +210,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& LOG_WARN("failed to get clean tenants from history table", K(ret), K(sys_clean_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < server_clean_tenants.count(); ++i) { - const ObBackupDataCleanTenant& server_clean_tenant = server_clean_tenants.at(i); + const ObBackupDataCleanTenant &server_clean_tenant = server_clean_tenants.at(i); ObSimpleBackupDataCleanTenant simple_clean_tenant; if (OB_FAIL(extern_clean_tenants_map.get_refactored( server_clean_tenant.simple_clean_tenant_.tenant_id_, simple_clean_tenant))) { @@ -217,7 +226,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& } for (int64_t i = 0; OB_SUCC(ret) && i < deleted_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& deleted_clean_tenant = deleted_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &deleted_clean_tenant = deleted_clean_tenants.at(i); ObSimpleBackupDataCleanTenant simple_clean_tenant; if (OB_FAIL(extern_clean_tenants_map.get_refactored(deleted_clean_tenant.tenant_id_, simple_clean_tenant))) { if (OB_HASH_NOT_EXIST == ret) { @@ -232,7 +241,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& // add from server clean tenants for (int64_t i = 0; OB_SUCC(ret) && i < server_clean_tenants.count(); ++i) { - const ObBackupDataCleanTenant& server_clean_tenant = server_clean_tenants.at(i); + const ObBackupDataCleanTenant &server_clean_tenant = server_clean_tenants.at(i); if (OB_FAIL(clean_tenants.push_back(server_clean_tenant))) { LOG_WARN("failed to push server clean tenant into clean tenants", K(ret), K(server_clean_tenant)); } @@ -240,7 +249,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& // add deleted clean tenant already in inner table for (int64_t i = 0; OB_SUCC(ret) && i < deleted_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = deleted_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = deleted_clean_tenants.at(i); ObBackupDataCleanTenant clean_tenant; clean_tenant.simple_clean_tenant_ = simple_clean_tenant; if (OB_FAIL(clean_tenants.push_back(clean_tenant))) { @@ -250,7 +259,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& hash::ObHashMap::iterator iter; for (iter = extern_clean_tenants_map.begin(); OB_SUCC(ret) && iter != extern_clean_tenants_map.end(); ++iter) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = iter->second; + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = iter->second; if (OB_FAIL(new_deleted_clean_tenants.push_back(simple_clean_tenant))) { LOG_WARN("failed to push simple clean tenant info array", K(ret), K(simple_clean_tenant)); } @@ -265,7 +274,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& // add deleted tenants for (int64_t i = 0; OB_SUCC(ret) && i < new_deleted_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = new_deleted_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = new_deleted_clean_tenants.at(i); ObBackupDataCleanTenant clean_tenant; clean_tenant.simple_clean_tenant_ = simple_clean_tenant; if (OB_FAIL(clean_tenants.push_back(clean_tenant))) { @@ -276,7 +285,7 @@ int ObBackupDataClean::get_need_clean_tenants(ObIArray& return ret; } -int ObBackupDataClean::get_server_clean_tenants(ObIArray& clean_tenants) +int ObBackupDataClean::get_server_clean_tenants(ObIArray &clean_tenants) { int ret = OB_SUCCESS; ObArray all_tenant_ids; @@ -330,7 +339,7 @@ int ObBackupDataClean::get_server_clean_tenants(ObIArray& tenant_ids) +int ObBackupDataClean::get_all_tenant_ids(ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObSchemaGetterGuard guard; @@ -361,7 +370,7 @@ int ObBackupDataClean::get_all_tenant_ids(ObIArray& tenant_ids) } int ObBackupDataClean::get_backup_clean_info( - const uint64_t tenant_id, const bool for_update, ObISQLClient& sql_proxy, ObBackupCleanInfo& clean_info) + const uint64_t tenant_id, const bool for_update, ObISQLClient &sql_proxy, ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; ObTenantBackupCleanInfoUpdater updater; @@ -381,7 +390,7 @@ int ObBackupDataClean::get_backup_clean_info( return ret; } -int ObBackupDataClean::get_backup_clean_info(const uint64_t tenant_id, ObBackupCleanInfo& clean_info) +int ObBackupDataClean::get_backup_clean_info(const uint64_t tenant_id, ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; ObTenantBackupCleanInfoUpdater updater; @@ -401,7 +410,7 @@ int ObBackupDataClean::get_backup_clean_info(const uint64_t tenant_id, ObBackupC return ret; } -int ObBackupDataClean::get_server_need_clean_info(const uint64_t tenant_id, bool& need_add) +int ObBackupDataClean::get_server_need_clean_info(const uint64_t tenant_id, bool &need_add) { int ret = OB_SUCCESS; need_add = false; @@ -428,8 +437,8 @@ int ObBackupDataClean::get_server_need_clean_info(const uint64_t tenant_id, bool return ret; } -int ObBackupDataClean::get_tenant_backup_task_his_info(const share::ObBackupCleanInfo& clean_info, - common::ObISQLClient& trans, common::ObIArray& tenant_infos) +int ObBackupDataClean::get_tenant_backup_task_his_info(const share::ObBackupCleanInfo &clean_info, + common::ObISQLClient &trans, common::ObIArray &tenant_infos) { int ret = OB_SUCCESS; if (IS_NOT_INIT) { @@ -455,8 +464,8 @@ int ObBackupDataClean::get_tenant_backup_task_his_info(const share::ObBackupClea return ret; } -int ObBackupDataClean::inner_get_tenant_backup_task_his_info(const ObBackupCleanInfo& clean_info, - common::ObISQLClient& trans, common::ObIArray& tenant_infos) +int ObBackupDataClean::inner_get_tenant_backup_task_his_info(const ObBackupCleanInfo &clean_info, + common::ObISQLClient &trans, common::ObIArray &tenant_infos) { int ret = OB_SUCCESS; tenant_infos.reset(); @@ -478,8 +487,8 @@ int ObBackupDataClean::inner_get_tenant_backup_task_his_info(const ObBackupClean return ret; } -int ObBackupDataClean::get_tenant_backup_task_info(const share::ObBackupCleanInfo& clean_info, - common::ObISQLClient& trans, common::ObIArray& tenant_infos) +int ObBackupDataClean::get_tenant_backup_task_info(const share::ObBackupCleanInfo &clean_info, + common::ObISQLClient &trans, common::ObIArray &tenant_infos) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater updater; @@ -508,8 +517,8 @@ int ObBackupDataClean::get_tenant_backup_task_info(const share::ObBackupCleanInf return ret; } -int ObBackupDataClean::get_tenant_backup_backupset_task_his_info(const share::ObBackupCleanInfo& clean_info, - common::ObISQLClient& trans, common::ObIArray& tenant_infos) +int ObBackupDataClean::get_tenant_backup_backupset_task_his_info(const share::ObBackupCleanInfo &clean_info, + common::ObISQLClient &trans, common::ObIArray &tenant_infos) { int ret = OB_SUCCESS; if (IS_NOT_INIT) { @@ -526,8 +535,8 @@ int ObBackupDataClean::get_tenant_backup_backupset_task_his_info(const share::Ob } int ObBackupDataClean::convert_backup_backupset_task_to_backup_task( - const common::ObIArray& backup_backupset_tasks, - common::ObIArray& backup_tasks) + const common::ObIArray &backup_backupset_tasks, + common::ObIArray &backup_tasks) { int ret = OB_SUCCESS; backup_tasks.reset(); @@ -537,7 +546,7 @@ int ObBackupDataClean::convert_backup_backupset_task_to_backup_task( } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_backupset_tasks.count(); ++i) { ObTenantBackupTaskInfo info; - const ObTenantBackupBackupsetTaskInfo& bb_info = backup_backupset_tasks.at(i); + const ObTenantBackupBackupsetTaskInfo &bb_info = backup_backupset_tasks.at(i); if (OB_FAIL(bb_info.convert_to_backup_task_info(info))) { LOG_WARN("failed to convert to backup task info", KR(ret), K(bb_info)); } else if (OB_FAIL(backup_tasks.push_back(info))) { @@ -550,7 +559,7 @@ int ObBackupDataClean::convert_backup_backupset_task_to_backup_task( /*not use anymore*/ int ObBackupDataClean::get_log_archive_info(const int64_t copy_id, const uint64_t tenant_id, - common::ObISQLClient& trans, common::ObIArray& log_archive_infos) + common::ObISQLClient &trans, common::ObIArray &log_archive_infos) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr mgr; @@ -579,7 +588,7 @@ int ObBackupDataClean::get_log_archive_info(const int64_t copy_id, const uint64_ /*not use anymore*/ int ObBackupDataClean::get_log_archive_history_info(const int64_t copy_id, const uint64_t tenant_id, - common::ObISQLClient& trans, common::ObIArray& log_archive_infos) + common::ObISQLClient &trans, common::ObIArray &log_archive_infos) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr mgr; @@ -601,7 +610,7 @@ int ObBackupDataClean::get_log_archive_history_info(const int64_t copy_id, const /*not use anymore*/ int ObBackupDataClean::get_extern_clean_tenants( - hash::ObHashMap& clean_tenants_map) + hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; ObBackupCleanInfo sys_clean_info; @@ -635,7 +644,7 @@ int ObBackupDataClean::get_extern_clean_tenants( // get tenant info from log archive info for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_infos.count(); ++i) { - const ObLogArchiveBackupInfo& info = log_archive_infos.at(i); + const ObLogArchiveBackupInfo &info = log_archive_infos.at(i); ObBackupDest backup_dest; if (OB_FAIL(backup_dest.set(info.backup_dest_))) { LOG_WARN("failed to set backup dest", K(ret), K(info)); @@ -660,7 +669,7 @@ int ObBackupDataClean::get_extern_clean_tenants( backup_dest_set.reuse(); for (int64_t i = 0; OB_SUCC(ret) && i < task_infos.count(); ++i) { - const ObTenantBackupTaskInfo& task_info = task_infos.at(i); + const ObTenantBackupTaskInfo &task_info = task_infos.at(i); int hash_ret = backup_dest_set.exist_refactored(task_info.backup_dest_); if (OB_HASH_EXIST == hash_ret) { // do nothing @@ -679,8 +688,8 @@ int ObBackupDataClean::get_extern_clean_tenants( return ret; } -int ObBackupDataClean::get_archive_clean_tenant(const share::ObLogArchiveBackupInfo& log_archive_info, - hash::ObHashMap& clean_tenants_map) +int ObBackupDataClean::get_archive_clean_tenant(const share::ObLogArchiveBackupInfo &log_archive_info, + hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; ObTenantNameSimpleMgr tenant_name_mgr; @@ -729,8 +738,8 @@ int ObBackupDataClean::get_archive_clean_tenant(const share::ObLogArchiveBackupI return ret; } -int ObBackupDataClean::get_backup_clean_tenant(const share::ObTenantBackupTaskInfo& task_info, - hash::ObHashMap& clean_tenants_map) +int ObBackupDataClean::get_backup_clean_tenant(const share::ObTenantBackupTaskInfo &task_info, + hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; ObExternTenantInfoMgr tenant_info_mgr; @@ -771,7 +780,7 @@ int ObBackupDataClean::get_backup_clean_tenant(const share::ObTenantBackupTaskIn return ret; } -int ObBackupDataClean::do_clean_scheduler(ObIArray& clean_tenants) +int ObBackupDataClean::do_clean_scheduler(ObIArray &clean_tenants) { LOG_INFO("start do clean scheduler", K(clean_tenants)); int ret = OB_SUCCESS; @@ -788,7 +797,7 @@ int ObBackupDataClean::do_clean_scheduler(ObIArray& cle return ret; } -int ObBackupDataClean::do_schedule_clean_tenants(ObIArray& clean_tenants) +int ObBackupDataClean::do_schedule_clean_tenants(ObIArray &clean_tenants) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -802,7 +811,7 @@ int ObBackupDataClean::do_schedule_clean_tenants(ObIArray& clean_tenants) +int ObBackupDataClean::do_check_clean_tenants_finished(const common::ObIArray &clean_tenants) { int ret = OB_SUCCESS; ObBackupCleanInfo sys_clean_info; @@ -852,7 +861,7 @@ int ObBackupDataClean::do_check_clean_tenants_finished(const common::ObIArray& tenant_ids) +int ObBackupDataClean::schedule_tenants_backup_data_clean(const common::ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObBackupCleanInfo sys_clean_info; @@ -1055,7 +1068,7 @@ int ObBackupDataClean::schedule_tenants_backup_data_clean(const common::ObIArray } int ObBackupDataClean::schedule_tenant_backup_data_clean( - const uint64_t tenant_id, const share::ObBackupCleanInfo& sys_clean_info, ObISQLClient& sys_tenant_trans) + const uint64_t tenant_id, const share::ObBackupCleanInfo &sys_clean_info, ObISQLClient &sys_tenant_trans) { int ret = OB_SUCCESS; ObBackupCleanInfo clean_info; @@ -1119,7 +1132,7 @@ int ObBackupDataClean::schedule_tenant_backup_data_clean( return ret; } -int ObBackupDataClean::do_tenant_clean_scheduler(ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::do_tenant_clean_scheduler(ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; clean_tenant.backup_element_array_.reset(); @@ -1165,9 +1178,9 @@ int ObBackupDataClean::do_tenant_clean_scheduler(ObBackupCleanInfo& clean_info, // -- ObbackupDest // -- log_archive_round_array (ascending order) // -- backup_set_id_array(descending order) -int ObBackupDataClean::get_backup_clean_elements(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::get_backup_clean_elements(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObTenantBackupTaskInfo min_include_task_info; @@ -1209,7 +1222,7 @@ int ObBackupDataClean::get_backup_clean_elements(const share::ObBackupCleanInfo& } int ObBackupDataClean::add_log_archive_infos( - const common::ObIArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant) + const common::ObIArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1217,7 +1230,7 @@ int ObBackupDataClean::add_log_archive_infos( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_infos.count(); ++i) { - const ObLogArchiveBackupInfo& log_archive_info = log_archive_infos.at(i); + const ObLogArchiveBackupInfo &log_archive_info = log_archive_infos.at(i); if (OB_FAIL(add_log_archive_info(log_archive_info, clean_tenant))) { LOG_WARN("failed to add log archive info", K(ret), K(log_archive_info)); } @@ -1227,7 +1240,7 @@ int ObBackupDataClean::add_log_archive_infos( } int ObBackupDataClean::add_log_archive_info( - const ObLogArchiveBackupInfo& log_archive_info, ObBackupDataCleanTenant& clean_tenant) + const ObLogArchiveBackupInfo &log_archive_info, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_archive_info_mgr; @@ -1263,7 +1276,7 @@ int ObBackupDataClean::add_log_archive_info( log_archive_round.copy_id_ = log_archive_info.status_.copy_id_; for (int64_t i = 0; OB_SUCC(ret) && i < piece_infos.count(); ++i) { simple_piece_info.reset(); - const ObBackupPieceInfo& piece_info = piece_infos.at(i); + const ObBackupPieceInfo &piece_info = piece_infos.at(i); if (ObBackupFileStatus::BACKUP_FILE_DELETED == piece_info.file_status_) { // do nothing } else { @@ -1286,6 +1299,8 @@ int ObBackupDataClean::add_log_archive_info( } if (OB_FAIL(ret)) { + } else if (0 != STRCMP(piece_info.backup_dest_.ptr(), log_archive_info.backup_dest_)) { + // do nothing } else if (OB_FAIL(log_archive_round.add_simpe_piece_info(simple_piece_info))) { LOG_WARN("failed to add simple piece info", K(ret), K(simple_piece_info)); } @@ -1317,10 +1332,10 @@ int ObBackupDataClean::add_log_archive_info( return ret; } -int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; int64_t cluster_max_backup_set_id = 0; @@ -1340,7 +1355,7 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo& cle bool has_kept_last_succeed_data = false; bool is_continue = false; for (int64_t i = task_infos.count() - 1; OB_SUCC(ret) && i >= 0; --i) { - const ObTenantBackupTaskInfo& task_info = task_infos.at(i); + const ObTenantBackupTaskInfo &task_info = task_infos.at(i); is_continue = false; // consider can clean up if (ObTenantBackupTaskInfo::FINISH != task_info.status_) { @@ -1440,7 +1455,7 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo& cle ObBackupDest backup_dest; for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_infos.count(); ++i) { backup_dest.reset(); - const ObLogArchiveBackupInfo& log_archive_info = log_archive_infos.at(i); + const ObLogArchiveBackupInfo &log_archive_info = log_archive_infos.at(i); if (OB_FAIL(backup_dest.set(log_archive_info.backup_dest_))) { LOG_WARN("failed to set backup dest", K(ret), K(log_archive_info)); } else if (backup_dest != delete_backup_info.backup_dest_) { @@ -1456,10 +1471,10 @@ int ObBackupDataClean::add_delete_backup_set(const share::ObBackupCleanInfo& cle return ret; } -int ObBackupDataClean::add_obsolete_backup_sets(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::add_obsolete_backup_sets(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; @@ -1483,10 +1498,10 @@ int ObBackupDataClean::add_obsolete_backup_sets(const share::ObBackupCleanInfo& return ret; } -int ObBackupDataClean::add_normal_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::add_normal_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; bool is_continue = false; @@ -1502,7 +1517,7 @@ int ObBackupDataClean::add_normal_tenant_obsolete_backup_sets(const share::ObBac } else { for (int64_t i = task_infos.count() - 1; OB_SUCC(ret) && i >= 0; --i) { is_continue = false; - const ObTenantBackupTaskInfo& task_info = task_infos.at(i); + const ObTenantBackupTaskInfo &task_info = task_infos.at(i); ObBackupSetId backup_set_id; backup_set_id.backup_set_id_ = task_info.backup_set_id_; backup_set_id.copy_id_ = task_info.copy_id_; @@ -1547,10 +1562,10 @@ int ObBackupDataClean::add_normal_tenant_obsolete_backup_sets(const share::ObBac return ret; } -int ObBackupDataClean::add_sys_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::add_sys_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; bool has_kept_last_succeed_data = false; @@ -1574,7 +1589,7 @@ int ObBackupDataClean::add_sys_tenant_obsolete_backup_sets(const share::ObBackup } else { for (int64_t i = task_infos.count() - 1; OB_SUCC(ret) && i >= 0; --i) { is_continue = false; - const ObTenantBackupTaskInfo& task_info = task_infos.at(i); + const ObTenantBackupTaskInfo &task_info = task_infos.at(i); bool need_add_backup_set = true; if (task_info.snapshot_version_ <= clean_info.expired_time_) { if (OB_FAIL(deal_with_obsolete_backup_set(clean_info, @@ -1619,10 +1634,10 @@ int ObBackupDataClean::add_sys_tenant_obsolete_backup_sets(const share::ObBackup return ret; } -int ObBackupDataClean::deal_with_obsolete_backup_set(const share::ObBackupCleanInfo& clean_info, - const ObTenantBackupTaskInfo& task_info, const common::ObArray& log_archive_infos, - const int64_t cluster_max_backup_set_id, ObBackupSetId& backup_set_id, bool& has_kept_last_succeed_data, - share::ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::deal_with_obsolete_backup_set(const share::ObBackupCleanInfo &clean_info, + const ObTenantBackupTaskInfo &task_info, const common::ObArray &log_archive_infos, + const int64_t cluster_max_backup_set_id, ObBackupSetId &backup_set_id, bool &has_kept_last_succeed_data, + share::ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; backup_set_id.reset(); @@ -1709,10 +1724,10 @@ int ObBackupDataClean::deal_with_obsolete_backup_set(const share::ObBackupCleanI return ret; } -int ObBackupDataClean::deal_with_effective_backup_set(const share::ObBackupCleanInfo& clean_info, - const ObTenantBackupTaskInfo& task_info, const common::ObArray& log_archive_infos, - ObBackupSetId& backup_set_id, bool& has_kept_last_succeed_data, - share::ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::deal_with_effective_backup_set(const share::ObBackupCleanInfo &clean_info, + const ObTenantBackupTaskInfo &task_info, const common::ObArray &log_archive_infos, + ObBackupSetId &backup_set_id, bool &has_kept_last_succeed_data, + share::ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; backup_set_id.reset(); @@ -1752,10 +1767,10 @@ int ObBackupDataClean::deal_with_effective_backup_set(const share::ObBackupClean return ret; } -int ObBackupDataClean::add_obsolete_backup_set_with_order(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& reverse_task_infos, - const common::ObIArray& reverse_backup_set_ids, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& clog_data_clean_point) +int ObBackupDataClean::add_obsolete_backup_set_with_order(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &reverse_task_infos, + const common::ObIArray &reverse_backup_set_ids, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &clog_data_clean_point) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1774,16 +1789,24 @@ int ObBackupDataClean::add_obsolete_backup_set_with_order(const share::ObBackupC ObBackupDestOpt backup_dest_option; for (int64_t i = reverse_task_infos.count() - 1; OB_SUCC(ret) && i >= 0; --i) { backup_dest_option.reset(); - const ObTenantBackupTaskInfo& task_info = reverse_task_infos.at(i); - const ObBackupSetId& backup_set_id = reverse_backup_set_ids.at(i); + const ObTenantBackupTaskInfo &task_info = reverse_task_infos.at(i); + const ObBackupSetId &backup_set_id = reverse_backup_set_ids.at(i); new_backup_set_id = backup_set_id; if (!is_deleted_set_contine) { - if (task_info.is_result_succeed()) { + if (clean_info.is_delete_obsolete_backup_backup()) { + new_backup_set_id.clean_mode_ = ObBackupDataCleanMode::TOUCH; + if (task_info.is_result_succeed() && !is_set_clog_clean_point) { + clog_data_clean_point = task_info; + is_set_clog_clean_point = true; + } + } else if (task_info.is_result_succeed()) { new_backup_set_id.clean_mode_ = ObBackupDataCleanMode::TOUCH; if (!is_set_clog_clean_point) { clog_data_clean_point = task_info; is_set_clog_clean_point = true; } + } else { + // do nothing } } else if (ObBackupDataCleanMode::CLEAN == backup_set_id.clean_mode_) { // do nothing @@ -1807,9 +1830,9 @@ int ObBackupDataClean::add_obsolete_backup_set_with_order(const share::ObBackupC return ret; } -int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_archive_info_mgr; @@ -1846,7 +1869,7 @@ int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo& c clean_tenant.clog_gc_snapshot_ = backup_piece_info.max_ts_; // 1.find log archive info for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_infos.count() && !found_log_archive_info; ++i) { - const ObLogArchiveBackupInfo& tmp_log_archive_info = log_archive_infos.at(i); + const ObLogArchiveBackupInfo &tmp_log_archive_info = log_archive_infos.at(i); ObBackupDest tmp_backup_dest; if (OB_FAIL(tmp_backup_dest.set(tmp_log_archive_info.backup_dest_))) { LOG_WARN("failed to set tmp backup dest", K(ret), K(tmp_log_archive_info)); @@ -1884,7 +1907,7 @@ int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo& c } else { int64_t start_replay_log_ts = 0; for (int64_t i = 0; i < task_infos.count() && !found_backup_set; ++i) { - const ObTenantBackupTaskInfo& task_info = task_infos.at(i); + const ObTenantBackupTaskInfo &task_info = task_infos.at(i); if (task_info.is_result_succeed() && task_info.backup_dest_ == backup_dest && task_info.backup_type_.is_full_backup()) { start_replay_log_ts = task_info.start_replay_log_ts_; @@ -1915,9 +1938,9 @@ int ObBackupDataClean::add_delete_backup_piece(const share::ObBackupCleanInfo& c return ret; } -int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; const int64_t backup_round_id = clean_info.backup_round_id_; @@ -1938,7 +1961,7 @@ int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo& c } else { // 1.find log archive info for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_infos.count() && !found_log_archive_info; ++i) { - const ObLogArchiveBackupInfo& tmp_log_archive_info = log_archive_infos.at(i); + const ObLogArchiveBackupInfo &tmp_log_archive_info = log_archive_infos.at(i); ObBackupDest tmp_backup_dest; if (tmp_log_archive_info.status_.round_ == backup_round_id && tmp_log_archive_info.status_.copy_id_ == copy_id) { if (OB_FAIL(add_log_archive_info(tmp_log_archive_info, clean_tenant))) { @@ -1975,7 +1998,7 @@ int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo& c } else { int64_t start_replay_log_ts = 0; for (int64_t i = 0; i < task_infos.count() && !found_backup_set; ++i) { - const ObTenantBackupTaskInfo& task_info = task_infos.at(i); + const ObTenantBackupTaskInfo &task_info = task_infos.at(i); if (task_info.is_result_succeed() && task_info.backup_dest_ == backup_dest && task_info.backup_type_.is_full_backup()) { start_replay_log_ts = task_info.start_replay_log_ts_; @@ -2007,7 +2030,7 @@ int ObBackupDataClean::add_delete_backup_round(const share::ObBackupCleanInfo& c } int ObBackupDataClean::do_tenant_backup_clean( - const share::ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant) { LOG_INFO("start do tenant backup clean", K(clean_info)); int ret = OB_SUCCESS; @@ -2031,7 +2054,7 @@ int ObBackupDataClean::do_tenant_backup_clean( } int ObBackupDataClean::do_normal_tenant_backup_clean( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { LOG_INFO("do normal tenant backup clean", K(clean_info), K(clean_tenant)); int ret = OB_SUCCESS; @@ -2078,7 +2101,7 @@ int ObBackupDataClean::do_normal_tenant_backup_clean( } int ObBackupDataClean::update_normal_tenant_clean_result( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant, const int32_t clean_result) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant, const int32_t clean_result) { int ret = OB_SUCCESS; ObMySQLTransaction trans; @@ -2130,7 +2153,7 @@ int ObBackupDataClean::update_normal_tenant_clean_result( } int ObBackupDataClean::mark_backup_meta_data_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2145,7 +2168,7 @@ int ObBackupDataClean::mark_backup_meta_data_deleting( } int ObBackupDataClean::mark_extern_backup_info_deleted( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element) { int ret = OB_SUCCESS; ObExternBackupInfoMgr extern_backup_info_mgr; @@ -2167,7 +2190,7 @@ int ObBackupDataClean::mark_extern_backup_info_deleted( LOG_WARN("failed to init extern backup set file info mgr", K(ret), K(clean_info), K(cluster_backup_dest)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.backup_set_id_array_.count(); ++i) { - const ObBackupSetId& backup_set_id = clean_element.backup_set_id_array_.at(i); + const ObBackupSetId &backup_set_id = clean_element.backup_set_id_array_.at(i); backup_set_id_pair.reset(); if (!backup_set_id.is_valid()) { ret = OB_ERR_UNEXPECTED; @@ -2195,7 +2218,7 @@ int ObBackupDataClean::mark_extern_backup_info_deleted( } int ObBackupDataClean::mark_inner_table_his_data_deleted( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObMySQLTransaction trans; @@ -2209,7 +2232,7 @@ int ObBackupDataClean::mark_inner_table_his_data_deleted( LOG_WARN("failed to start trans", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& backup_clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDataCleanElement &backup_clean_element = clean_tenant.backup_element_array_.at(i); if (OB_FAIL(mark_backup_task_his_data_deleted(clean_info, backup_clean_element, trans))) { LOG_WARN("failed to mark backup task his data deleted", K(ret), K(clean_info)); } else if (OB_FAIL(mark_log_archive_stauts_his_data_deleted( @@ -2233,20 +2256,20 @@ int ObBackupDataClean::mark_inner_table_his_data_deleted( return ret; } -int ObBackupDataClean::mark_backup_task_his_data_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObISQLClient& trans) +int ObBackupDataClean::mark_backup_task_his_data_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObISQLClient &trans) { int ret = OB_SUCCESS; const uint64_t tenant_id = clean_info.tenant_id_; const int64_t incarnation = clean_element.incarnation_; - const ObBackupDest& backup_dest = clean_element.backup_dest_; + const ObBackupDest &backup_dest = clean_element.backup_dest_; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.backup_set_id_array_.count(); ++i) { - const ObBackupSetId& backup_set_id = clean_element.backup_set_id_array_.at(i); + const ObBackupSetId &backup_set_id = clean_element.backup_set_id_array_.at(i); if (ObBackupDataCleanMode::CLEAN != backup_set_id.clean_mode_) { // do nothing } else { @@ -2277,7 +2300,7 @@ int ObBackupDataClean::mark_backup_task_his_data_deleted(const share::ObBackupCl } int ObBackupDataClean::inner_mark_backup_task_his_data_deleted(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const ObBackupDest& backup_dest, common::ObISQLClient& trans) + const int64_t backup_set_id, const ObBackupDest &backup_dest, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObBackupTaskHistoryUpdater updater; @@ -2291,7 +2314,7 @@ int ObBackupDataClean::inner_mark_backup_task_his_data_deleted(const uint64_t te LOG_WARN("failed to get need mark deleted backup tasks", K(ret), K(tenant_id), K(backup_set_id), K(backup_dest)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_tasks.count(); ++i) { - const ObTenantBackupTaskInfo& backup_task_info = backup_tasks.at(i); + const ObTenantBackupTaskInfo &backup_task_info = backup_tasks.at(i); if (OB_FAIL(updater.mark_backup_task_deleted( backup_task_info.tenant_id_, backup_task_info.incarnation_, backup_task_info.backup_set_id_))) { LOG_WARN("failed to mark backup task deleted", K(ret), K(backup_task_info)); @@ -2303,7 +2326,7 @@ int ObBackupDataClean::inner_mark_backup_task_his_data_deleted(const uint64_t te int ObBackupDataClean::inner_mark_backup_backup_task_his_data_deleted(const uint64_t tenant_id, const int64_t incarnation, const int64_t backup_set_id, const int64_t copy_id, - const share::ObBackupDest& backup_dest, common::ObISQLClient& trans) + const share::ObBackupDest &backup_dest, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray backup_backupset_tasks; @@ -2316,7 +2339,7 @@ int ObBackupDataClean::inner_mark_backup_backup_task_his_data_deleted(const uint LOG_WARN("failed to get need mark deleted task items", KR(ret), K(tenant_id)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_backupset_tasks.count(); ++i) { - const ObTenantBackupBackupsetTaskInfo& info = backup_backupset_tasks.at(i); + const ObTenantBackupBackupsetTaskInfo &info = backup_backupset_tasks.at(i); if (OB_FAIL(ObTenantBackupBackupsetHistoryOperator::mark_task_item_deleted( info.tenant_id_, info.incarnation_, info.copy_id_, info.backup_set_id_, trans))) { LOG_WARN("failed to mark task item deleted", KR(ret), K(tenant_id), K(copy_id)); @@ -2328,7 +2351,7 @@ int ObBackupDataClean::inner_mark_backup_backup_task_his_data_deleted(const uint } int ObBackupDataClean::inner_mark_backup_set_file_data_deleting(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient& trans) + const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray backup_set_file_infos; @@ -2343,7 +2366,7 @@ int ObBackupDataClean::inner_mark_backup_set_file_data_deleting(const uint64_t t LOG_WARN("failed to get tenant backup set file infos", K(ret), K(tenant_id), K(incarnation), K(backup_set_id)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_file_infos.count(); ++i) { - const ObBackupSetFileInfo& src_backup_set_file = backup_set_file_infos.at(i); + const ObBackupSetFileInfo &src_backup_set_file = backup_set_file_infos.at(i); dest_backup_set_file = src_backup_set_file; if (ObBackupSetFileInfo::DOING == src_backup_set_file.status_) { ret = OB_ERR_UNEXPECTED; @@ -2361,7 +2384,7 @@ int ObBackupDataClean::inner_mark_backup_set_file_data_deleting(const uint64_t t } int ObBackupDataClean::inner_mark_backup_set_file_data_deleted(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient& trans) + const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray backup_set_file_infos; @@ -2376,7 +2399,7 @@ int ObBackupDataClean::inner_mark_backup_set_file_data_deleted(const uint64_t te LOG_WARN("failed to get tenant backup set file infos", K(ret), K(tenant_id), K(incarnation), K(backup_set_id)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_file_infos.count(); ++i) { - const ObBackupSetFileInfo& src_backup_set_file = backup_set_file_infos.at(i); + const ObBackupSetFileInfo &src_backup_set_file = backup_set_file_infos.at(i); dest_backup_set_file = src_backup_set_file; if (ObBackupSetFileInfo::DOING == src_backup_set_file.status_) { ret = OB_ERR_UNEXPECTED; @@ -2393,8 +2416,8 @@ int ObBackupDataClean::inner_mark_backup_set_file_data_deleted(const uint64_t te return ret; } -int ObBackupDataClean::mark_log_archive_stauts_his_data_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const int64_t clog_gc_snapshot, common::ObISQLClient& trans) +int ObBackupDataClean::mark_log_archive_stauts_his_data_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const int64_t clog_gc_snapshot, common::ObISQLClient &trans) { int ret = OB_SUCCESS; @@ -2423,7 +2446,7 @@ int ObBackupDataClean::mark_log_archive_stauts_his_data_deleted(const share::ObB } } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) { - const ObLogArchiveRound& log_archive_round = clean_element.log_archive_round_array_.at(i); + const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i); if (OB_FAIL(mark_log_archive_round_data_deleted(clean_info, log_archive_round.log_archive_round_, log_archive_round.copy_id_, @@ -2437,9 +2460,9 @@ int ObBackupDataClean::mark_log_archive_stauts_his_data_deleted(const share::ObB return ret; } -int ObBackupDataClean::mark_log_archive_round_data_deleted(const share::ObBackupCleanInfo& clean_info, +int ObBackupDataClean::mark_log_archive_round_data_deleted(const share::ObBackupCleanInfo &clean_info, const int64_t log_archive_round, const int64_t copy_id, const int64_t start_piece_id, - const int64_t clog_gc_snapshot, common::ObISQLClient& trans) + const int64_t clog_gc_snapshot, common::ObISQLClient &trans) { int ret = OB_SUCCESS; const bool is_backup_backup = copy_id > 0; @@ -2488,8 +2511,8 @@ int ObBackupDataClean::mark_log_archive_round_data_deleted(const share::ObBackup return ret; } -int ObBackupDataClean::mark_log_archive_piece_data_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupPieceInfo& backup_piece_info, const int64_t clog_gc_snapshot, common::ObISQLClient& trans) +int ObBackupDataClean::mark_log_archive_piece_data_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupPieceInfo &backup_piece_info, const int64_t clog_gc_snapshot, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_archive_backup_info_mgr; @@ -2520,7 +2543,7 @@ int ObBackupDataClean::mark_log_archive_piece_data_deleting(const share::ObBacku } int ObBackupDataClean::mark_backup_set_infos_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2528,7 +2551,7 @@ int ObBackupDataClean::mark_backup_set_infos_deleting( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDataCleanElement &clean_element = clean_tenant.backup_element_array_.at(i); if (OB_FAIL(mark_backup_set_info_deleting(clean_info, clean_element))) { LOG_WARN("failed to mark backup set info deleted", K(ret), K(clean_info)); } @@ -2538,7 +2561,7 @@ int ObBackupDataClean::mark_backup_set_infos_deleting( } int ObBackupDataClean::mark_backup_set_info_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element) { int ret = OB_SUCCESS; ObArray backup_set_ids; @@ -2556,8 +2579,8 @@ int ObBackupDataClean::mark_backup_set_info_deleting( return ret; } -int ObBackupDataClean::mark_backup_set_info_inner_table_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids) +int ObBackupDataClean::mark_backup_set_info_inner_table_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids) { int ret = OB_SUCCESS; const uint64_t tenant_id = clean_info.tenant_id_; @@ -2576,7 +2599,7 @@ int ObBackupDataClean::mark_backup_set_info_inner_table_deleting(const share::Ob LOG_WARN("failed to init history updater", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_ids.count(); ++i) { - const ObBackupSetId& backup_set_id = backup_set_ids.at(i); + const ObBackupSetId &backup_set_id = backup_set_ids.at(i); if (ObBackupDataCleanMode::CLEAN != backup_set_id.clean_mode_) { ret = OB_ERR_UNEXPECTED; LOG_WARN("can not mark backup set deleted", K(ret), K(backup_set_id)); @@ -2602,13 +2625,13 @@ int ObBackupDataClean::mark_backup_set_info_inner_table_deleting(const share::Ob return ret; } -int ObBackupDataClean::mark_extern_backup_set_info_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids) +int ObBackupDataClean::mark_extern_backup_set_info_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids) { int ret = OB_SUCCESS; const uint64_t tenant_id = clean_info.tenant_id_; const int64_t incarnation = clean_element.incarnation_; - const ObBackupDest& backup_dest = clean_element.backup_dest_; + const ObBackupDest &backup_dest = clean_element.backup_dest_; ObArray backup_set_id_pairs; ObExternBackupInfoMgr extern_backup_info_mgr; ObExternBackupSetFileInfoMgr extern_backup_set_file_info_mgr; @@ -2623,7 +2646,7 @@ int ObBackupDataClean::mark_extern_backup_set_info_deleting(const share::ObBacku LOG_WARN("failed to set cluster backup dest", K(ret), K(backup_dest)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_ids.count(); ++i) { - const ObBackupSetId& backup_set_id = backup_set_ids.at(i); + const ObBackupSetId &backup_set_id = backup_set_ids.at(i); backup_set_id_pair.reset(); if (ObBackupDataCleanMode::CLEAN != backup_set_id.clean_mode_) { ret = OB_ERR_UNEXPECTED; @@ -2659,7 +2682,7 @@ int ObBackupDataClean::mark_extern_backup_set_info_deleting(const share::ObBacku } int ObBackupDataClean::mark_log_archive_infos_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2667,7 +2690,7 @@ int ObBackupDataClean::mark_log_archive_infos_deleting( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDataCleanElement &clean_element = clean_tenant.backup_element_array_.at(i); if (OB_FAIL(mark_log_archive_info_deleting(clean_info, clean_element))) { LOG_WARN("failed to mark log archive inifo deleted", K(ret), K(clean_info)); } @@ -2677,7 +2700,7 @@ int ObBackupDataClean::mark_log_archive_infos_deleting( } int ObBackupDataClean::mark_log_archive_info_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element) { int ret = OB_SUCCESS; ObArray backup_piece_keys; @@ -2699,9 +2722,9 @@ int ObBackupDataClean::mark_log_archive_info_deleting( return ret; } -int ObBackupDataClean::mark_log_archive_info_inner_table_deleting(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& backup_piece_keys, - const common::ObIArray& log_archive_rounds) +int ObBackupDataClean::mark_log_archive_info_inner_table_deleting(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &backup_piece_keys, + const common::ObIArray &log_archive_rounds) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_info_mgr; @@ -2719,7 +2742,7 @@ int ObBackupDataClean::mark_log_archive_info_inner_table_deleting(const share::O LOG_WARN("failed to start trans", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_rounds.count(); ++i) { - const ObLogArchiveRound& log_archive_round = log_archive_rounds.at(i); + const ObLogArchiveRound &log_archive_round = log_archive_rounds.at(i); ObLogArchiveBackupInfoMgr log_info_mgr; info.reset(); if (log_archive_round.copy_id_ > 0 && OB_FAIL(log_info_mgr.set_backup_backup())) { @@ -2742,7 +2765,7 @@ int ObBackupDataClean::mark_log_archive_info_inner_table_deleting(const share::O } for (int64_t i = 0; OB_SUCC(ret) && i < backup_piece_keys.count(); ++i) { - const ObBackupPieceInfoKey& piece_key = backup_piece_keys.at(i); + const ObBackupPieceInfoKey &piece_key = backup_piece_keys.at(i); piece_info.reset(); ObLogArchiveBackupInfoMgr log_info_mgr; if (piece_key.copy_id_ > 0 && OB_FAIL(log_info_mgr.set_backup_backup())) { @@ -2775,16 +2798,16 @@ int ObBackupDataClean::mark_log_archive_info_inner_table_deleting(const share::O return ret; } -int ObBackupDataClean::mark_extern_log_archive_info_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_piece_keys, - const common::ObIArray& log_archive_rounds) +int ObBackupDataClean::mark_extern_log_archive_info_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_piece_keys, + const common::ObIArray &log_archive_rounds) { int ret = OB_SUCCESS; ObArray round_ids; ObLogArchiveBackupInfoMgr log_info_mgr; const uint64_t tenant_id = clean_info.tenant_id_; const int64_t incarnation = clean_element.incarnation_; - const ObBackupDest& backup_dest = clean_element.backup_dest_; + const ObBackupDest &backup_dest = clean_element.backup_dest_; ObClusterBackupDest cluster_backup_dest; if (!is_inited_) { @@ -2794,7 +2817,7 @@ int ObBackupDataClean::mark_extern_log_archive_info_deleting(const share::ObBack LOG_WARN("failed to set cluster backup dest", K(ret), K(backup_dest), K(clean_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_rounds.count(); ++i) { - const ObLogArchiveRound& log_archive_round = log_archive_rounds.at(i); + const ObLogArchiveRound &log_archive_round = log_archive_rounds.at(i); if (OB_FAIL(round_ids.push_back(log_archive_round.log_archive_round_))) { LOG_WARN("failed to push log archive round into array", K(ret), K(log_archive_round)); } @@ -2815,7 +2838,7 @@ int ObBackupDataClean::mark_extern_log_archive_info_deleting(const share::ObBack } int ObBackupDataClean::get_need_delete_backup_set_ids( - const ObBackupDataCleanElement& clean_element, common::ObIArray& backup_set_ids) + const ObBackupDataCleanElement &clean_element, common::ObIArray &backup_set_ids) { int ret = OB_SUCCESS; backup_set_ids.reset(); @@ -2824,7 +2847,7 @@ int ObBackupDataClean::get_need_delete_backup_set_ids( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.backup_set_id_array_.count(); ++i) { - const ObBackupSetId& backup_set_id = clean_element.backup_set_id_array_.at(i); + const ObBackupSetId &backup_set_id = clean_element.backup_set_id_array_.at(i); if (ObBackupDataCleanMode::TOUCH == backup_set_id.clean_mode_) { // do nothing } else if (OB_FAIL(backup_set_ids.push_back(backup_set_id))) { @@ -2835,18 +2858,13 @@ int ObBackupDataClean::get_need_delete_backup_set_ids( return ret; } -int ObBackupDataClean::get_need_delete_clog_round_and_piece(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObIArray& log_archive_rounds, - common::ObIArray& backup_piece_keys) +int ObBackupDataClean::get_need_delete_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys) { int ret = OB_SUCCESS; log_archive_rounds.reset(); backup_piece_keys.reset(); - const int64_t clog_gc_snapshot = clean_info.clog_gc_snapshot_; - ObLogArchiveBackupInfoMgr log_info_mgr; - const uint64_t tenant_id = clean_info.tenant_id_; - const int64_t incarnation = clean_element.incarnation_; - const int64_t backup_copies = clean_element.backup_dest_option_.backup_copies_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2866,18 +2884,86 @@ int ObBackupDataClean::get_need_delete_clog_round_and_piece(const share::ObBacku LOG_WARN("failed to push backup piece key into array", K(ret), K(piece_key)); } } + } else if (OB_SYS_TENANT_ID == clean_info.tenant_id_) { + if (OB_FAIL(get_sys_tenant_delete_clog_round_and_piece( + clean_info, clean_element, log_archive_rounds, backup_piece_keys))) { + LOG_WARN("failed to get sys tenant delete clog round and piece", K(ret), K(clean_info)); + } + } else { + if (OB_FAIL(get_normal_tenant_delete_clog_round_and_piece( + clean_info, clean_element, log_archive_rounds, backup_piece_keys))) { + LOG_WARN("failed to get normal tenant delete clog round and piece", K(ret), K(clean_info)); + } + } + return ret; +} + +int ObBackupDataClean::get_sys_tenant_delete_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys) +{ + int ret = OB_SUCCESS; + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("backup data clean do not init", K(ret)); + } else if (OB_SYS_TENANT_ID != clean_info.tenant_id_) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("get sys tenant delete clog round and piece get invalid argument", K(ret), K(clean_info)); + } else if (ObBackupCleanInfoStatus::PREPARE == clean_info.status_) { + if (OB_FAIL(get_sys_tenant_prepare_clog_round_and_piece( + clean_info, clean_element, log_archive_rounds, backup_piece_keys))) { + LOG_WARN("failed to get sys tenant prepare delete clog round and piece", K(ret), K(clean_info)); + } + } else if (ObBackupCleanInfoStatus::DOING == clean_info.status_) { + if (OB_FAIL(get_sys_tenant_doing_clog_round_and_piece( + clean_info, clean_element, log_archive_rounds, backup_piece_keys))) { + LOG_WARN("failed to get sys tenant prepare delete clog round and piece", K(ret), K(clean_info)); + } + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("clean info status is unexpected", K(ret), K(clean_info)); + } + return ret; +} + +int ObBackupDataClean::get_sys_tenant_prepare_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys) +{ + int ret = OB_SUCCESS; + log_archive_rounds.reset(); + backup_piece_keys.reset(); + const int64_t clog_gc_snapshot = clean_info.clog_gc_snapshot_; + ObLogArchiveBackupInfoMgr log_info_mgr; + const uint64_t tenant_id = clean_info.tenant_id_; + const int64_t incarnation = clean_element.incarnation_; + const int64_t backup_copies = clean_element.backup_dest_option_.backup_copies_; + ObSimpleArchiveRound simple_archive_round; + ObSimplePieceKey simple_piece_key; + const bool overwrite_key = true; + bool is_delete_inorder = true; + + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("backup data clean do not init", K(ret)); + } else if (!clean_info.is_valid() || OB_SYS_TENANT_ID != clean_info.tenant_id_ || + ObBackupCleanInfoStatus::PREPARE != clean_info.status_) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("get sys tenant delete clog round and piece get invalid argument", K(ret), K(clean_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) { - const ObLogArchiveRound& log_archive_round = clean_element.log_archive_round_array_.at(i); - if (clean_info.is_delete_backup_set() && 0 != log_archive_round.start_piece_id_) { + const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i); + if (!is_delete_inorder) { + break; + } else if (clean_info.is_delete_backup_set() && 0 != log_archive_round.start_piece_id_) { // do nothing } else { - for (int64_t j = 0; OB_SUCC(ret) && j < log_archive_round.piece_infos_.count(); ++j) { - const ObSimplePieceInfo& simple_piece_info = log_archive_round.piece_infos_.at(j); + for (int64_t j = 0; OB_SUCC(ret) && is_delete_inorder && j < log_archive_round.piece_infos_.count(); ++j) { + const ObSimplePieceInfo &simple_piece_info = log_archive_round.piece_infos_.at(j); if (simple_piece_info.max_ts_ > clog_gc_snapshot || ObBackupPieceStatus::BACKUP_PIECE_FROZEN != simple_piece_info.status_ || simple_piece_info.copies_num_ < backup_copies) { - // do nothing + is_delete_inorder = false; } else if (ObBackupFileStatus::BACKUP_FILE_DELETED == simple_piece_info.file_status_) { // do nothing } else { @@ -2887,8 +2973,16 @@ int ObBackupDataClean::get_need_delete_clog_round_and_piece(const share::ObBacku piece_info_key.incarnation_ = incarnation; piece_info_key.round_id_ = log_archive_round.log_archive_round_; piece_info_key.tenant_id_ = tenant_id; + + simple_piece_key.reset(); + simple_piece_key.incarnation_ = piece_info_key.incarnation_; + simple_piece_key.round_id_ = piece_info_key.round_id_; + simple_piece_key.backup_piece_id_ = piece_info_key.backup_piece_id_; + simple_piece_key.copy_id_ = piece_info_key.copy_id_; if (OB_FAIL(backup_piece_keys.push_back(piece_info_key))) { LOG_WARN("failed to push piece info key into array", K(ret), K(simple_piece_info), K(piece_info_key)); + } else if (OB_FAIL(sys_tenant_deleted_backup_piece_.set_refactored_1(simple_piece_key, overwrite_key))) { + LOG_WARN("failed to set simple piece key", K(ret), K(simple_piece_key)); } } } @@ -2898,9 +2992,135 @@ int ObBackupDataClean::get_need_delete_clog_round_and_piece(const share::ObBacku } else if (ObLogArchiveStatus::STOP != log_archive_round.log_archive_status_) { // do nothing } else if (log_archive_round.checkpoint_ts_ > clog_gc_snapshot || log_archive_round.copies_num_ < backup_copies) { - // do nothing + is_delete_inorder = false; } else if (OB_FAIL(log_archive_rounds.push_back(log_archive_round))) { LOG_WARN("failed to push log archive round into array", K(ret), K(log_archive_round)); + } else { + simple_archive_round.reset(); + simple_archive_round.incarnation_ = clean_element.incarnation_; + simple_archive_round.round_id_ = log_archive_round.log_archive_round_; + simple_archive_round.copy_id_ = log_archive_round.copy_id_; + if (OB_FAIL(sys_tenant_deleted_backup_round_.set_refactored_1(simple_archive_round, overwrite_key))) { + LOG_WARN("failed to set sys tenant deleted backup round", K(ret), K(simple_archive_round)); + } + } + } + } + return ret; +} + +int ObBackupDataClean::get_sys_tenant_doing_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys) +{ + int ret = OB_SUCCESS; + ObBackupPieceInfoKey backup_piece_key; + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("backup data clean do not init", K(ret)); + } else if (ObBackupCleanInfoStatus::DOING != clean_info.status_) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("backup clean info status is unexpected", K(ret)); + } else { + hash::ObHashSet::const_iterator piece_iter; + for (piece_iter = sys_tenant_deleted_backup_piece_.begin(); + OB_SUCC(ret) && piece_iter != sys_tenant_deleted_backup_piece_.end(); + ++piece_iter) { + backup_piece_key.reset(); + const ObSimplePieceKey &simple_piece_key = piece_iter->first; + backup_piece_key.backup_piece_id_ = simple_piece_key.backup_piece_id_; + backup_piece_key.copy_id_ = simple_piece_key.copy_id_; + backup_piece_key.incarnation_ = simple_piece_key.incarnation_; + backup_piece_key.round_id_ = simple_piece_key.round_id_; + backup_piece_key.tenant_id_ = clean_info.tenant_id_; + if (OB_FAIL(backup_piece_keys.push_back(backup_piece_key))) { + LOG_WARN("failed to push backup piece key into array", K(ret), K(backup_piece_key), K(simple_piece_key)); + } + } + + hash::ObHashSet::const_iterator round_iter; + for (round_iter = sys_tenant_deleted_backup_round_.begin(); + OB_SUCC(ret) && round_iter != sys_tenant_deleted_backup_round_.end(); + ++round_iter) { + const ObSimpleArchiveRound &simple_archive_round = round_iter->first; + for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) { + const ObLogArchiveRound &tmp_archive_round = clean_element.log_archive_round_array_.at(i); + if (tmp_archive_round.log_archive_round_ == simple_archive_round.round_id_ && + tmp_archive_round.copy_id_ == simple_archive_round.copy_id_) { + if (OB_FAIL(log_archive_rounds.push_back(tmp_archive_round))) { + LOG_WARN("failed to push log archive round into array", K(ret), K(tmp_archive_round)); + } else { + break; + } + } + } + } + } + return ret; +} + +int ObBackupDataClean::get_normal_tenant_delete_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys) +{ + int ret = OB_SUCCESS; + log_archive_rounds.reset(); + backup_piece_keys.reset(); + const uint64_t tenant_id = clean_info.tenant_id_; + const int64_t incarnation = clean_element.incarnation_; + ObSimpleArchiveRound simple_archive_round; + ObSimplePieceKey simple_piece_key; + + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("backup data clean do not init", K(ret)); + } else if (!clean_info.is_valid() || OB_SYS_TENANT_ID == clean_info.tenant_id_) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("get normal tenant delete clog round and piece get invalid argument", K(ret), K(clean_info)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < clean_element.log_archive_round_array_.count(); ++i) { + const ObLogArchiveRound &log_archive_round = clean_element.log_archive_round_array_.at(i); + for (int64_t j = 0; OB_SUCC(ret) && j < log_archive_round.piece_infos_.count(); ++j) { + const ObSimplePieceInfo &simple_piece_info = log_archive_round.piece_infos_.at(j); + simple_piece_key.reset(); + simple_piece_key.incarnation_ = incarnation; + simple_piece_key.round_id_ = simple_piece_info.round_id_; + simple_piece_key.backup_piece_id_ = simple_piece_info.backup_piece_id_; + simple_piece_key.copy_id_ = log_archive_round.copy_id_; + const int hash_ret = sys_tenant_deleted_backup_piece_.exist_refactored(simple_piece_key); + if (OB_HASH_NOT_EXIST == hash_ret) { + // do nothing + } else if (OB_HASH_EXIST != hash_ret) { + ret = hash_ret; + LOG_WARN("failed to check piece key exist", K(ret), K(simple_piece_key)); + } else { + ObBackupPieceInfoKey piece_info_key; + piece_info_key.backup_piece_id_ = simple_piece_info.backup_piece_id_; + piece_info_key.copy_id_ = log_archive_round.copy_id_; + piece_info_key.incarnation_ = incarnation; + piece_info_key.round_id_ = log_archive_round.log_archive_round_; + piece_info_key.tenant_id_ = tenant_id; + if (OB_FAIL(backup_piece_keys.push_back(piece_info_key))) { + LOG_WARN("failed to push piece info key into array", K(ret), K(simple_piece_info), K(piece_info_key)); + } + } + } + + if (OB_FAIL(ret)) { + } else { + simple_archive_round.reset(); + simple_archive_round.incarnation_ = clean_element.incarnation_; + simple_archive_round.round_id_ = log_archive_round.log_archive_round_; + simple_archive_round.copy_id_ = log_archive_round.copy_id_; + const int hash_ret = sys_tenant_deleted_backup_round_.exist_refactored(simple_archive_round); + if (OB_HASH_NOT_EXIST == hash_ret) { + // do nothing + } else if (OB_HASH_EXIST != hash_ret) { + ret = hash_ret; + LOG_WARN("failed to check round exist", K(ret), K(simple_piece_key)); + } else if (OB_FAIL(log_archive_rounds.push_back(log_archive_round))) { + LOG_WARN("failed to push log archive round into array", K(ret), K(log_archive_round)); + } } } } @@ -2908,7 +3128,7 @@ int ObBackupDataClean::get_need_delete_clog_round_and_piece(const share::ObBacku } int ObBackupDataClean::delete_backup_data( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObTenantBackupDataCleanMgr tenant_backup_data_clean_mgr; @@ -2922,7 +3142,7 @@ int ObBackupDataClean::delete_backup_data( } int ObBackupDataClean::delete_tenant_backup_meta_data( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2938,7 +3158,7 @@ int ObBackupDataClean::delete_tenant_backup_meta_data( } int ObBackupDataClean::delete_backup_extern_infos( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObArray backup_set_ids; @@ -2952,9 +3172,9 @@ int ObBackupDataClean::delete_backup_extern_infos( ret = OB_INVALID_ARGUMENT; LOG_WARN("mark_extern_backup_infos_deleted get invalid argument", K(ret), K(clean_info), K(clean_tenant)); } else { - const ObIArray& backup_element_array = clean_tenant.backup_element_array_; + const ObIArray &backup_element_array = clean_tenant.backup_element_array_; for (int64_t i = 0; OB_SUCC(ret) && i < backup_element_array.count(); ++i) { - const ObBackupDataCleanElement& clean_element = backup_element_array.at(i); + const ObBackupDataCleanElement &clean_element = backup_element_array.at(i); if (OB_FAIL(get_need_delete_backup_set_ids(clean_element, backup_set_ids))) { LOG_WARN("failed to get need delete backup set ids", K(ret), K(clean_info)); } else if (OB_FAIL(get_need_delete_clog_round_and_piece( @@ -2976,8 +3196,8 @@ int ObBackupDataClean::delete_backup_extern_infos( return ret; } -int ObBackupDataClean::delete_extern_backup_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids) +int ObBackupDataClean::delete_extern_backup_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids) { int ret = OB_SUCCESS; ObExternBackupInfoMgr extern_backup_info_mgr; @@ -3007,7 +3227,7 @@ int ObBackupDataClean::delete_extern_backup_info_deleted(const share::ObBackupCl if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_ids.count(); ++i) { - const ObBackupSetId& backup_set_id = backup_set_ids.at(i); + const ObBackupSetId &backup_set_id = backup_set_ids.at(i); if (ObBackupDataCleanMode::CLEAN != backup_set_id.clean_mode_) { ret = OB_ERR_UNEXPECTED; LOG_WARN("backup set clean mode is unexpected", K(ret), K(backup_set_id)); @@ -3050,8 +3270,8 @@ int ObBackupDataClean::delete_extern_backup_info_deleted(const share::ObBackupCl return ret; } -int ObBackupDataClean::delete_extern_clog_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const ObIArray& log_archive_rounds) +int ObBackupDataClean::delete_extern_clog_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const ObIArray &log_archive_rounds) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr mgr; @@ -3071,7 +3291,7 @@ int ObBackupDataClean::delete_extern_clog_info_deleted(const share::ObBackupClea LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_rounds.count(); ++i) { - const ObLogArchiveRound& log_archive_round = log_archive_rounds.at(i); + const ObLogArchiveRound &log_archive_round = log_archive_rounds.at(i); if (OB_FAIL(round_ids.push_back(log_archive_round.log_archive_round_))) { LOG_WARN("failed to push log archive round id into array", K(ret), K(log_archive_round)); } @@ -3123,7 +3343,7 @@ int ObBackupDataClean::delete_extern_clog_info_deleted(const share::ObBackupClea } int ObBackupDataClean::delete_extern_tmp_files( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element) + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element) { int ret = OB_SUCCESS; ObClusterBackupDest cluster_backup_dest; @@ -3160,8 +3380,8 @@ int ObBackupDataClean::delete_extern_tmp_files( return ret; } -int ObBackupDataClean::mark_extern_backup_set_file_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids) +int ObBackupDataClean::mark_extern_backup_set_file_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids) { int ret = OB_SUCCESS; ObExternBackupSetFileInfoMgr extern_backup_set_file_info_mgr; @@ -3192,7 +3412,7 @@ int ObBackupDataClean::mark_extern_backup_set_file_info_deleted(const share::ObB if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_ids.count(); ++i) { - const ObBackupSetId& backup_set_id = backup_set_ids.at(i); + const ObBackupSetId &backup_set_id = backup_set_ids.at(i); backup_set_id_pair.reset(); if (ObBackupDataCleanMode::CLEAN != backup_set_id.clean_mode_) { ret = OB_ERR_UNEXPECTED; @@ -3243,8 +3463,8 @@ int ObBackupDataClean::mark_extern_backup_set_file_info_deleted(const share::ObB return ret; } -int ObBackupDataClean::mark_extern_backup_piece_file_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_piece_keys) +int ObBackupDataClean::mark_extern_backup_piece_file_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_piece_keys) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_archive_info_mgr; @@ -3311,7 +3531,7 @@ int ObBackupDataClean::mark_extern_backup_piece_file_info_deleted(const share::O } int ObBackupDataClean::delete_inner_table_his_data( - const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant, common::ObISQLClient& trans) + const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant, common::ObISQLClient &trans) { int ret = OB_SUCCESS; @@ -3320,7 +3540,7 @@ int ObBackupDataClean::delete_inner_table_his_data( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDataCleanElement &clean_element = clean_tenant.backup_element_array_.at(i); if (OB_FAIL(delete_marked_backup_task_his_data(clean_info, clean_element, trans))) { LOG_WARN("failed to delete marked backup task his data", K(ret), K(clean_info)); } else if (OB_FAIL(delete_marked_log_archive_status_his_data(clean_info, clean_element, trans))) { @@ -3331,8 +3551,8 @@ int ObBackupDataClean::delete_inner_table_his_data( return ret; } -int ObBackupDataClean::delete_marked_backup_task_his_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObISQLClient& trans) +int ObBackupDataClean::delete_marked_backup_task_his_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray backup_set_ids; @@ -3351,7 +3571,7 @@ int ObBackupDataClean::delete_marked_backup_task_his_data(const share::ObBackupC } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_ids.count(); ++i) { tenant_backup_tasks.reset(); - const ObBackupSetId& backup_set_id = backup_set_ids.at(i); + const ObBackupSetId &backup_set_id = backup_set_ids.at(i); ObTenantBackupTaskInfo backup_task_info; if (ObBackupDataCleanMode::CLEAN != backup_set_id.clean_mode_) { ret = OB_ERR_UNEXPECTED; @@ -3383,7 +3603,7 @@ int ObBackupDataClean::delete_marked_backup_task_his_data(const share::ObBackupC } int ObBackupDataClean::inner_delete_marked_backup_backup_task_his_data(const uint64_t tenant_id, const int64_t job_id, - const int64_t copy_id, const int64_t backup_set_id, common::ObISQLClient& trans) + const int64_t copy_id, const int64_t backup_set_id, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObTenantBackupTaskInfo tenant_backup_task; @@ -3407,8 +3627,8 @@ int ObBackupDataClean::inner_delete_marked_backup_backup_task_his_data(const uin return ret; } -int ObBackupDataClean::delete_marked_log_archive_status_his_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObISQLClient& trans) +int ObBackupDataClean::delete_marked_log_archive_status_his_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray log_archive_rounds; @@ -3426,7 +3646,7 @@ int ObBackupDataClean::delete_marked_log_archive_status_his_data(const share::Ob for (int64_t i = 0; OB_SUCC(ret) && i < log_archive_rounds.count(); ++i) { log_archive_info.reset(); ObLogArchiveBackupInfoMgr log_archive_backup_info_mgr; - const ObLogArchiveRound& log_archive_round = log_archive_rounds.at(i); + const ObLogArchiveRound &log_archive_round = log_archive_rounds.at(i); if (log_archive_round.copy_id_ > 0 && OB_FAIL(log_archive_backup_info_mgr.set_backup_backup())) { LOG_WARN("failed to set copy id", K(ret), K(log_archive_round)); } else if (OB_FAIL(log_archive_backup_info_mgr.get_log_archive_history_info(trans, @@ -3449,7 +3669,7 @@ int ObBackupDataClean::delete_marked_log_archive_status_his_data(const share::Ob for (int64_t i = 0; OB_SUCC(ret) && i < backup_piece_keys.count(); ++i) { backup_piece_info.reset(); ObLogArchiveBackupInfoMgr log_archive_backup_info_mgr; - const ObBackupPieceInfoKey& piece_info_key = backup_piece_keys.at(i); + const ObBackupPieceInfoKey &piece_info_key = backup_piece_keys.at(i); if (piece_info_key.copy_id_ > 0 && OB_FAIL(log_archive_backup_info_mgr.set_backup_backup())) { LOG_WARN("failed to set copy id", K(ret), K(piece_info_key)); } else if (OB_FAIL(log_archive_backup_info_mgr.get_backup_piece( @@ -3464,8 +3684,8 @@ int ObBackupDataClean::delete_marked_log_archive_status_his_data(const share::Ob return ret; } -int ObBackupDataClean::update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo& src_clean_info, - const share::ObBackupCleanInfo& dest_clean_info) +int ObBackupDataClean::update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo &src_clean_info, + const share::ObBackupCleanInfo &dest_clean_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -3477,8 +3697,8 @@ int ObBackupDataClean::update_clean_info(const uint64_t tenant_id, const share:: return ret; } -int ObBackupDataClean::update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo& src_clean_info, - const share::ObBackupCleanInfo& dest_clean_info, common::ObISQLClient& trans) +int ObBackupDataClean::update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo &src_clean_info, + const share::ObBackupCleanInfo &dest_clean_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObTenantBackupCleanInfoUpdater updater; @@ -3606,7 +3826,7 @@ void ObBackupDataClean::cleanup_prepared_infos() } } -int ObBackupDataClean::check_need_cleanup_prepared_infos(const ObBackupCleanInfo& sys_clean_info, bool& need_clean) +int ObBackupDataClean::check_need_cleanup_prepared_infos(const ObBackupCleanInfo &sys_clean_info, bool &need_clean) { int ret = OB_SUCCESS; need_clean = false; @@ -3623,7 +3843,7 @@ int ObBackupDataClean::check_need_cleanup_prepared_infos(const ObBackupCleanInfo return ret; } -int ObBackupDataClean::cleanup_tenant_prepared_infos(const uint64_t tenant_id, ObISQLClient& sys_tenant_trans) +int ObBackupDataClean::cleanup_tenant_prepared_infos(const uint64_t tenant_id, ObISQLClient &sys_tenant_trans) { int ret = OB_SUCCESS; const int64_t EXECUTE_TIMEOUT_US = 30L * 1000 * 1000; // 30s @@ -3686,7 +3906,7 @@ int ObBackupDataClean::cleanup_tenant_prepared_infos(const uint64_t tenant_id, O } int ObBackupDataClean::insert_tenant_backup_clean_info_history( - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& sys_trans) + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &sys_trans) { int ret = OB_SUCCESS; ObBackupCleanInfo clean_info; @@ -3722,7 +3942,7 @@ int ObBackupDataClean::insert_tenant_backup_clean_info_history( } int ObBackupDataClean::do_with_failed_tenant_clean_task( - const common::ObIArray& normal_clean_tenants, int32_t& clean_result) + const common::ObIArray &normal_clean_tenants, int32_t &clean_result) { int ret = OB_SUCCESS; ObMySQLTransaction trans; @@ -3770,8 +3990,8 @@ int ObBackupDataClean::do_with_failed_tenant_clean_task( } int ObBackupDataClean::check_tenant_backup_clean_task_failed( - const common::ObIArray& normal_clean_tenants, - const ObBackupCleanInfo& sys_clean_info, common::ObISQLClient& sys_tenant_trans, int32_t& result) + const common::ObIArray &normal_clean_tenants, + const ObBackupCleanInfo &sys_clean_info, common::ObISQLClient &sys_tenant_trans, int32_t &result) { int ret = OB_SUCCESS; result = OB_SUCCESS; @@ -3785,7 +4005,7 @@ int ObBackupDataClean::check_tenant_backup_clean_task_failed( result = inner_error_; } else { for (int64_t i = 0; OB_SUCCESS == result && OB_SUCC(ret) && i < normal_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = normal_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = normal_clean_tenants.at(i); ObBackupCleanInfo tenant_clean_info; tenant_clean_info.tenant_id_ = simple_clean_tenant.tenant_id_; if (OB_SYS_TENANT_ID == simple_clean_tenant.tenant_id_) { @@ -3817,7 +4037,7 @@ int ObBackupDataClean::check_tenant_backup_clean_task_failed( } int ObBackupDataClean::update_tenant_backup_clean_task_failed( - const common::ObIArray& normal_clean_tenants, common::ObISQLClient& sys_tenant_trans, + const common::ObIArray &normal_clean_tenants, common::ObISQLClient &sys_tenant_trans, const int32_t result) { int ret = OB_SUCCESS; @@ -3836,7 +4056,7 @@ int ObBackupDataClean::update_tenant_backup_clean_task_failed( LOG_WARN("set timeout context failed", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < normal_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = normal_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = normal_clean_tenants.at(i); ObBackupCleanInfo tenant_clean_info; ObMySQLTransaction trans; tenant_clean_info.tenant_id_ = simple_clean_tenant.tenant_id_; @@ -3894,8 +4114,8 @@ int ObBackupDataClean::update_tenant_backup_clean_task_failed( } int ObBackupDataClean::do_with_finished_tenant_clean_task( - const common::ObIArray& normal_clean_tenants, - const share::ObBackupCleanInfo& sys_clean_info, const ObBackupDataCleanTenant& sys_clean_tenant, + const common::ObIArray &normal_clean_tenants, + const share::ObBackupCleanInfo &sys_clean_info, const ObBackupDataCleanTenant &sys_clean_tenant, const int32_t clean_result) { int ret = OB_SUCCESS; @@ -3962,12 +4182,11 @@ int ObBackupDataClean::do_with_finished_tenant_clean_task( if (OB_SUCC(ret)) { retry_count_ = 0; } - sys_tenant_deleted_backup_set_.reuse(); return ret; } int ObBackupDataClean::insert_clean_infos_into_history( - const common::ObIArray& normal_clean_tenants, common::ObISQLClient& sys_tenant_trans) + const common::ObIArray &normal_clean_tenants, common::ObISQLClient &sys_tenant_trans) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -3975,7 +4194,7 @@ int ObBackupDataClean::insert_clean_infos_into_history( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < normal_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tennat = normal_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tennat = normal_clean_tenants.at(i); if (OB_FAIL(insert_tenant_backup_clean_info_history(simple_clean_tennat, sys_tenant_trans))) { LOG_WARN("failed to insert tenant backup clean info", K(ret), K(simple_clean_tennat)); } @@ -3985,7 +4204,7 @@ int ObBackupDataClean::insert_clean_infos_into_history( } int ObBackupDataClean::reset_backup_clean_infos( - const common::ObIArray& normal_clean_tenants, common::ObISQLClient& sys_trans) + const common::ObIArray &normal_clean_tenants, common::ObISQLClient &sys_trans) { int ret = OB_SUCCESS; const bool for_update = true; @@ -3994,7 +4213,7 @@ int ObBackupDataClean::reset_backup_clean_infos( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < normal_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = normal_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = normal_clean_tenants.at(i); ObMySQLTransaction trans; ObBackupCleanInfo dest_clean_info; ObBackupCleanInfo clean_info; @@ -4050,7 +4269,7 @@ int ObBackupDataClean::reset_backup_clean_infos( } int ObBackupDataClean::check_all_tenant_clean_tasks_stopped( - const common::ObIArray& normal_clean_tenants, bool& is_all_tasks_stopped) + const common::ObIArray &normal_clean_tenants, bool &is_all_tasks_stopped) { int ret = OB_SUCCESS; ObBackupCleanInfo dest_clean_info; @@ -4062,7 +4281,7 @@ int ObBackupDataClean::check_all_tenant_clean_tasks_stopped( LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; is_all_tasks_stopped && OB_SUCC(ret) && i < normal_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = normal_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = normal_clean_tenants.at(i); ObBackupCleanInfo tenant_clean_info; tenant_clean_info.tenant_id_ = simple_clean_tenant.tenant_id_; if (OB_SYS_TENANT_ID == simple_clean_tenant.tenant_id_) { @@ -4090,7 +4309,7 @@ int ObBackupDataClean::check_all_tenant_clean_tasks_stopped( } int ObBackupDataClean::update_clog_gc_snaphost( - const int64_t cluster_clog_gc_snapshot, ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant) + const int64_t cluster_clog_gc_snapshot, ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; int64_t clog_gc_snapshot = 0; @@ -4147,8 +4366,8 @@ int ObBackupDataClean::update_clog_gc_snaphost( return ret; } -int ObBackupDataClean::get_clog_gc_snapshot(const ObBackupCleanInfo& clean_info, - const ObBackupDataCleanTenant& clean_tenant, const int64_t cluster_clog_gc_snapshot, int64_t& clog_gc_snapshot) +int ObBackupDataClean::get_clog_gc_snapshot(const ObBackupCleanInfo &clean_info, + const ObBackupDataCleanTenant &clean_tenant, const int64_t cluster_clog_gc_snapshot, int64_t &clog_gc_snapshot) { int ret = OB_SUCCESS; clog_gc_snapshot = INT64_MAX; @@ -4186,7 +4405,7 @@ int ObBackupDataClean::get_clog_gc_snapshot(const ObBackupCleanInfo& clean_info, return ret; } -int ObBackupDataClean::get_deleted_clean_tenants(ObIArray& deleted_tenants) +int ObBackupDataClean::get_deleted_clean_tenants(ObIArray &deleted_tenants) { int ret = OB_SUCCESS; deleted_tenants.reset(); @@ -4209,7 +4428,7 @@ int ObBackupDataClean::get_deleted_clean_tenants(ObIArray& deleted_tenant_clean_infos) + ObISQLClient &trans, common::ObIArray &deleted_tenant_clean_infos) { int ret = OB_SUCCESS; ObTenantBackupCleanInfoUpdater updater; @@ -4250,7 +4469,7 @@ int ObBackupDataClean::get_deleted_tenant_clean_infos( } int ObBackupDataClean::schedule_deleted_clean_tenants( - const common::ObIArray& deleted_clean_tenants) + const common::ObIArray &deleted_clean_tenants) { int ret = OB_SUCCESS; ObTenantBackupCleanInfoUpdater updater; @@ -4277,7 +4496,7 @@ int ObBackupDataClean::schedule_deleted_clean_tenants( LOG_WARN("failed to init tenant backup clean info updater", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < deleted_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_clean_tenant = deleted_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_clean_tenant = deleted_clean_tenants.at(i); ObBackupCleanInfo clean_info = sys_clean_info; clean_info.tenant_id_ = simple_clean_tenant.tenant_id_; if (OB_FAIL(updater.insert_backup_clean_info(OB_SYS_TENANT_ID, clean_info))) { @@ -4300,8 +4519,8 @@ int ObBackupDataClean::schedule_deleted_clean_tenants( return ret; } -int ObBackupDataClean::get_clean_tenants(const common::ObIArray& clean_tenants, - common::ObIArray& normal_clean_tenants, ObBackupDataCleanTenant& sys_clean_tenant) +int ObBackupDataClean::get_clean_tenants(const common::ObIArray &clean_tenants, + common::ObIArray &normal_clean_tenants, ObBackupDataCleanTenant &sys_clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -4309,8 +4528,8 @@ int ObBackupDataClean::get_clean_tenants(const common::ObIArray& backup_element_array = clean_tenant.backup_element_array_; + const ObIArray &backup_element_array = clean_tenant.backup_element_array_; for (int64_t i = 0; OB_SUCC(ret) && i < backup_element_array.count(); ++i) { - const ObBackupDataCleanElement& clean_element = backup_element_array.at(i); + const ObBackupDataCleanElement &clean_element = backup_element_array.at(i); if (OB_FAIL(clean_tenant_backup_dir(tenant_id, clean_element))) { LOG_WARN("failed to clean tenant backup dir", K(ret), K(tenant_id), K(clean_element)); } @@ -4408,13 +4627,13 @@ int ObBackupDataClean::try_clean_tenant_backup_dir(const ObBackupDataCleanTenant return ret; } -int ObBackupDataClean::clean_tenant_backup_dir(const uint64_t tenant_id, const ObBackupDataCleanElement& clean_element) +int ObBackupDataClean::clean_tenant_backup_dir(const uint64_t tenant_id, const ObBackupDataCleanElement &clean_element) { int ret = OB_SUCCESS; ObClusterBackupDest cluster_backup_dest; ObBackupPath path; - const char* storage_info = clean_element.backup_dest_.storage_info_; - const ObStorageType& device_type = clean_element.backup_dest_.device_type_; + const char *storage_info = clean_element.backup_dest_.storage_info_; + const ObStorageType &device_type = clean_element.backup_dest_.device_type_; if (!is_inited_) { ret = OB_NOT_INIT; @@ -4441,8 +4660,8 @@ int ObBackupDataClean::clean_tenant_backup_dir(const uint64_t tenant_id, const O return ret; } -int ObBackupDataClean::clean_backup_tenant_info(const ObBackupDataCleanTenant& sys_clean_tenant, - const common::ObIArray& normal_clean_tenants) +int ObBackupDataClean::clean_backup_tenant_info(const ObBackupDataCleanTenant &sys_clean_tenant, + const common::ObIArray &normal_clean_tenants) { int ret = OB_SUCCESS; @@ -4453,9 +4672,9 @@ int ObBackupDataClean::clean_backup_tenant_info(const ObBackupDataCleanTenant& s ret = OB_INVALID_ARGUMENT; LOG_WARN("try clean backup tenant get invalid argument", K(ret), K(sys_clean_tenant)); } else { - const ObIArray& backup_element_array = sys_clean_tenant.backup_element_array_; + const ObIArray &backup_element_array = sys_clean_tenant.backup_element_array_; for (int64_t i = 0; OB_SUCC(ret) && i < backup_element_array.count(); ++i) { - const ObBackupDataCleanElement& clean_element = backup_element_array.at(i); + const ObBackupDataCleanElement &clean_element = backup_element_array.at(i); if (OB_FAIL(inner_clean_backup_tenant_info(clean_element, normal_clean_tenants))) { LOG_WARN("failed to clean backup tenant info", K(ret), K(clean_element)); } @@ -4464,8 +4683,8 @@ int ObBackupDataClean::clean_backup_tenant_info(const ObBackupDataCleanTenant& s return ret; } -int ObBackupDataClean::inner_clean_backup_tenant_info(const ObBackupDataCleanElement& clean_element, - const common::ObIArray& normal_clean_tenants) +int ObBackupDataClean::inner_clean_backup_tenant_info(const ObBackupDataCleanElement &clean_element, + const common::ObIArray &normal_clean_tenants) { int ret = OB_SUCCESS; const ObStorageType device_type = clean_element.backup_dest_.device_type_; @@ -4485,7 +4704,7 @@ int ObBackupDataClean::inner_clean_backup_tenant_info(const ObBackupDataCleanEle LOG_WARN("failed to init tenant info mgr", K(ret), K(cluster_backup_dest)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < normal_clean_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& normal_clean_tenant = normal_clean_tenants.at(i); + const ObSimpleBackupDataCleanTenant &normal_clean_tenant = normal_clean_tenants.at(i); if (normal_clean_tenant.is_deleted_) { path.reset(); file_name_array.reset(); @@ -4527,7 +4746,7 @@ int ObBackupDataClean::inner_clean_backup_tenant_info(const ObBackupDataCleanEle return ret; } -int ObBackupDataClean::touch_extern_tenant_name(const ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::touch_extern_tenant_name(const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObExternTenantInfoMgr tenant_info_mgr; @@ -4545,7 +4764,7 @@ int ObBackupDataClean::touch_extern_tenant_name(const ObBackupDataCleanTenant& c for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { path.reset(); cluster_backup_dest.reset(); - const ObBackupDataCleanElement& clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDataCleanElement &clean_element = clean_tenant.backup_element_array_.at(i); const ObStorageType device_type = clean_element.backup_dest_.device_type_; if (OB_FAIL(cluster_backup_dest.set(clean_element.backup_dest_, clean_element.incarnation_))) { LOG_WARN("failed to set cluster backup dest", K(ret), K(clean_element)); @@ -4560,7 +4779,7 @@ int ObBackupDataClean::touch_extern_tenant_name(const ObBackupDataCleanTenant& c return ret; } -int ObBackupDataClean::touch_extern_clog_info(const ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::touch_extern_clog_info(const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; ObBackupPath path; @@ -4577,7 +4796,7 @@ int ObBackupDataClean::touch_extern_clog_info(const ObBackupDataCleanTenant& cle for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { path.reset(); cluster_backup_dest.reset(); - const ObBackupDataCleanElement& clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDataCleanElement &clean_element = clean_tenant.backup_element_array_.at(i); const ObStorageType device_type = clean_element.backup_dest_.device_type_; if (OB_FAIL(cluster_backup_dest.set(clean_element.backup_dest_, clean_element.incarnation_))) { LOG_WARN("failed to set cluster backup dest", K(ret), K(clean_element)); @@ -4595,9 +4814,9 @@ int ObBackupDataClean::touch_extern_clog_info(const ObBackupDataCleanTenant& cle return ret; } -int ObBackupDataClean::delete_cluster_backup_meta_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanTenant& clean_tenant, - const common::ObIArray& normal_clean_tenants) +int ObBackupDataClean::delete_cluster_backup_meta_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanTenant &clean_tenant, + const common::ObIArray &normal_clean_tenants) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -4618,7 +4837,7 @@ int ObBackupDataClean::delete_cluster_backup_meta_data(const share::ObBackupClea return ret; } -int ObBackupDataClean::get_cluster_max_succeed_backup_set(const int64_t copy_id, int64_t& backup_set_id) +int ObBackupDataClean::get_cluster_max_succeed_backup_set(const int64_t copy_id, int64_t &backup_set_id) { int ret = OB_SUCCESS; backup_set_id = 0; @@ -4642,7 +4861,7 @@ int ObBackupDataClean::get_cluster_max_succeed_backup_set(const int64_t copy_id, return ret; } -int ObBackupDataClean::inner_get_cluster_max_succeed_backup_set(int64_t& backup_set_id) +int ObBackupDataClean::inner_get_cluster_max_succeed_backup_set(int64_t &backup_set_id) { int ret = OB_SUCCESS; backup_set_id = 0; @@ -4667,7 +4886,7 @@ int ObBackupDataClean::inner_get_cluster_max_succeed_backup_set(int64_t& backup_ return ret; } -int ObBackupDataClean::inner_get_cluster_max_succeed_backup_backup_set(const int64_t copy_id, int64_t& backup_set_id) +int ObBackupDataClean::inner_get_cluster_max_succeed_backup_backup_set(const int64_t copy_id, int64_t &backup_set_id) { int ret = OB_SUCCESS; ObTenantBackupBackupsetTaskInfo task_info; @@ -4689,7 +4908,7 @@ int ObBackupDataClean::inner_get_cluster_max_succeed_backup_backup_set(const int } int ObBackupDataClean::get_log_archive_info( - const int64_t snapshot_version, const ObArray& log_infos, ObLogArchiveBackupInfo& log_info) + const int64_t snapshot_version, const ObArray &log_infos, ObLogArchiveBackupInfo &log_info) { int ret = OB_SUCCESS; log_info.reset(); @@ -4700,7 +4919,7 @@ int ObBackupDataClean::get_log_archive_info( } else if (log_infos.empty()) { } else { for (int64_t i = 0; OB_SUCC(ret) && i < log_infos.count() - 1; ++i) { - if (log_infos.at(i).status_.start_ts_ >= log_infos.at(i + 1).status_.start_ts_) { + if (log_infos.at(i).status_.start_ts_ > log_infos.at(i + 1).status_.start_ts_) { ret = OB_ERR_UNEXPECTED; LOG_WARN("log infos is not sorted by start ts", K(ret), K(log_infos)); } @@ -4719,8 +4938,8 @@ int ObBackupDataClean::get_log_archive_info( return ret; } -int ObBackupDataClean::check_backupset_continue_with_clog_data(const ObTenantBackupTaskInfo& backup_task_info, - const common::ObArray& log_archive_infos, bool& is_continue) +int ObBackupDataClean::check_backupset_continue_with_clog_data(const ObTenantBackupTaskInfo &backup_task_info, + const common::ObArray &log_archive_infos, bool &is_continue) { int ret = OB_SUCCESS; ObLogArchiveBackupInfo log_archive_info; @@ -4798,7 +5017,7 @@ int ObBackupDataClean::check_can_do_task() } int ObBackupDataClean::do_tenant_cancel_delete_backup( - const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -4818,7 +5037,7 @@ int ObBackupDataClean::do_tenant_cancel_delete_backup( return ret; } -int ObBackupDataClean::do_sys_tenant_cancel_delete_backup(const ObBackupCleanInfo& clean_info) +int ObBackupDataClean::do_sys_tenant_cancel_delete_backup(const ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; @@ -4836,7 +5055,7 @@ int ObBackupDataClean::do_sys_tenant_cancel_delete_backup(const ObBackupCleanInf return ret; } -int ObBackupDataClean::set_tenant_clean_info_cancel(const ObBackupCleanInfo& clean_info) +int ObBackupDataClean::set_tenant_clean_info_cancel(const ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; ObArray all_tenant_ids; @@ -4878,7 +5097,7 @@ int ObBackupDataClean::set_tenant_clean_info_cancel(const ObBackupCleanInfo& cle LOG_WARN("failed to get deleted tenant clean infos", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < deleted_tenant_clean_infos.count(); ++i) { - const ObBackupCleanInfo& delete_tenant_clean_info = deleted_tenant_clean_infos.at(i); + const ObBackupCleanInfo &delete_tenant_clean_info = deleted_tenant_clean_infos.at(i); if (OB_FAIL(set_deleted_tenant_cancel(delete_tenant_clean_info, trans))) { LOG_WARN("failed to set deleted tenant cancel", K(ret), K(delete_tenant_clean_info)); } @@ -4901,7 +5120,7 @@ int ObBackupDataClean::set_tenant_clean_info_cancel(const ObBackupCleanInfo& cle return ret; } -int ObBackupDataClean::set_normal_tenant_cancel(const uint64_t tenant_id, common::ObISQLClient& sys_tenant_trans) +int ObBackupDataClean::set_normal_tenant_cancel(const uint64_t tenant_id, common::ObISQLClient &sys_tenant_trans) { int ret = OB_SUCCESS; ObMySQLTransaction trans; @@ -4951,7 +5170,7 @@ int ObBackupDataClean::set_normal_tenant_cancel(const uint64_t tenant_id, common } int ObBackupDataClean::set_deleted_tenant_cancel( - const ObBackupCleanInfo& clean_info, common::ObISQLClient& sys_tenant_trans) + const ObBackupCleanInfo &clean_info, common::ObISQLClient &sys_tenant_trans) { int ret = OB_SUCCESS; ObBackupCleanInfo dest_clean_info; @@ -4976,7 +5195,7 @@ int ObBackupDataClean::set_deleted_tenant_cancel( } int ObBackupDataClean::do_normal_tenant_cancel_delete_backup( - const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant) + const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; const int32_t result = clean_info.result_ == OB_SUCCESS ? OB_CANCELED : clean_info.result_; @@ -4994,7 +5213,7 @@ int ObBackupDataClean::do_normal_tenant_cancel_delete_backup( } /*not use anymore*/ -int ObBackupDataClean::get_sys_tenant_backup_dest(hash::ObHashSet& cluster_backup_dest_set) +int ObBackupDataClean::get_sys_tenant_backup_dest(hash::ObHashSet &cluster_backup_dest_set) { int ret = OB_SUCCESS; ObArray task_infos; @@ -5044,7 +5263,7 @@ int ObBackupDataClean::get_sys_tenant_backup_dest(hash::ObHashSet& task_infos, - common::ObIArray& log_archive_infos) +int ObBackupDataClean::do_scheduler_normal_tenant(share::ObBackupCleanInfo &clean_info, + ObBackupDataCleanTenant &clean_tenant, common::ObIArray &task_infos, + common::ObIArray &log_archive_infos) { int ret = OB_SUCCESS; clean_tenant.backup_element_array_.reset(); ObBackupCleanInfo sys_clean_info; clean_info.reset(); - ObSimpleBackupDataCleanTenant& simple_clean_tenant = clean_tenant.simple_clean_tenant_; + ObSimpleBackupDataCleanTenant &simple_clean_tenant = clean_tenant.simple_clean_tenant_; const bool for_update = false; if (!is_inited_) { @@ -5100,15 +5319,15 @@ int ObBackupDataClean::do_scheduler_normal_tenant(share::ObBackupCleanInfo& clea return ret; } -int ObBackupDataClean::do_scheduler_deleted_tenant(share::ObBackupCleanInfo& clean_info, - ObBackupDataCleanTenant& clean_tenant, common::ObIArray& task_infos, - common::ObIArray& log_archive_infos) +int ObBackupDataClean::do_scheduler_deleted_tenant(share::ObBackupCleanInfo &clean_info, + ObBackupDataCleanTenant &clean_tenant, common::ObIArray &task_infos, + common::ObIArray &log_archive_infos) { int ret = OB_SUCCESS; clean_tenant.backup_element_array_.reset(); ObBackupCleanInfo sys_clean_info; clean_info.reset(); - ObSimpleBackupDataCleanTenant& simple_clean_tenant = clean_tenant.simple_clean_tenant_; + ObSimpleBackupDataCleanTenant &simple_clean_tenant = clean_tenant.simple_clean_tenant_; const bool for_update = false; if (!is_inited_) { @@ -5133,9 +5352,9 @@ int ObBackupDataClean::do_scheduler_deleted_tenant(share::ObBackupCleanInfo& cle return ret; } -int ObBackupDataClean::do_inner_scheduler_delete_tenant(const ObClusterBackupDest& cluster_backup_dest, - ObBackupDataCleanTenant& clean_tenant, common::ObIArray& task_infos, - common::ObIArray& log_archive_infos) +int ObBackupDataClean::do_inner_scheduler_delete_tenant(const ObClusterBackupDest &cluster_backup_dest, + ObBackupDataCleanTenant &clean_tenant, common::ObIArray &task_infos, + common::ObIArray &log_archive_infos) { int ret = OB_SUCCESS; ObExternBackupInfoMgr extern_backup_info_mgr; @@ -5162,7 +5381,7 @@ int ObBackupDataClean::do_inner_scheduler_delete_tenant(const ObClusterBackupDes LOG_WARN("failed to get log archive status", K(ret), K(clean_tenant)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < extern_backup_infos.count(); ++i) { - const ObExternBackupInfo& extern_backup_info = extern_backup_infos.at(i); + const ObExternBackupInfo &extern_backup_info = extern_backup_infos.at(i); ObTenantBackupTaskInfo task_info; task_info.cluster_id_ = cluster_backup_dest.cluster_id_; task_info.tenant_id_ = clean_tenant.simple_clean_tenant_.tenant_id_; @@ -5183,7 +5402,7 @@ int ObBackupDataClean::do_inner_scheduler_delete_tenant(const ObClusterBackupDes } for (int64_t i = 0; OB_SUCC(ret) && i < status_array.count(); ++i) { - ObTenantLogArchiveStatus& status = status_array.at(i); + ObTenantLogArchiveStatus &status = status_array.at(i); // set delete tenant archive status stop status.status_ = ObLogArchiveStatus::STOP; ObLogArchiveBackupInfo archive_info; @@ -5203,7 +5422,7 @@ int ObBackupDataClean::do_inner_scheduler_delete_tenant(const ObClusterBackupDes return ret; } -int ObBackupDataClean::check_backup_dest_lifecycle(const ObBackupDataCleanTenant& clean_tenant) +int ObBackupDataClean::check_backup_dest_lifecycle(const ObBackupDataCleanTenant &clean_tenant) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -5221,8 +5440,8 @@ int ObBackupDataClean::check_backup_dest_lifecycle(const ObBackupDataCleanTenant LOG_WARN("failed to set current backup dest", K(ret), K(backup_dest_str)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < clean_tenant.backup_element_array_.count(); ++i) { - const ObBackupDataCleanElement& data_clean_element = clean_tenant.backup_element_array_.at(i); - const ObBackupDest& backup_dest = data_clean_element.backup_dest_; + const ObBackupDataCleanElement &data_clean_element = clean_tenant.backup_element_array_.at(i); + const ObBackupDest &backup_dest = data_clean_element.backup_dest_; if (current_backup_dest == backup_dest) { if (OB_SUCCESS != (tmp_ret = ObBackupUtil::check_backup_dest_lifecycle(backup_dest, is_update_reserved_backup_timestamp_))) { @@ -5234,10 +5453,10 @@ int ObBackupDataClean::check_backup_dest_lifecycle(const ObBackupDataCleanTenant return ret; } -int ObBackupDataClean::get_all_tenant_backup_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos) +int ObBackupDataClean::get_all_tenant_backup_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos) { int ret = OB_SUCCESS; @@ -5271,10 +5490,10 @@ int ObBackupDataClean::get_all_tenant_backup_infos(const share::ObBackupCleanInf return ret; } -int ObBackupDataClean::get_delete_backup_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos) +int ObBackupDataClean::get_delete_backup_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos) { int ret = OB_SUCCESS; tenant_backup_infos.reset(); @@ -5303,10 +5522,10 @@ int ObBackupDataClean::get_delete_backup_infos(const share::ObBackupCleanInfo& c return ret; } -int ObBackupDataClean::get_delete_obsolete_backup_set_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos) +int ObBackupDataClean::get_delete_obsolete_backup_set_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos) { int ret = OB_SUCCESS; tenant_backup_infos.reset(); @@ -5326,10 +5545,10 @@ int ObBackupDataClean::get_delete_obsolete_backup_set_infos(const share::ObBacku return ret; } -int ObBackupDataClean::get_delete_obsolete_backup_backupset_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos) +int ObBackupDataClean::get_delete_obsolete_backup_backupset_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos) { int ret = OB_SUCCESS; tenant_backup_infos.reset(); @@ -5351,9 +5570,9 @@ int ObBackupDataClean::get_delete_obsolete_backup_backupset_infos(const share::O return ret; } -int ObBackupDataClean::get_tenant_backup_task_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_infos) +int ObBackupDataClean::get_tenant_backup_task_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_infos) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater updater; @@ -5386,7 +5605,7 @@ int ObBackupDataClean::get_tenant_backup_task_infos(const share::ObBackupCleanIn if (OB_FAIL(ret)) { } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_tenant_infos.count(); ++i) { - const ObTenantBackupTaskInfo& tenant_task_info = tmp_tenant_infos.at(i); + const ObTenantBackupTaskInfo &tenant_task_info = tmp_tenant_infos.at(i); if (clean_info.is_delete_obsolete_backup() && tenant_task_info.backup_dest_ != backup_dest_) { // do nothing } else if (OB_FAIL(tenant_infos.push_back(tenant_task_info))) { @@ -5400,9 +5619,9 @@ int ObBackupDataClean::get_tenant_backup_task_infos(const share::ObBackupCleanIn return ret; } -int ObBackupDataClean::get_tenant_backup_backupset_task_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_infos) +int ObBackupDataClean::get_tenant_backup_backupset_task_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_infos) { int ret = OB_SUCCESS; ObArray tenant_backupset_infos; @@ -5430,7 +5649,7 @@ int ObBackupDataClean::get_tenant_backup_backupset_task_infos(const share::ObBac LOG_WARN("failed to get full backupset task items", KR(ret), K(clean_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < his_tenant_backupset_infos.count(); ++i) { - const ObTenantBackupTaskInfo& backup_task_info = his_tenant_backupset_infos.at(i); + const ObTenantBackupTaskInfo &backup_task_info = his_tenant_backupset_infos.at(i); if ((clean_info.is_delete_obsolete_backup_backup() && backup_task_info.backup_dest_ != backup_backup_dest_) || (clean_info.copy_id_ > 0 && backup_task_info.copy_id_ != clean_info.copy_id_)) { // do nothing @@ -5441,7 +5660,7 @@ int ObBackupDataClean::get_tenant_backup_backupset_task_infos(const share::ObBac for (int64_t i = 0; OB_SUCC(ret) && i < tenant_backupset_infos.count(); ++i) { tenant_info.reset(); - const ObTenantBackupBackupsetTaskInfo& backupset_info = tenant_backupset_infos.at(i); + const ObTenantBackupBackupsetTaskInfo &backupset_info = tenant_backupset_infos.at(i); if (OB_FAIL(backupset_info.convert_to_backup_task_info(tenant_info))) { LOG_WARN("failed to convert to backup task info", KR(ret), K(backupset_info)); } else if ((clean_info.is_delete_obsolete_backup_backup() && tenant_info.backup_dest_ != backup_backup_dest_) || @@ -5452,23 +5671,18 @@ int ObBackupDataClean::get_tenant_backup_backupset_task_infos(const share::ObBac } } - for (int64_t i = tenant_infos.count() - 1; OB_SUCC(ret) && i >= 0; --i) { - const ObTenantBackupTaskInfo& tmp_info = tenant_infos.at(i); - if (i == tenant_infos.count() - 1) { - prev_task_info = tmp_info; - } else if (prev_task_info.is_same_task(tmp_info) && OB_FAIL(tenant_infos.remove(i))) { - LOG_WARN("failed to remove task", K(ret), K(tmp_info), K(prev_task_info)); - } else { - prev_task_info = tmp_info; + if (OB_SUCC(ret)) { + if (OB_FAIL(duplicate_task_info(tenant_infos))) { + LOG_WARN("failed to duplicate task infos", K(ret)); } } } return ret; } -int ObBackupDataClean::get_tenant_backup_log_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_log_infos) +int ObBackupDataClean::get_tenant_backup_log_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_log_infos) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_archive_info_mgr; @@ -5503,7 +5717,7 @@ int ObBackupDataClean::get_tenant_backup_log_infos(const share::ObBackupCleanInf if (OB_FAIL(ret)) { } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_log_archive_infos.count(); ++i) { - const ObLogArchiveBackupInfo& log_archive_info = tmp_log_archive_infos.at(i); + const ObLogArchiveBackupInfo &log_archive_info = tmp_log_archive_infos.at(i); ObBackupDest backup_dest; if (ObLogArchiveStatus::DOING != log_archive_info.status_.status_ && ObLogArchiveStatus::INTERRUPTED != log_archive_info.status_.status_ && @@ -5527,9 +5741,9 @@ int ObBackupDataClean::get_tenant_backup_log_infos(const share::ObBackupCleanInf // NOTE:step1 get log archive info from piece because if piece_interval > 0, // backup backup log will not record log archive info into history, so we use piece infos to get log archive info -int ObBackupDataClean::get_tenant_backup_backuplog_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_log_infos) +int ObBackupDataClean::get_tenant_backup_backuplog_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_log_infos) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr log_archive_info_mgr; @@ -5571,7 +5785,7 @@ int ObBackupDataClean::get_tenant_backup_backuplog_infos(const share::ObBackupCl LOG_WARN("failed to get backup log archive info from piece infos", K(ret), K(clean_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_log_archive_infos.count(); ++i) { - const ObLogArchiveBackupInfo& log_archive_info = tmp_log_archive_infos.at(i); + const ObLogArchiveBackupInfo &log_archive_info = tmp_log_archive_infos.at(i); ObBackupDest backup_dest; if (ObLogArchiveStatus::DOING != log_archive_info.status_.status_ && ObLogArchiveStatus::INTERRUPTED != log_archive_info.status_.status_ && @@ -5591,7 +5805,7 @@ int ObBackupDataClean::get_tenant_backup_backuplog_infos(const share::ObBackupCl return ret; } -int ObBackupDataClean::get_backup_dest_option(const ObBackupDest& backup_dest, ObBackupDestOpt& backup_dest_option) +int ObBackupDataClean::get_backup_dest_option(const ObBackupDest &backup_dest, ObBackupDestOpt &backup_dest_option) { int ret = OB_SUCCESS; backup_dest_option.reset(); @@ -5649,7 +5863,7 @@ int ObBackupDataClean::set_current_backup_dest() } int ObBackupDataClean::get_clean_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map) + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; ObArray tenant_backup_tasks; @@ -5681,7 +5895,7 @@ int ObBackupDataClean::get_clean_tenants_from_history_table( } int ObBackupDataClean::get_delete_backup_set_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map) + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; const bool for_update = false; @@ -5705,7 +5919,7 @@ int ObBackupDataClean::get_delete_backup_set_tenants_from_history_table( } int ObBackupDataClean::get_delete_backup_piece_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map) + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; ObArray tenant_ids; @@ -5727,7 +5941,7 @@ int ObBackupDataClean::get_delete_backup_piece_tenants_from_history_table( } int ObBackupDataClean::get_delete_backup_round_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map) + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; const bool for_update = false; @@ -5749,7 +5963,7 @@ int ObBackupDataClean::get_delete_backup_round_tenants_from_history_table( } int ObBackupDataClean::get_delete_obsolete_backup_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map) + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; ObArray log_archive_tenant_ids; @@ -5780,8 +5994,8 @@ int ObBackupDataClean::get_delete_obsolete_backup_tenants_from_history_table( return ret; } -int ObBackupDataClean::set_history_tenant_info_into_map(const common::ObIArray& tenant_ids, - hash::ObHashMap& clean_tenants_map) +int ObBackupDataClean::set_history_tenant_info_into_map(const common::ObIArray &tenant_ids, + hash::ObHashMap &clean_tenants_map) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -5846,7 +6060,7 @@ void ObBackupDataClean::update_prepare_flag(const bool is_prepare_flag) } } -int ObBackupDataClean::commit_trans(ObMySQLTransaction& trans) +int ObBackupDataClean::commit_trans(ObMySQLTransaction &trans) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -5863,7 +6077,7 @@ int ObBackupDataClean::commit_trans(ObMySQLTransaction& trans) return ret; } -int ObBackupDataClean::start_trans(ObTimeoutCtx& timeout_ctx, ObMySQLTransaction& trans) +int ObBackupDataClean::start_trans(ObTimeoutCtx &timeout_ctx, ObMySQLTransaction &trans) { int ret = OB_SUCCESS; const int64_t MAX_EXECUTE_TIMEOUT_US = 600L * 1000 * 1000; // 600s @@ -5879,8 +6093,8 @@ int ObBackupDataClean::start_trans(ObTimeoutCtx& timeout_ctx, ObMySQLTransaction } int ObBackupDataClean::check_can_delete_extern_info_file(const uint64_t tenant_id, - const ObClusterBackupDest& current_backup_dest, const bool is_backup_backup, const ObBackupPath& path, - bool& can_delete_file) + const ObClusterBackupDest ¤t_backup_dest, const bool is_backup_backup, const ObBackupPath &path, + bool &can_delete_file) { int ret = OB_SUCCESS; can_delete_file = false; @@ -5938,7 +6152,7 @@ int ObBackupDataClean::check_can_delete_extern_info_file(const uint64_t tenant_i return ret; } -int ObBackupDataClean::get_backup_set_file_copies_num(const ObTenantBackupTaskInfo& task_info, int64_t& copies_num) +int ObBackupDataClean::get_backup_set_file_copies_num(const ObTenantBackupTaskInfo &task_info, int64_t &copies_num) { int ret = OB_SUCCESS; ObBackupTaskHistoryUpdater updater; @@ -5957,7 +6171,7 @@ int ObBackupDataClean::get_backup_set_file_copies_num(const ObTenantBackupTaskIn LOG_WARN("failed to get backup set file info copies", K(ret), K(task_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_file_infos.count(); ++i) { - const ObBackupSetFileInfo& backup_set_file_info = backup_set_file_infos.at(i); + const ObBackupSetFileInfo &backup_set_file_info = backup_set_file_infos.at(i); if (0 == backup_set_file_info.copy_id_) { if (ObBackupFileStatus::BACKUP_FILE_DELETED == backup_set_file_info.file_status_ || OB_SUCCESS != backup_set_file_info.result_) { @@ -5981,7 +6195,7 @@ int ObBackupDataClean::get_backup_set_file_copies_num(const ObTenantBackupTaskIn return ret; } -int ObBackupDataClean::get_backup_piece_file_copies_num(const ObBackupPieceInfo& backup_piece_info, int64_t& copies_num) +int ObBackupDataClean::get_backup_piece_file_copies_num(const ObBackupPieceInfo &backup_piece_info, int64_t &copies_num) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr archive_backup_info_mgr; @@ -6002,7 +6216,7 @@ int ObBackupDataClean::get_backup_piece_file_copies_num(const ObBackupPieceInfo& LOG_WARN("failed to get backup piece copy list", K(ret), K(backup_piece_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_piece_infos.count(); ++i) { - const ObBackupPieceInfo& tmp_piece_info = backup_piece_infos.at(i); + const ObBackupPieceInfo &tmp_piece_info = backup_piece_infos.at(i); if (0 == tmp_piece_info.key_.copy_id_) { if (ObBackupFileStatus::BACKUP_FILE_DELETED == tmp_piece_info.file_status_) { ret = OB_ERR_UNEXPECTED; @@ -6111,8 +6325,8 @@ int ObBackupDataClean::prepare_deleted_tenant_backup_infos() return ret; } -int ObBackupDataClean::add_backup_infos_for_compatible(const ObClusterBackupDest& cluster_backup_dest, - const common::ObIArray& simple_tenants) +int ObBackupDataClean::add_backup_infos_for_compatible(const ObClusterBackupDest &cluster_backup_dest, + const common::ObIArray &simple_tenants) { int ret = OB_SUCCESS; hash::ObHashMap min_backup_set_log_ts; @@ -6131,7 +6345,7 @@ int ObBackupDataClean::add_backup_infos_for_compatible(const ObClusterBackupDest LOG_WARN("failed to init updater", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < simple_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_tenant = simple_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_tenant = simple_tenants.at(i); if (OB_SYS_TENANT_ID == simple_tenant.tenant_id_) { // do nothing } else if (OB_FAIL(add_backup_infos_for_compatible_(cluster_backup_dest, simple_tenant, min_backup_set_log_ts))) { @@ -6172,8 +6386,8 @@ int ObBackupDataClean::add_backup_infos_for_compatible(const ObClusterBackupDest return ret; } -int ObBackupDataClean::add_backup_infos_for_compatible_(const ObClusterBackupDest& cluster_backup_dest, - const ObSimpleBackupDataCleanTenant& simple_tenant, hash::ObHashMap& min_backup_set_log_ts) +int ObBackupDataClean::add_backup_infos_for_compatible_(const ObClusterBackupDest &cluster_backup_dest, + const ObSimpleBackupDataCleanTenant &simple_tenant, hash::ObHashMap &min_backup_set_log_ts) { int ret = OB_SUCCESS; ObExternBackupInfoMgr backup_info_mgr; @@ -6197,7 +6411,7 @@ int ObBackupDataClean::add_backup_infos_for_compatible_(const ObClusterBackupDes LOG_WARN("failed to get extern backup infos", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < extern_backup_infos.count(); ++i) { - const ObExternBackupInfo& extern_backup_info = extern_backup_infos.at(i); + const ObExternBackupInfo &extern_backup_info = extern_backup_infos.at(i); ObTenantBackupTaskInfo tmp_backup_task_info; if (OB_FAIL(check_can_do_task())) { LOG_WARN("failed to check can do task", K(ret)); @@ -6215,7 +6429,7 @@ int ObBackupDataClean::add_backup_infos_for_compatible_(const ObClusterBackupDes if (OB_SUCC(ret)) { // add inner table for (int64_t i = 0; OB_SUCC(ret) && i < backup_task_infos.count(); ++i) { - ObTenantBackupTaskInfo& task_info = backup_task_infos.at(i); + ObTenantBackupTaskInfo &task_info = backup_task_infos.at(i); set_file_info.reset(); int64_t start_replay_log_ts = 0; if (OB_FAIL(check_can_do_task())) { @@ -6264,8 +6478,8 @@ int ObBackupDataClean::add_backup_infos_for_compatible_(const ObClusterBackupDes } int ObBackupDataClean::get_backup_task_info_from_extern_info(const uint64_t tenant_id, - const ObClusterBackupDest& cluster_backup_dest, const ObExternBackupInfo& extern_backup_info, - ObTenantBackupTaskInfo& backup_task_info) + const ObClusterBackupDest &cluster_backup_dest, const ObExternBackupInfo &extern_backup_info, + ObTenantBackupTaskInfo &backup_task_info) { int ret = OB_SUCCESS; backup_task_info.reset(); @@ -6312,8 +6526,8 @@ int ObBackupDataClean::get_backup_task_info_from_extern_info(const uint64_t tena return ret; } -int ObBackupDataClean::add_log_archive_infos_for_compatible(const ObClusterBackupDest& cluster_backup_dest, - const common::ObIArray& simple_tenants) +int ObBackupDataClean::add_log_archive_infos_for_compatible(const ObClusterBackupDest &cluster_backup_dest, + const common::ObIArray &simple_tenants) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -6321,7 +6535,7 @@ int ObBackupDataClean::add_log_archive_infos_for_compatible(const ObClusterBacku LOG_WARN("backup data clean do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < simple_tenants.count(); ++i) { - const ObSimpleBackupDataCleanTenant& simple_tenant = simple_tenants.at(i); + const ObSimpleBackupDataCleanTenant &simple_tenant = simple_tenants.at(i); if (!simple_tenant.is_deleted_) { // do nothing } else if (OB_FAIL(add_log_archive_infos_for_compatible_(cluster_backup_dest, simple_tenant))) { @@ -6333,7 +6547,7 @@ int ObBackupDataClean::add_log_archive_infos_for_compatible(const ObClusterBacku } int ObBackupDataClean::add_log_archive_infos_for_compatible_( - const ObClusterBackupDest& cluster_backup_dest, const ObSimpleBackupDataCleanTenant& simple_tenant) + const ObClusterBackupDest &cluster_backup_dest, const ObSimpleBackupDataCleanTenant &simple_tenant) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr mgr; @@ -6357,7 +6571,7 @@ int ObBackupDataClean::add_log_archive_infos_for_compatible_( for (int64_t i = 0; OB_SUCC(ret) && i < archive_status_array.count(); ++i) { archive_info.reset(); piece.reset(); - ObTenantLogArchiveStatus& archive_status = archive_status_array.at(i); + ObTenantLogArchiveStatus &archive_status = archive_status_array.at(i); archive_status.status_ = ObLogArchiveStatus::STOP; archive_info.status_ = archive_status; @@ -6396,7 +6610,7 @@ int ObBackupDataClean::add_log_archive_infos_for_compatible_( } int ObBackupDataClean::get_backup_round_copies_num( - const ObLogArchiveBackupInfo& archive_backup_info, int64_t& copies_num) + const ObLogArchiveBackupInfo &archive_backup_info, int64_t &copies_num) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr archive_backup_info_mgr; @@ -6421,7 +6635,7 @@ int ObBackupDataClean::get_backup_round_copies_num( LOG_WARN("failed to get round backup piece infos", K(ret), K(archive_backup_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_piece_infos.count(); ++i) { - const ObBackupPieceInfo& piece_info = backup_piece_infos.at(i); + const ObBackupPieceInfo &piece_info = backup_piece_infos.at(i); int64_t tmp_copies_num = 0; if (OB_FAIL(get_backup_piece_file_copies_num(piece_info, tmp_copies_num))) { LOG_WARN("failed to get backup piece file copies num", K(ret), K(piece_info)); @@ -6480,7 +6694,7 @@ int ObBackupDataClean::upgrade_backup_info() } int ObBackupDataClean::check_backup_set_id_can_be_deleted( - const uint64_t tenant_id, const ObBackupSetId& backup_set_id, bool& can_deleted) + const uint64_t tenant_id, const ObBackupSetId &backup_set_id, bool &can_deleted) { int ret = OB_SUCCESS; can_deleted = false; @@ -6506,7 +6720,7 @@ int ObBackupDataClean::check_backup_set_id_can_be_deleted( return ret; } -int ObBackupDataClean::add_deleting_backup_set_id_into_set(const uint64_t tenant_id, const ObBackupSetId& backup_set_id) +int ObBackupDataClean::add_deleting_backup_set_id_into_set(const uint64_t tenant_id, const ObBackupSetId &backup_set_id) { int ret = OB_SUCCESS; const bool overwirte_key = true; @@ -6524,7 +6738,7 @@ int ObBackupDataClean::add_deleting_backup_set_id_into_set(const uint64_t tenant return ret; } -int ObBackupDataClean::remove_delete_expired_data_snapshot_(const ObSimpleBackupDataCleanTenant& simple_tenant) +int ObBackupDataClean::remove_delete_expired_data_snapshot_(const ObSimpleBackupDataCleanTenant &simple_tenant) { int ret = OB_SUCCESS; ObBackupInfoManager info_manager; @@ -6545,7 +6759,7 @@ int ObBackupDataClean::remove_delete_expired_data_snapshot_(const ObSimpleBackup return ret; } -int ObBackupDataClean::set_comment(ObBackupCleanInfo::Comment& comment) +int ObBackupDataClean::set_comment(ObBackupCleanInfo::Comment &comment) { int ret = OB_SUCCESS; char ip[common::OB_MAX_SERVER_ADDR_SIZE] = ""; @@ -6576,7 +6790,7 @@ int ObBackupDataClean::set_comment(ObBackupCleanInfo::Comment& comment) return ret; } -int ObBackupDataClean::set_error_msg(const int32_t result, ObBackupCleanInfo::ErrorMsg& error_msg) +int ObBackupDataClean::set_error_msg(const int32_t result, ObBackupCleanInfo::ErrorMsg &error_msg) { int ret = OB_SUCCESS; error_msg.reset(); @@ -6589,14 +6803,14 @@ int ObBackupDataClean::set_error_msg(const int32_t result, ObBackupCleanInfo::Er return ret; } -int ObBackupDataClean::prepare_delete_backup_set(const ObBackupCleanInfo& sys_clean_info) +int ObBackupDataClean::prepare_delete_backup_set(const ObBackupCleanInfo &sys_clean_info) { int ret = OB_SUCCESS; const ObBackupFileStatus::STATUS file_status = ObBackupFileStatus::BACKUP_FILE_DELETING; ObArray backup_set_file_infos; - const ObBackupDest* backup_dest_ptr = NULL; sys_tenant_deleted_backup_set_.reuse(); const bool is_backup_backup = sys_clean_info.is_delete_obsolete_backup_backup(); + const ObBackupDest *backup_dest_ptr = is_backup_backup ? &backup_backup_dest_ : &backup_dest_; const bool overwirte_key = true; ObBackupDest backup_dest; if (!is_inited_) { @@ -6620,7 +6834,7 @@ int ObBackupDataClean::prepare_delete_backup_set(const ObBackupCleanInfo& sys_cl // do nothing } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_file_infos.count(); ++i) { - const ObBackupSetFileInfo& backup_set_file_info = backup_set_file_infos.at(i); + const ObBackupSetFileInfo &backup_set_file_info = backup_set_file_infos.at(i); backup_dest.reset(); if (OB_FAIL(backup_dest.set(backup_set_file_info.backup_dest_.ptr()))) { LOG_WARN("failed to set backup dest", K(ret), K(backup_set_file_info)); @@ -6639,5 +6853,126 @@ int ObBackupDataClean::prepare_delete_backup_set(const ObBackupCleanInfo& sys_cl return ret; } +int ObBackupDataClean::prepare_delete_backup_piece_and_round(const ObBackupCleanInfo &sys_clean_info) +{ + int ret = OB_SUCCESS; + const ObBackupFileStatus::STATUS file_status = ObBackupFileStatus::BACKUP_FILE_DELETING; + ObLogArchiveBackupInfoMgr log_archive_info_mgr; + ObArray backup_piece_infos; + ObArray archive_infos; + const bool is_backup_backup = sys_clean_info.is_delete_obsolete_backup_backup(); + const ObBackupDest *backup_dest_ptr = is_backup_backup ? &backup_backup_dest_ : &backup_dest_; + const bool overwrite_key = true; + const bool for_update = false; + ObBackupDest backup_dest; + ObSimplePieceKey simple_piece_key; + ObSimpleArchiveRound simple_archive_round; + + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("backup data clean do not init", K(ret)); + } else if (ObBackupCleanInfoStatus::DOING != sys_clean_info.status_) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("prepare delete backup set get invalid argument", K(ret), K(sys_clean_info)); + } else if (!sys_clean_info.is_delete_obsolete() || !backup_dest_ptr->is_valid()) { + // do nothing + } else if (is_backup_backup && OB_FAIL(log_archive_info_mgr.set_backup_backup())) { + LOG_WARN("failed to set backup backup", K(ret)); + } else if (OB_FAIL(log_archive_info_mgr.get_tenant_backup_piece_infos_with_file_status(*sql_proxy_, + OB_START_INCARNATION, + sys_clean_info.tenant_id_, + file_status, + is_backup_backup, + backup_piece_infos))) { + LOG_WARN("failed to get tenant backup piece infos with file stauts", K(ret), K(sys_clean_info)); + } else if (OB_FAIL(log_archive_info_mgr.get_backup_log_archive_history_infos( + *sql_proxy_, sys_clean_info.tenant_id_, for_update, archive_infos))) { + LOG_WARN("failed to get backup log archive history infos", K(ret), K(sys_clean_info)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < backup_piece_infos.count(); ++i) { + const ObBackupPieceInfo &backup_piece_info = backup_piece_infos.at(i); + backup_dest.reset(); + simple_piece_key.reset(); + if (OB_FAIL(backup_dest.set(backup_piece_info.backup_dest_.ptr()))) { + LOG_WARN("failed to set backup dest", K(ret), K(backup_piece_info)); + } else if (backup_dest != *backup_dest_ptr) { + // do nothing + } else if ((backup_piece_info.key_.copy_id_ == 0 && !is_backup_backup) || + (backup_piece_info.key_.copy_id_ > 0 && is_backup_backup)) { + simple_piece_key.backup_piece_id_ = backup_piece_info.key_.backup_piece_id_; + simple_piece_key.copy_id_ = backup_piece_info.key_.copy_id_; + simple_piece_key.incarnation_ = backup_piece_info.key_.incarnation_; + simple_piece_key.round_id_ = backup_piece_info.key_.round_id_; + if (OB_FAIL(sys_tenant_deleted_backup_piece_.set_refactored_1(simple_piece_key, overwrite_key))) { + LOG_WARN("failed to set tenant deleted backup piece", K(ret), K(simple_piece_key)); + } + } + } + + for (int64_t i = 0; OB_SUCC(ret) && i < archive_infos.count(); ++i) { + const ObLogArchiveBackupInfo &archive_info = archive_infos.at(i); + backup_dest.reset(); + simple_archive_round.reset(); + if (OB_FAIL(backup_dest.set(archive_info.backup_dest_))) { + LOG_WARN("failed to set backup dest", K(ret), K(archive_info)); + } else if (backup_dest != *backup_dest_ptr || !archive_info.status_.is_mark_deleted_) { + // do nothing + } else if ((archive_info.status_.copy_id_ == 0 && !is_backup_backup) || + (archive_info.status_.copy_id_ > 0 && is_backup_backup)) { + simple_archive_round.copy_id_ = archive_info.status_.copy_id_; + simple_archive_round.incarnation_ = archive_info.status_.incarnation_; + simple_archive_round.round_id_ = archive_info.status_.round_; + if (OB_FAIL(sys_tenant_deleted_backup_round_.set_refactored_1(simple_archive_round, overwrite_key))) { + LOG_WARN("failed to set tenant deleted backup round", K(ret), K(simple_archive_round)); + } + } + } + } + return ret; +} + +int ObBackupDataClean::duplicate_task_info(common::ObIArray &task_infos) +{ + int ret = OB_SUCCESS; + int64_t step = 0; + ObHashSet task_infos_set; + ObArray tmp_task_infos; + + if (!is_inited_) { + ret = OB_NOT_INIT; + LOG_WARN("backup data clean do not init", K(ret)); + } else if (task_infos.empty()) { + // do nothing + } else if (OB_FAIL(task_infos_set.create(task_infos.count()))) { + LOG_WARN("failed to create task info set", K(ret)); + } else { + // remove same tasks + for (int64_t i = task_infos.count() - 1; OB_SUCC(ret) && i >= 0; --i) { + const ObTenantBackupTaskInfo &tmp_info = task_infos.at(i); + int hash_ret = task_infos_set.exist_refactored(tmp_info); + if (OB_HASH_NOT_EXIST == hash_ret) { + if (OB_FAIL(task_infos_set.set_refactored(tmp_info))) { + LOG_WARN("failed to set task info into set", K(ret), K(tmp_info)); + } else if (OB_FAIL(tmp_task_infos.push_back(tmp_info))) { + LOG_WARN("failed to push tmp info into array", K(ret), K(tmp_info)); + } + } else if (OB_HASH_EXIST == hash_ret) { + // do nothing + } else { + ret = OB_SUCCESS == hash_ret ? OB_ERR_UNEXPECTED : hash_ret; + } + } + + if (OB_SUCC(ret)) { + CompareBackupTaskInfo backup_task_cmp; + std::sort(tmp_task_infos.begin(), tmp_task_infos.end(), backup_task_cmp); + if (OB_FAIL(task_infos.assign(tmp_task_infos))) { + LOG_WARN("failed to assign task infos", K(ret), K(tmp_task_infos)); + } + } + } + return ret; +} + } // namespace rootserver } // namespace oceanbase diff --git a/src/rootserver/ob_backup_data_clean.h b/src/rootserver/ob_backup_data_clean.h index d126476c2324aa222a017e012756fe83edefaa13..b588b5e6b677be53cfb3324ea4ca4f9428cd0ea3 100644 --- a/src/rootserver/ob_backup_data_clean.h +++ b/src/rootserver/ob_backup_data_clean.h @@ -47,7 +47,7 @@ namespace rootserver { class ObBackupDataCleanIdling : public ObThreadIdling { public: - explicit ObBackupDataCleanIdling(volatile bool& stop) : ObThreadIdling(stop) + explicit ObBackupDataCleanIdling(volatile bool &stop) : ObThreadIdling(stop) {} virtual int64_t get_idle_interval_us(); }; @@ -56,8 +56,8 @@ class ObBackupDataClean : public ObRsReentrantThread { public: ObBackupDataClean(); virtual ~ObBackupDataClean(); - int init(share::schema::ObMultiVersionSchemaService& schema_service, ObMySQLProxy& sql_proxy, - share::ObIBackupLeaseService& backup_lease_service); + int init(share::schema::ObMultiVersionSchemaService &schema_service, ObMySQLProxy &sql_proxy, + share::ObIBackupLeaseService &backup_lease_service); virtual void run3() override; virtual int blocking_run() override { @@ -74,7 +74,7 @@ public: return is_working_; } int start() override; - share::ObIBackupLeaseService* get_backup_lease_service() + share::ObIBackupLeaseService *get_backup_lease_service() { return backup_lease_service_; } @@ -82,363 +82,382 @@ public: { return is_update_reserved_backup_timestamp_; } - share::ObBackupDest& get_backup_dest() + share::ObBackupDest &get_backup_dest() { return backup_dest_; } - share::ObBackupDest& get_backup_backup_dest() + share::ObBackupDest &get_backup_backup_dest() { return backup_backup_dest_; } private: - int get_need_clean_tenants(common::ObIArray& clean_tenants); - int get_server_clean_tenants(common::ObIArray& clean_tenants); - int get_extern_clean_tenants(hash::ObHashMap& clean_tenants_map); - int get_server_need_clean_info(const uint64_t tenant_id, bool& need_add); - int get_all_tenant_ids(common::ObIArray& tenant_ids); - int get_tenant_backup_task_his_info(const share::ObBackupCleanInfo& clean_info, common::ObISQLClient& trans, - common::ObIArray& tenant_infos); - int get_tenant_backup_task_info(const share::ObBackupCleanInfo& clean_info, common::ObISQLClient& trans, - common::ObIArray& tenant_infos); - int inner_get_tenant_backup_task_his_info(const share::ObBackupCleanInfo& clean_info, common::ObISQLClient& trans, - common::ObIArray& tenant_infos); - int get_tenant_backup_backupset_task_his_info(const share::ObBackupCleanInfo& clean_info, common::ObISQLClient& trans, - common::ObIArray& tenant_infos); + int get_need_clean_tenants(common::ObIArray &clean_tenants); + int get_server_clean_tenants(common::ObIArray &clean_tenants); + int get_extern_clean_tenants(hash::ObHashMap &clean_tenants_map); + int get_server_need_clean_info(const uint64_t tenant_id, bool &need_add); + int get_all_tenant_ids(common::ObIArray &tenant_ids); + int get_tenant_backup_task_his_info(const share::ObBackupCleanInfo &clean_info, common::ObISQLClient &trans, + common::ObIArray &tenant_infos); + int get_tenant_backup_task_info(const share::ObBackupCleanInfo &clean_info, common::ObISQLClient &trans, + common::ObIArray &tenant_infos); + int inner_get_tenant_backup_task_his_info(const share::ObBackupCleanInfo &clean_info, common::ObISQLClient &trans, + common::ObIArray &tenant_infos); + int get_tenant_backup_backupset_task_his_info(const share::ObBackupCleanInfo &clean_info, common::ObISQLClient &trans, + common::ObIArray &tenant_infos); int convert_backup_backupset_task_to_backup_task( - const common::ObIArray& backup_backupset_tasks, - common::ObIArray& backup_tasks); - int get_log_archive_info(const int64_t copy_id, const uint64_t tenant_id, common::ObISQLClient& trans, - common::ObIArray& log_archive_infos); - int get_log_archive_history_info(const int64_t copy_id, const uint64_t tenant_id, common::ObISQLClient& trans, - common::ObIArray& log_archive_infos); - - int get_backup_clean_tenant(const share::ObTenantBackupTaskInfo& task_info, - hash::ObHashMap& clean_tenants_map); - int get_archive_clean_tenant(const share::ObLogArchiveBackupInfo& log_archive_info, - hash::ObHashMap& clean_tenants_map); - - int get_backup_clean_elements(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant); - int do_tenant_backup_clean(const share::ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant); - int do_with_finished_tenant_clean_task(const common::ObIArray& normal_clean_tenants, - const share::ObBackupCleanInfo& sys_clean_info, const ObBackupDataCleanTenant& sys_clean_tenant, + const common::ObIArray &backup_backupset_tasks, + common::ObIArray &backup_tasks); + int get_log_archive_info(const int64_t copy_id, const uint64_t tenant_id, common::ObISQLClient &trans, + common::ObIArray &log_archive_infos); + int get_log_archive_history_info(const int64_t copy_id, const uint64_t tenant_id, common::ObISQLClient &trans, + common::ObIArray &log_archive_infos); + + int get_backup_clean_tenant(const share::ObTenantBackupTaskInfo &task_info, + hash::ObHashMap &clean_tenants_map); + int get_archive_clean_tenant(const share::ObLogArchiveBackupInfo &log_archive_info, + hash::ObHashMap &clean_tenants_map); + + int get_backup_clean_elements(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant); + int do_tenant_backup_clean(const share::ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant); + int do_with_finished_tenant_clean_task(const common::ObIArray &normal_clean_tenants, + const share::ObBackupCleanInfo &sys_clean_info, const ObBackupDataCleanTenant &sys_clean_tenant, const int32_t clean_result); - int reset_backup_clean_infos(const common::ObIArray& normal_clean_tenants, - common::ObISQLClient& sys_tenant_trans); - int insert_clean_infos_into_history(const common::ObIArray& normal_clean_tenants, - common::ObISQLClient& sys_tenant_trans); + int reset_backup_clean_infos(const common::ObIArray &normal_clean_tenants, + common::ObISQLClient &sys_tenant_trans); + int insert_clean_infos_into_history(const common::ObIArray &normal_clean_tenants, + common::ObISQLClient &sys_tenant_trans); int check_all_tenant_clean_tasks_stopped( - const common::ObIArray& normal_clean_tenants, bool& is_all_tasks_stopped); + const common::ObIArray &normal_clean_tenants, bool &is_all_tasks_stopped); int do_with_failed_tenant_clean_task( - const common::ObIArray& normal_clean_tenants, int32_t& clean_result); - int check_tenant_backup_clean_task_failed(const common::ObIArray& normal_clean_tenants, - const share::ObBackupCleanInfo& sys_clean_info, common::ObISQLClient& sys_tenant_trans, int32_t& result); + const common::ObIArray &normal_clean_tenants, int32_t &clean_result); + int check_tenant_backup_clean_task_failed(const common::ObIArray &normal_clean_tenants, + const share::ObBackupCleanInfo &sys_clean_info, common::ObISQLClient &sys_tenant_trans, int32_t &result); int update_tenant_backup_clean_task_failed( - const common::ObIArray& normal_clean_tenants, - common::ObISQLClient& sys_tenant_trans, const int32_t result); + const common::ObIArray &normal_clean_tenants, + common::ObISQLClient &sys_tenant_trans, const int32_t result); int do_normal_tenant_backup_clean( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); int mark_backup_meta_data_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); int mark_inner_table_his_data_deleted( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); - int mark_backup_task_his_data_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObISQLClient& trans); + int mark_backup_task_his_data_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObISQLClient &trans); int inner_mark_backup_task_his_data_deleted(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const share::ObBackupDest& backup_dest, common::ObISQLClient& trans); + const int64_t backup_set_id, const share::ObBackupDest &backup_dest, common::ObISQLClient &trans); int inner_mark_backup_backup_task_his_data_deleted(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const int64_t copy_id, const share::ObBackupDest& backup_dest, - common::ObISQLClient& trans); + const int64_t backup_set_id, const int64_t copy_id, const share::ObBackupDest &backup_dest, + common::ObISQLClient &trans); int inner_mark_backup_set_file_data_deleting(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient& trans); + const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient &trans); int inner_mark_backup_set_file_data_deleted(const uint64_t tenant_id, const int64_t incarnation, - const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient& trans); + const int64_t backup_set_id, const int64_t copy_id, common::ObISQLClient &trans); - int mark_log_archive_stauts_his_data_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const int64_t clog_gc_snapshot, common::ObISQLClient& trans); - int mark_log_archive_round_data_deleted(const share::ObBackupCleanInfo& clean_info, const int64_t log_archive_round, - const int64_t copy_id, const int64_t start_piece_id, const int64_t clog_gc_snapshot, common::ObISQLClient& trans); - int mark_log_archive_piece_data_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupPieceInfo& backup_piece_info, const int64_t clog_gc_snapshot, common::ObISQLClient& trans); + int mark_log_archive_stauts_his_data_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const int64_t clog_gc_snapshot, common::ObISQLClient &trans); + int mark_log_archive_round_data_deleted(const share::ObBackupCleanInfo &clean_info, const int64_t log_archive_round, + const int64_t copy_id, const int64_t start_piece_id, const int64_t clog_gc_snapshot, common::ObISQLClient &trans); + int mark_log_archive_piece_data_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupPieceInfo &backup_piece_info, const int64_t clog_gc_snapshot, common::ObISQLClient &trans); int mark_extern_backup_info_deleted( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element); // for new interface int mark_backup_set_infos_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); int mark_backup_set_info_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element); - int mark_backup_set_info_inner_table_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids); - int mark_extern_backup_set_info_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element); + int mark_backup_set_info_inner_table_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids); + int mark_extern_backup_set_info_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids); int mark_log_archive_infos_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); int mark_log_archive_info_deleting( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element); - int mark_log_archive_info_inner_table_deleting(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& backup_piece_keys, - const common::ObIArray& log_archive_rounds); - int mark_extern_log_archive_info_deleting(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_piece_keys, - const common::ObIArray& log_archive_rounds); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element); + int mark_log_archive_info_inner_table_deleting(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &backup_piece_keys, + const common::ObIArray &log_archive_rounds); + int mark_extern_log_archive_info_deleting(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_piece_keys, + const common::ObIArray &log_archive_rounds); int get_need_delete_backup_set_ids( - const ObBackupDataCleanElement& clean_element, common::ObIArray& backup_set_ids); - int get_need_delete_clog_round_and_piece(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObIArray& log_archive_rounds, - common::ObIArray& backup_piece_keys); + const ObBackupDataCleanElement &clean_element, common::ObIArray &backup_set_ids); + int get_need_delete_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys); + + int delete_backup_data(const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); + int get_sys_tenant_delete_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys); + int get_normal_tenant_delete_clog_round_and_piece(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys); + int get_sys_tenant_prepare_clog_round_and_piece( + const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, + common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys); + int get_sys_tenant_doing_clog_round_and_piece( + const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, + common::ObIArray &log_archive_rounds, + common::ObIArray &backup_piece_keys); - int delete_backup_data(const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); int delete_tenant_backup_meta_data( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); int delete_backup_extern_infos( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); - int delete_inner_table_his_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanTenant& clean_tenant, common::ObISQLClient& trans); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); + int delete_inner_table_his_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanTenant &clean_tenant, common::ObISQLClient &trans); int delete_backup_extern_info( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element); - int delete_extern_backup_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids); - int delete_extern_clog_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& log_archive_rounds); + int delete_extern_backup_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids); + int delete_extern_clog_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &log_archive_rounds); - int delete_marked_backup_task_his_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObISQLClient& trans); + int delete_marked_backup_task_his_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObISQLClient &trans); int inner_delete_marked_backup_backup_task_his_data(const uint64_t tenant_id, const int64_t job_id, - const int64_t copy_id, const int64_t backup_set_id, common::ObISQLClient& trans); - int delete_marked_log_archive_status_his_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, common::ObISQLClient& trans); + const int64_t copy_id, const int64_t backup_set_id, common::ObISQLClient &trans); + int delete_marked_log_archive_status_his_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, common::ObISQLClient &trans); // new interface int delete_extern_tmp_files( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanElement& clean_element); - int mark_extern_backup_set_file_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_set_ids); - int mark_extern_backup_piece_file_info_deleted(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanElement& clean_element, const common::ObIArray& backup_piece_keys); - - int update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo& src_clean_info, - const share::ObBackupCleanInfo& dest_clean_info); - int update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo& src_clean_info, - const share::ObBackupCleanInfo& dest_clean_info, common::ObISQLClient& trans); - int do_with_status(const share::ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant); - - int do_clean_scheduler(common::ObIArray& clean_tenants); - int do_schedule_clean_tenants(common::ObIArray& clean_tenants); - int do_check_clean_tenants_finished(const common::ObIArray& clean_tenants); - - int do_tenant_clean_scheduler(share::ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant); - int get_backup_clean_info(const uint64_t tenant_id, const bool for_update, common::ObISQLClient& sql_proxy, - share::ObBackupCleanInfo& clean_info); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanElement &clean_element); + int mark_extern_backup_set_file_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_set_ids); + int mark_extern_backup_piece_file_info_deleted(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanElement &clean_element, const common::ObIArray &backup_piece_keys); + + int update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo &src_clean_info, + const share::ObBackupCleanInfo &dest_clean_info); + int update_clean_info(const uint64_t tenant_id, const share::ObBackupCleanInfo &src_clean_info, + const share::ObBackupCleanInfo &dest_clean_info, common::ObISQLClient &trans); + int do_with_status(const share::ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant); + + int do_clean_scheduler(common::ObIArray &clean_tenants); + int do_schedule_clean_tenants(common::ObIArray &clean_tenants); + int do_check_clean_tenants_finished(const common::ObIArray &clean_tenants); + + int do_tenant_clean_scheduler(share::ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant); + int get_backup_clean_info(const uint64_t tenant_id, const bool for_update, common::ObISQLClient &sql_proxy, + share::ObBackupCleanInfo &clean_info); int get_backup_clean_info( - const uint64_t tenant_id, common::ObISQLClient& sql_proxy, share::ObBackupCleanInfo& clean_info); - int get_backup_clean_info(const uint64_t tenant_id, share::ObBackupCleanInfo& clean_info); + const uint64_t tenant_id, common::ObISQLClient &sql_proxy, share::ObBackupCleanInfo &clean_info); + int get_backup_clean_info(const uint64_t tenant_id, share::ObBackupCleanInfo &clean_info); void cleanup_prepared_infos(); - int check_need_cleanup_prepared_infos(const share::ObBackupCleanInfo& sys_backup_info, bool& need_clean); - int cleanup_tenant_prepared_infos(const uint64_t tenant_id, common::ObISQLClient& sys_tenant_trans); + int check_need_cleanup_prepared_infos(const share::ObBackupCleanInfo &sys_backup_info, bool &need_clean); + int cleanup_tenant_prepared_infos(const uint64_t tenant_id, common::ObISQLClient &sys_tenant_trans); int prepare_tenant_backup_clean(); int mark_sys_tenant_backup_meta_data_deleting(); - int schedule_tenants_backup_data_clean(const common::ObIArray& tenant_ids); + int schedule_tenants_backup_data_clean(const common::ObIArray &tenant_ids); int schedule_tenant_backup_data_clean( - const uint64_t tenant_id, const share::ObBackupCleanInfo& sys_clean_info, ObISQLClient& sys_tenant_trans); + const uint64_t tenant_id, const share::ObBackupCleanInfo &sys_clean_info, ObISQLClient &sys_tenant_trans); int insert_tenant_backup_clean_info_history( - const ObSimpleBackupDataCleanTenant& clean_tenant, common::ObISQLClient& sys_trans); - int update_clog_gc_snaphost(const int64_t cluster_clog_gc_snapshot, share::ObBackupCleanInfo& clean_info, - ObBackupDataCleanTenant& clean_tenant); - int get_clog_gc_snapshot(const ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant, - const int64_t cluster_clog_gc_snapshot, int64_t& clog_gc_snapshot); - int get_deleted_clean_tenants(common::ObIArray& deleted_tenants); + const ObSimpleBackupDataCleanTenant &clean_tenant, common::ObISQLClient &sys_trans); + int update_clog_gc_snaphost(const int64_t cluster_clog_gc_snapshot, share::ObBackupCleanInfo &clean_info, + ObBackupDataCleanTenant &clean_tenant); + int get_clog_gc_snapshot(const ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant, + const int64_t cluster_clog_gc_snapshot, int64_t &clog_gc_snapshot); + int get_deleted_clean_tenants(common::ObIArray &deleted_tenants); int get_deleted_tenant_clean_infos( - ObISQLClient& trans, common::ObIArray& deleted_tenant_clean_infos); - int schedule_deleted_clean_tenants(const common::ObIArray& deleted_clean_tenants); - int get_clean_tenants(const common::ObIArray& clean_tenants, - common::ObIArray& normal_clean_tenants, ObBackupDataCleanTenant& sys_clean_tenant); + ObISQLClient &trans, common::ObIArray &deleted_tenant_clean_infos); + int schedule_deleted_clean_tenants(const common::ObIArray &deleted_clean_tenants); + int get_clean_tenants(const common::ObIArray &clean_tenants, + common::ObIArray &normal_clean_tenants, ObBackupDataCleanTenant &sys_clean_tenant); int delete_backup_clean_info( - const uint64_t tenant_id, const share::ObBackupCleanInfo& clean_info, ObISQLClient& trans); - int set_sys_clean_info_stop(const share::ObBackupCleanInfo& backup_clean_info, ObISQLClient& trans); - int try_clean_tenant_backup_dir(const ObBackupDataCleanTenant& clean_tenant); - int clean_tenant_backup_dir(const uint64_t tenant_id, const ObBackupDataCleanElement& clean_element); - - int clean_backup_tenant_info(const ObBackupDataCleanTenant& sys_clean_tenant, - const common::ObIArray& normal_clean_tenants); - int inner_clean_backup_tenant_info(const ObBackupDataCleanElement& clean_element, - const common::ObIArray& normal_clean_tenants); - int delete_cluster_backup_meta_data(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanTenant& clean_tenant, - const common::ObIArray& normal_clean_tenants); - int touch_extern_tenant_name(const ObBackupDataCleanTenant& clean_tenant); - int touch_extern_clog_info(const ObBackupDataCleanTenant& clean_tenant); + const uint64_t tenant_id, const share::ObBackupCleanInfo &clean_info, ObISQLClient &trans); + int set_sys_clean_info_stop(const share::ObBackupCleanInfo &backup_clean_info, ObISQLClient &trans); + int try_clean_tenant_backup_dir(const ObBackupDataCleanTenant &clean_tenant); + int clean_tenant_backup_dir(const uint64_t tenant_id, const ObBackupDataCleanElement &clean_element); + + int clean_backup_tenant_info(const ObBackupDataCleanTenant &sys_clean_tenant, + const common::ObIArray &normal_clean_tenants); + int inner_clean_backup_tenant_info(const ObBackupDataCleanElement &clean_element, + const common::ObIArray &normal_clean_tenants); + int delete_cluster_backup_meta_data(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanTenant &clean_tenant, + const common::ObIArray &normal_clean_tenants); + int touch_extern_tenant_name(const ObBackupDataCleanTenant &clean_tenant); + int touch_extern_clog_info(const ObBackupDataCleanTenant &clean_tenant); void set_inner_error(const int32_t result); int add_log_archive_infos( - const common::ObIArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant); - int add_log_archive_info(const ObLogArchiveBackupInfo& log_archive_info, ObBackupDataCleanTenant& clean_tenant); - int add_delete_backup_set(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& min_include_task_info); - int add_obsolete_backup_sets(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& min_include_task_info); - int add_normal_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& min_include_task_info); - int add_sys_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& min_include_task_info); - int deal_with_obsolete_backup_set(const share::ObBackupCleanInfo& clean_info, const ObTenantBackupTaskInfo& task_info, - const common::ObArray& log_archive_infos, const int64_t cluster_max_backup_set_id, - ObBackupSetId& backup_set_id, bool& has_kept_last_succeed_data, - share::ObTenantBackupTaskInfo& clog_data_clean_point); - int deal_with_effective_backup_set(const share::ObBackupCleanInfo& clean_info, - const ObTenantBackupTaskInfo& task_info, const common::ObArray& log_archive_infos, - ObBackupSetId& backup_set_id, bool& has_kept_last_succeed_data, - share::ObTenantBackupTaskInfo& clog_data_clean_point); - int add_obsolete_backup_set_with_order(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& reverse_task_infos, - const common::ObIArray& reverse_backup_set_ids, ObBackupDataCleanTenant& clean_tenant, - share::ObTenantBackupTaskInfo& clog_data_clean_point); - - int add_delete_backup_piece(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant); - int add_delete_backup_round(const share::ObBackupCleanInfo& clean_info, - const common::ObIArray& task_infos, - const common::ObArray& log_archive_infos, ObBackupDataCleanTenant& clean_tenant); - - int update_normal_tenant_clean_result(const share::ObBackupCleanInfo& clean_info, - const ObBackupDataCleanTenant& clean_tenant, const int32_t clean_result); - int get_cluster_max_succeed_backup_set(const int64_t copy_id, int64_t& backup_set_id); - int inner_get_cluster_max_succeed_backup_set(int64_t& backup_set_id); - int inner_get_cluster_max_succeed_backup_backup_set(const int64_t copy_id, int64_t& backup_set_id); + const common::ObIArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant); + int add_log_archive_info(const ObLogArchiveBackupInfo &log_archive_info, ObBackupDataCleanTenant &clean_tenant); + int add_delete_backup_set(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &min_include_task_info); + int add_obsolete_backup_sets(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &min_include_task_info); + int add_normal_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &min_include_task_info); + int add_sys_tenant_obsolete_backup_sets(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &min_include_task_info); + int deal_with_obsolete_backup_set(const share::ObBackupCleanInfo &clean_info, const ObTenantBackupTaskInfo &task_info, + const common::ObArray &log_archive_infos, const int64_t cluster_max_backup_set_id, + ObBackupSetId &backup_set_id, bool &has_kept_last_succeed_data, + share::ObTenantBackupTaskInfo &clog_data_clean_point); + int deal_with_effective_backup_set(const share::ObBackupCleanInfo &clean_info, + const ObTenantBackupTaskInfo &task_info, const common::ObArray &log_archive_infos, + ObBackupSetId &backup_set_id, bool &has_kept_last_succeed_data, + share::ObTenantBackupTaskInfo &clog_data_clean_point); + int add_obsolete_backup_set_with_order(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &reverse_task_infos, + const common::ObIArray &reverse_backup_set_ids, ObBackupDataCleanTenant &clean_tenant, + share::ObTenantBackupTaskInfo &clog_data_clean_point); + + int add_delete_backup_piece(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant); + int add_delete_backup_round(const share::ObBackupCleanInfo &clean_info, + const common::ObIArray &task_infos, + const common::ObArray &log_archive_infos, ObBackupDataCleanTenant &clean_tenant); + + int update_normal_tenant_clean_result(const share::ObBackupCleanInfo &clean_info, + const ObBackupDataCleanTenant &clean_tenant, const int32_t clean_result); + int get_cluster_max_succeed_backup_set(const int64_t copy_id, int64_t &backup_set_id); + int inner_get_cluster_max_succeed_backup_set(int64_t &backup_set_id); + int inner_get_cluster_max_succeed_backup_backup_set(const int64_t copy_id, int64_t &backup_set_id); int get_log_archive_info(const int64_t backup_snapshot_version, - const common::ObArray& log_archive_infos, - share::ObLogArchiveBackupInfo& log_archvie_info); - int check_backupset_continue_with_clog_data(const share::ObTenantBackupTaskInfo& backup_task_info, - const common::ObArray& log_archive_infos, bool& is_continue); + const common::ObArray &log_archive_infos, + share::ObLogArchiveBackupInfo &log_archvie_info); + int check_backupset_continue_with_clog_data(const share::ObTenantBackupTaskInfo &backup_task_info, + const common::ObArray &log_archive_infos, bool &is_continue); int do_tenant_cancel_delete_backup( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); - int do_sys_tenant_cancel_delete_backup(const share::ObBackupCleanInfo& clean_info); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); + int do_sys_tenant_cancel_delete_backup(const share::ObBackupCleanInfo &clean_info); int do_normal_tenant_cancel_delete_backup( - const share::ObBackupCleanInfo& clean_info, const ObBackupDataCleanTenant& clean_tenant); - int set_tenant_clean_info_cancel(const share::ObBackupCleanInfo& clean_info); - int set_normal_tenant_cancel(const uint64_t tenant_id, common::ObISQLClient& sys_tenant_trans); - int set_deleted_tenant_cancel(const ObBackupCleanInfo& clean_info, common::ObISQLClient& sys_tenant_trans); - int get_sys_tenant_backup_dest(common::hash::ObHashSet& cluster_backup_dest_set); - int do_scheduler_normal_tenant(share::ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant, - common::ObIArray& task_infos, - common::ObIArray& log_archive_infos); - int do_scheduler_deleted_tenant(share::ObBackupCleanInfo& clean_info, ObBackupDataCleanTenant& clean_tenant, - common::ObIArray& task_infos, - common::ObIArray& log_archive_infos); - int do_inner_scheduler_delete_tenant(const ObClusterBackupDest& cluster_backup_dest, - ObBackupDataCleanTenant& clean_tenant, common::ObIArray& task_infos, - common::ObIArray& log_archive_infos); - int get_all_tenant_backup_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos); - int get_delete_backup_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos); - int get_delete_obsolete_backup_set_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos); - int get_delete_obsolete_backup_backupset_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos); - int get_delete_backup_piece_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_backup_log_infos); - - int get_tenant_backup_task_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_infos); - int get_tenant_backup_backupset_task_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_infos); - int get_tenant_backup_log_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_log_infos); - int get_tenant_backup_backuplog_infos(const share::ObBackupCleanInfo& clean_info, - const ObSimpleBackupDataCleanTenant& simple_clean_tenant, common::ObISQLClient& trans, - common::ObIArray& tenant_backup_log_infos); - int get_backup_dest_option(const ObBackupDest& backup_dest, ObBackupDestOpt& backup_dest_option); + const share::ObBackupCleanInfo &clean_info, const ObBackupDataCleanTenant &clean_tenant); + int set_tenant_clean_info_cancel(const share::ObBackupCleanInfo &clean_info); + int set_normal_tenant_cancel(const uint64_t tenant_id, common::ObISQLClient &sys_tenant_trans); + int set_deleted_tenant_cancel(const ObBackupCleanInfo &clean_info, common::ObISQLClient &sys_tenant_trans); + int get_sys_tenant_backup_dest(common::hash::ObHashSet &cluster_backup_dest_set); + int do_scheduler_normal_tenant(share::ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant, + common::ObIArray &task_infos, + common::ObIArray &log_archive_infos); + int do_scheduler_deleted_tenant(share::ObBackupCleanInfo &clean_info, ObBackupDataCleanTenant &clean_tenant, + common::ObIArray &task_infos, + common::ObIArray &log_archive_infos); + int do_inner_scheduler_delete_tenant(const ObClusterBackupDest &cluster_backup_dest, + ObBackupDataCleanTenant &clean_tenant, common::ObIArray &task_infos, + common::ObIArray &log_archive_infos); + int get_all_tenant_backup_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos); + int get_delete_backup_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos); + int get_delete_obsolete_backup_set_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos); + int get_delete_obsolete_backup_backupset_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos); + int get_delete_backup_piece_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_backup_log_infos); + + int get_tenant_backup_task_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_infos); + int get_tenant_backup_backupset_task_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_infos); + int get_tenant_backup_log_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_log_infos); + int get_tenant_backup_backuplog_infos(const share::ObBackupCleanInfo &clean_info, + const ObSimpleBackupDataCleanTenant &simple_clean_tenant, common::ObISQLClient &trans, + common::ObIArray &tenant_backup_log_infos); + int get_backup_dest_option(const ObBackupDest &backup_dest, ObBackupDestOpt &backup_dest_option); int get_clean_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map); + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map); int get_delete_backup_set_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map); + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map); int get_delete_backup_piece_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map); + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map); int get_delete_backup_round_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map); + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map); int get_delete_obsolete_backup_tenants_from_history_table( - const ObBackupCleanInfo& clean_info, hash::ObHashMap& clean_tenants_map); - int set_history_tenant_info_into_map(const common::ObIArray& tenant_ids, - hash::ObHashMap& clean_tenants_map); + const ObBackupCleanInfo &clean_info, hash::ObHashMap &clean_tenants_map); + int set_history_tenant_info_into_map(const common::ObIArray &tenant_ids, + hash::ObHashMap &clean_tenants_map); int set_current_backup_dest(); - int check_backup_dest_lifecycle(const ObBackupDataCleanTenant& clean_tenant); + int check_backup_dest_lifecycle(const ObBackupDataCleanTenant &clean_tenant); bool is_result_need_retry(const int32_t result); int check_inner_table_version_(); - int commit_trans(ObMySQLTransaction& trans); - int start_trans(ObTimeoutCtx& timeout_ctx, ObMySQLTransaction& trans); - int check_can_delete_extern_info_file(const uint64_t tenant_id, const ObClusterBackupDest& current_backup_dest, - const bool is_backup_backup, const ObBackupPath& path, bool& can_delete_file); - int get_backup_set_file_copies_num(const ObTenantBackupTaskInfo& task_info, int64_t& copies_num); - int get_backup_piece_file_copies_num(const ObBackupPieceInfo& backup_piece_info, int64_t& copies_num); - int get_backup_round_copies_num(const ObLogArchiveBackupInfo& archive_backup_info, int64_t& copies_num); + int commit_trans(ObMySQLTransaction &trans); + int start_trans(ObTimeoutCtx &timeout_ctx, ObMySQLTransaction &trans); + int check_can_delete_extern_info_file(const uint64_t tenant_id, const ObClusterBackupDest ¤t_backup_dest, + const bool is_backup_backup, const ObBackupPath &path, bool &can_delete_file); + int get_backup_set_file_copies_num(const ObTenantBackupTaskInfo &task_info, int64_t &copies_num); + int get_backup_piece_file_copies_num(const ObBackupPieceInfo &backup_piece_info, int64_t &copies_num); + int get_backup_round_copies_num(const ObLogArchiveBackupInfo &archive_backup_info, int64_t &copies_num); int prepare_deleted_tenant_backup_infos(); - int add_backup_infos_for_compatible(const ObClusterBackupDest& cluster_backup_dest, - const common::ObIArray& simple_tenants); - int add_backup_infos_for_compatible_(const ObClusterBackupDest& cluster_backup_dest, - const ObSimpleBackupDataCleanTenant& simple_tenant, hash::ObHashMap& min_backup_set_log_ts); + int add_backup_infos_for_compatible(const ObClusterBackupDest &cluster_backup_dest, + const common::ObIArray &simple_tenants); + int add_backup_infos_for_compatible_(const ObClusterBackupDest &cluster_backup_dest, + const ObSimpleBackupDataCleanTenant &simple_tenant, hash::ObHashMap &min_backup_set_log_ts); - int add_log_archive_infos_for_compatible(const ObClusterBackupDest& cluster_backup_dest, - const common::ObIArray& simple_tenants); + int add_log_archive_infos_for_compatible(const ObClusterBackupDest &cluster_backup_dest, + const common::ObIArray &simple_tenants); int add_log_archive_infos_for_compatible_( - const ObClusterBackupDest& cluster_backup_dest, const ObSimpleBackupDataCleanTenant& simple_tenant); - int get_backup_task_info_from_extern_info(const uint64_t tenant_id, const ObClusterBackupDest& cluster_backup_dest, - const ObExternBackupInfo& extern_backup_info, ObTenantBackupTaskInfo& backup_task_info); + const ObClusterBackupDest &cluster_backup_dest, const ObSimpleBackupDataCleanTenant &simple_tenant); + int get_backup_task_info_from_extern_info(const uint64_t tenant_id, const ObClusterBackupDest &cluster_backup_dest, + const ObExternBackupInfo &extern_backup_info, ObTenantBackupTaskInfo &backup_task_info); int upgrade_backup_info(); - int add_deleting_backup_set_id_into_set(const uint64_t tenant_id, const ObBackupSetId& backup_set_id); + int add_deleting_backup_set_id_into_set(const uint64_t tenant_id, const ObBackupSetId &backup_set_id); int check_backup_set_id_can_be_deleted( - const uint64_t tenant_id, const ObBackupSetId& backup_set_id, bool& can_deleted); - int remove_delete_expired_data_snapshot_(const ObSimpleBackupDataCleanTenant& simple_tenant); - int set_comment(ObBackupCleanInfo::Comment& comment); - int set_error_msg(const int32_t result, ObBackupCleanInfo::ErrorMsg& error_msg); - int prepare_delete_backup_set(const ObBackupCleanInfo& sys_clean_info); + const uint64_t tenant_id, const ObBackupSetId &backup_set_id, bool &can_deleted); + int remove_delete_expired_data_snapshot_(const ObSimpleBackupDataCleanTenant &simple_tenant); + int set_comment(ObBackupCleanInfo::Comment &comment); + int set_error_msg(const int32_t result, ObBackupCleanInfo::ErrorMsg &error_msg); + int prepare_delete_backup_set(const ObBackupCleanInfo &sys_clean_info); + int prepare_delete_backup_piece_and_round(const ObBackupCleanInfo &sys_clean_info); + int duplicate_task_info(common::ObIArray &task_infos); private: struct CompareLogArchiveBackupInfo { - bool operator()(const share::ObLogArchiveBackupInfo& lhs, const share::ObLogArchiveBackupInfo& rhs) const + bool operator()(const share::ObLogArchiveBackupInfo &lhs, const share::ObLogArchiveBackupInfo &rhs) const { return lhs.status_.start_ts_ < rhs.status_.start_ts_; } }; struct CompareLogArchiveSnapshotVersion { - bool operator()(const share::ObLogArchiveBackupInfo& log_info, const int64_t snapshot_version) const + bool operator()(const share::ObLogArchiveBackupInfo &log_info, const int64_t snapshot_version) const { return log_info.status_.start_ts_ < snapshot_version; } }; struct CompareBackupTaskInfo { - bool operator()(const share::ObTenantBackupTaskInfo& lhs, const share::ObTenantBackupTaskInfo& rhs) const + bool operator()(const share::ObTenantBackupTaskInfo &lhs, const share::ObTenantBackupTaskInfo &rhs) const { return lhs.backup_set_id_ < rhs.backup_set_id_; } @@ -447,13 +466,13 @@ private: private: static const int64_t MAX_BUCKET_NUM = 1024; bool is_inited_; - share::schema::ObMultiVersionSchemaService* schema_service_; - common::ObMySQLProxy* sql_proxy_; + share::schema::ObMultiVersionSchemaService *schema_service_; + common::ObMySQLProxy *sql_proxy_; mutable ObBackupDataCleanIdling idling_; bool is_prepare_flag_; int32_t inner_error_; bool is_working_; - share::ObIBackupLeaseService* backup_lease_service_; + share::ObIBackupLeaseService *backup_lease_service_; ObBackupDest backup_dest_; ObBackupDestOpt backup_dest_option_; ObBackupDest backup_backup_dest_; @@ -463,6 +482,8 @@ private: share::ObBackupInnerTableVersion inner_table_version_; hash::ObHashSet sys_tenant_deleted_backup_set_; int64_t retry_count_; + hash::ObHashSet sys_tenant_deleted_backup_round_; + hash::ObHashSet sys_tenant_deleted_backup_piece_; private: DISALLOW_COPY_AND_ASSIGN(ObBackupDataClean); diff --git a/src/rootserver/ob_root_backup.cpp b/src/rootserver/ob_root_backup.cpp index 52ae050775de32dec4674ca3b0360c4b1ac22f11..2e406994816872d1d61d35623a75803fefa67181 100644 --- a/src/rootserver/ob_root_backup.cpp +++ b/src/rootserver/ob_root_backup.cpp @@ -61,11 +61,11 @@ ObRootBackup::ObRootBackup() ObRootBackup::~ObRootBackup() {} -int ObRootBackup::init(common::ObServerConfig& cfg, share::schema::ObMultiVersionSchemaService& schema_service, - ObMySQLProxy& sql_proxy, ObRootBalancer& root_balancer, ObFreezeInfoManager& freeze_info_mgr, - ObServerManager& server_mgr, ObRebalanceTaskMgr& rebalancer_mgr, ObZoneManager& zone_mgr, - obrpc::ObSrvRpcProxy& rpc_proxy, share::ObIBackupLeaseService& backup_lease_service, - ObRestorePointService& restore_point_service) +int ObRootBackup::init(common::ObServerConfig &cfg, share::schema::ObMultiVersionSchemaService &schema_service, + ObMySQLProxy &sql_proxy, ObRootBalancer &root_balancer, ObFreezeInfoManager &freeze_info_mgr, + ObServerManager &server_mgr, ObRebalanceTaskMgr &rebalancer_mgr, ObZoneManager &zone_mgr, + obrpc::ObSrvRpcProxy &rpc_proxy, share::ObIBackupLeaseService &backup_lease_service, + ObRestorePointService &restore_point_service) { int ret = OB_SUCCESS; const int root_backup_thread_cnt = 1; @@ -215,7 +215,7 @@ int ObRootBackup::check_inner_table_version_() return ret; } -int ObRootBackup::get_need_backup_tenant_ids(ObIArray& tenant_ids) +int ObRootBackup::get_need_backup_tenant_ids(ObIArray &tenant_ids) { int ret = OB_SUCCESS; tenant_ids.reset(); @@ -283,7 +283,7 @@ int ObRootBackup::get_need_backup_tenant_ids(ObIArray& tenant_ids) return ret; } -int ObRootBackup::get_all_tenant_ids(ObIArray& tenant_ids) +int ObRootBackup::get_all_tenant_ids(ObIArray &tenant_ids) { int ret = OB_SUCCESS; ObSchemaGetterGuard guard; @@ -345,7 +345,7 @@ int ObRootBackup::get_all_tenant_ids(ObIArray& tenant_ids) return ret; } -int ObRootBackup::get_need_backup_info(const uint64_t tenant_id, ObBackupInfoManager& info_manager, bool& need_add) +int ObRootBackup::get_need_backup_info(const uint64_t tenant_id, ObBackupInfoManager &info_manager, bool &need_add) { int ret = OB_SUCCESS; need_add = false; @@ -379,7 +379,7 @@ int ObRootBackup::get_need_backup_info(const uint64_t tenant_id, ObBackupInfoMan return ret; } -int ObRootBackup::do_root_scheduler(const ObIArray& tenant_ids) +int ObRootBackup::do_root_scheduler(const ObIArray &tenant_ids) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -425,7 +425,7 @@ int ObRootBackup::do_root_scheduler(const ObIArray& tenant_ids) return ret; } -int ObRootBackup::do_tenant_scheduler(const uint64_t tenant_id, ObBackupInfoManager& info_manager) +int ObRootBackup::do_tenant_scheduler(const uint64_t tenant_id, ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; ObTimeoutCtx timeout_ctx; @@ -468,7 +468,7 @@ int ObRootBackup::do_tenant_scheduler(const uint64_t tenant_id, ObBackupInfoMana return ret; } -int ObRootBackup::do_with_status(share::ObBackupInfoManager& info_manager, const ObBaseBackupInfoStruct& info) +int ObRootBackup::do_with_status(share::ObBackupInfoManager &info_manager, const ObBaseBackupInfoStruct &info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -483,7 +483,7 @@ int ObRootBackup::do_with_status(share::ObBackupInfoManager& info_manager, const } else if (OB_FAIL(check_can_backup())) { LOG_WARN("failed to check can backup", K(ret), K(info)); } else { - const ObBackupInfoStatus& status = info.backup_status_; + const ObBackupInfoStatus &status = info.backup_status_; switch (status.status_) { case ObBackupInfoStatus::STOP: break; @@ -519,7 +519,7 @@ int ObRootBackup::do_with_status(share::ObBackupInfoManager& info_manager, const return ret; } -int ObRootBackup::do_scheduler(const ObBaseBackupInfoStruct& info, ObBackupInfoManager& info_manager) +int ObRootBackup::do_scheduler(const ObBaseBackupInfoStruct &info, ObBackupInfoManager &info_manager) { // TODO() sys tenant and normal tenant LOG_INFO("start do backup scheduler", K(info)); @@ -604,6 +604,7 @@ int ObRootBackup::do_scheduler(const ObBaseBackupInfoStruct& info, ObBackupInfoM } // Forbidden check backup dest lifecycle, because oss has bug which make observer core /* + if (OB_SUCC(ret)) { if (OB_SYS_TENANT_ID == info.tenant_id_) { int tmp_ret = OB_SUCCESS; @@ -623,7 +624,7 @@ int ObRootBackup::do_scheduler(const ObBaseBackupInfoStruct& info, ObBackupInfoM return ret; } -int ObRootBackup::do_backup(const ObBaseBackupInfoStruct& info, ObBackupInfoManager& info_manager) +int ObRootBackup::do_backup(const ObBaseBackupInfoStruct &info, ObBackupInfoManager &info_manager) { LOG_INFO("start do backup", K(info)); int ret = OB_SUCCESS; @@ -653,7 +654,7 @@ int ObRootBackup::do_backup(const ObBaseBackupInfoStruct& info, ObBackupInfoMana } int ObRootBackup::do_sys_tenant_backup( - const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) + const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { // TODO() fix it later, use tenant backup task check result int ret = OB_SUCCESS; @@ -691,7 +692,7 @@ int ObRootBackup::do_sys_tenant_backup( return ret; } -int ObRootBackup::do_tenant_backup(const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) +int ObRootBackup::do_tenant_backup(const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { LOG_INFO("start do backup", K(info)); int ret = OB_SUCCESS; @@ -745,6 +746,7 @@ int ObRootBackup::do_tenant_backup(const share::ObBaseBackupInfoStruct& info, sh } else { int64_t start_replay_log_ts = 0; ObTenantBackupTaskInfo dest_task_info; + if (OB_FAIL(calculate_tenant_start_replay_log_ts(task_info, *backup_lease_service_, start_replay_log_ts))) { LOG_WARN("failed to do get tenant start relay log ts", K(ret), K(task_info)); } else { @@ -752,6 +754,21 @@ int ObRootBackup::do_tenant_backup(const share::ObBaseBackupInfoStruct& info, sh dest_task_info.start_replay_log_ts_ = start_replay_log_ts; } +#ifdef ERRSIM + ret = E(EventTable::EN_BACKUP_UPDATE_START_REPLAY_LOG_TS) OB_SUCCESS; +#endif + + if (OB_FAIL(ret)) { + if (ObBackupUtils::is_need_retry_error(ret)) { + //do nothing + } else { + dest_task_info = task_info; + dest_task_info.result_ = ret; + inner_error_ = ret; + ret = OB_SUCCESS; + } + } + if (OB_FAIL(ret)) { } else if (OB_FAIL(start_trans(timeout_ctx, updater))) { LOG_WARN("failed to start trans", K(ret), K(info)); @@ -788,7 +805,7 @@ int ObRootBackup::do_tenant_backup(const share::ObBaseBackupInfoStruct& info, sh return ret; } -int ObRootBackup::do_cleanup(const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) +int ObRootBackup::do_cleanup(const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { LOG_INFO("start do cleanup", K(info)); int ret = OB_SUCCESS; @@ -898,7 +915,7 @@ int ObRootBackup::do_cleanup(const share::ObBaseBackupInfoStruct& info, share::O } int ObRootBackup::do_cleanup_pg_backup_tasks( - const ObTenantBackupTaskInfo& tenant_task_info, bool& all_task_deleted, common::ObISQLClient& trans) + const ObTenantBackupTaskInfo &tenant_task_info, bool &all_task_deleted, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObPGBackupTaskUpdater pg_task_updater; @@ -930,7 +947,7 @@ int ObRootBackup::do_cleanup_pg_backup_tasks( return ret; } -int ObRootBackup::do_cleanup_tenant_backup_task(const ObBaseBackupInfoStruct& info, common::ObISQLClient& trans) +int ObRootBackup::do_cleanup_tenant_backup_task(const ObBaseBackupInfoStruct &info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater tenant_task_updater; @@ -950,7 +967,7 @@ int ObRootBackup::do_cleanup_tenant_backup_task(const ObBaseBackupInfoStruct& in } int ObRootBackup::do_insert_tenant_backup_task_his( - const ObTenantBackupTaskInfo& tenant_task_info, common::ObISQLClient& trans) + const ObTenantBackupTaskInfo &tenant_task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObBackupTaskHistoryUpdater backup_task_history_updater; @@ -969,7 +986,7 @@ int ObRootBackup::do_insert_tenant_backup_task_his( return ret; } -int ObRootBackup::do_cancel(const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) +int ObRootBackup::do_cancel(const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -995,7 +1012,7 @@ int ObRootBackup::do_cancel(const share::ObBaseBackupInfoStruct& info, share::Ob } int ObRootBackup::get_tenant_backup_task( - common::ObISQLClient& trans, const share::ObBaseBackupInfoStruct& info, share::ObTenantBackupTaskInfo& task_info) + common::ObISQLClient &trans, const share::ObBaseBackupInfoStruct &info, share::ObTenantBackupTaskInfo &task_info) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater tenant_task_updater; @@ -1014,7 +1031,7 @@ int ObRootBackup::get_tenant_backup_task( } int ObRootBackup::get_tenant_backup_task(const uint64_t tenant_id, const int64_t backup_set_id, - const int64_t incarnation, common::ObISQLClient& trans, share::ObTenantBackupTaskInfo& task_info) + const int64_t incarnation, common::ObISQLClient &trans, share::ObTenantBackupTaskInfo &task_info) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater tenant_task_updater; @@ -1034,7 +1051,7 @@ int ObRootBackup::get_tenant_backup_task(const uint64_t tenant_id, const int64_t } int ObRootBackup::insert_tenant_backup_task( - ObMySQLTransaction& trans, const ObBaseBackupInfoStruct& info, const ObExternBackupInfo& extern_backup_info) + ObMySQLTransaction &trans, const ObBaseBackupInfoStruct &info, const ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater tenant_task_updater; @@ -1053,9 +1070,9 @@ int ObRootBackup::insert_tenant_backup_task( return ret; } -int ObRootBackup::update_tenant_backup_info(const share::ObBaseBackupInfoStruct& src_info, - const share::ObBaseBackupInfoStruct& dest_info, ObBackupInfoManager& info_manager, - share::ObBackupItemTransUpdater& updater) +int ObRootBackup::update_tenant_backup_info(const share::ObBaseBackupInfoStruct &src_info, + const share::ObBaseBackupInfoStruct &dest_info, ObBackupInfoManager &info_manager, + share::ObBackupItemTransUpdater &updater) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1072,14 +1089,14 @@ int ObRootBackup::update_tenant_backup_info(const share::ObBaseBackupInfoStruct& return ret; } -int ObRootBackup::get_tenant_total_partition_cnt(const uint64_t tenant_id, int64_t& total_partition_cnt) +int ObRootBackup::get_tenant_total_partition_cnt(const uint64_t tenant_id, int64_t &total_partition_cnt) { // total_partition_cnt contains both normal pg and mark dropped pg // here interface just use to get partition count to calc query_time and trx_time int ret = OB_SUCCESS; total_partition_cnt = 0; ObSchemaGetterGuard schema_guard; - ObArray schemas; + ObArray schemas; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1090,7 +1107,7 @@ int ObRootBackup::get_tenant_total_partition_cnt(const uint64_t tenant_id, int64 LOG_WARN("failed to get table schema in tenant", K(ret), K(tenant_id)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < schemas.count(); ++i) { - const ObSimpleTableSchemaV2* schema = schemas.at(i); + const ObSimpleTableSchemaV2 *schema = schemas.at(i); // FIXME: doesn't involve the delay delete objects total_partition_cnt += schema->get_all_part_num(); } @@ -1098,9 +1115,9 @@ int ObRootBackup::get_tenant_total_partition_cnt(const uint64_t tenant_id, int64 return ret; } -int ObRootBackup::update_extern_backup_infos(const share::ObBaseBackupInfoStruct& info, - const ObExternBackupInfo::ExternBackupInfoStatus& status, const bool is_force_stop, - ObExternBackupInfo& extern_backup_info) +int ObRootBackup::update_extern_backup_infos(const share::ObBaseBackupInfoStruct &info, + const ObExternBackupInfo::ExternBackupInfoStatus &status, const bool is_force_stop, + ObExternBackupInfo &extern_backup_info) { int ret = OB_SUCCESS; ObExternBackupInfoMgr extern_backup_info_mgr; @@ -1129,9 +1146,9 @@ int ObRootBackup::update_extern_backup_infos(const share::ObBaseBackupInfoStruct return ret; } -int ObRootBackup::do_extern_backup_set_infos(const ObBaseBackupInfoStruct& info, - const ObTenantBackupTaskInfo& tenant_task_info, const ObExternBackupInfo& extern_backup_info, - const bool is_force_stop, ObExternBackupSetInfo& extern_backup_set_info) +int ObRootBackup::do_extern_backup_set_infos(const ObBaseBackupInfoStruct &info, + const ObTenantBackupTaskInfo &tenant_task_info, const ObExternBackupInfo &extern_backup_info, + const bool is_force_stop, ObExternBackupSetInfo &extern_backup_set_info) { int ret = OB_SUCCESS; ObExternBackupSetInfoMgr extern_backup_set_info_mgr; @@ -1179,13 +1196,13 @@ int ObRootBackup::do_extern_backup_set_infos(const ObBaseBackupInfoStruct& info, return ret; } -int ObRootBackup::do_extern_backup_tenant_locality_infos(const ObBaseBackupInfoStruct& info, - const ObExternBackupInfo& extern_backup_info, const bool is_force_stop, - ObExternTenantLocalityInfo& extern_tenant_locality_info) +int ObRootBackup::do_extern_backup_tenant_locality_infos(const ObBaseBackupInfoStruct &info, + const ObExternBackupInfo &extern_backup_info, const bool is_force_stop, + ObExternTenantLocalityInfo &extern_tenant_locality_info) { int ret = OB_SUCCESS; ObSchemaGetterGuard guard; - const ObTenantSchema* tenant_info = NULL; + const ObTenantSchema *tenant_info = NULL; ObExternTenantLocalityInfoMgr extern_tenant_locality_info_mgr; ObClusterBackupDest backup_dest; const uint64_t tenant_id = info.tenant_id_; @@ -1240,7 +1257,7 @@ int ObRootBackup::do_extern_backup_tenant_locality_infos(const ObBaseBackupInfoS } int ObRootBackup::do_extern_tenant_infos( - const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) + const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; ObArray tenant_ids; @@ -1263,7 +1280,7 @@ int ObRootBackup::do_extern_tenant_infos( const uint64_t tenant_id = tenant_ids.at(i); ObBaseBackupInfoStruct info; ObSchemaGetterGuard guard; - const ObTenantSchema* tenant_schema = NULL; + const ObTenantSchema *tenant_schema = NULL; ObExternTenantInfo tenant_info; if (OB_SYS_TENANT_ID == tenant_id) { // do nothing @@ -1303,8 +1320,8 @@ int ObRootBackup::do_extern_tenant_infos( } int ObRootBackup::get_stopped_backup_tenant_task_infos( - const common::ObIArray& tenant_backup_infos, - common::ObIArray& tenant_task_infos) + const common::ObIArray &tenant_backup_infos, + common::ObIArray &tenant_task_infos) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1312,7 +1329,7 @@ int ObRootBackup::get_stopped_backup_tenant_task_infos( LOG_WARN("root backup do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tenant_backup_infos.count(); ++i) { - const ObBaseBackupInfoStruct& info = tenant_backup_infos.at(i); + const ObBaseBackupInfoStruct &info = tenant_backup_infos.at(i); ObTenantBackupTaskUpdater updater; ObTenantBackupTaskInfo tenant_task_info; if (!info.backup_status_.is_stop_status()) { @@ -1336,9 +1353,9 @@ int ObRootBackup::get_stopped_backup_tenant_task_infos( return ret; } -int ObRootBackup::get_stopped_backup_tenant_infos(const share::ObBaseBackupInfoStruct& sys_backup_info, - const common::ObIArray& tenant_backup_infos, int32_t& result, - int64_t& min_start_replay_log_ts, ObBackupStatistics& backup_statistics) +int ObRootBackup::get_stopped_backup_tenant_infos(const share::ObBaseBackupInfoStruct &sys_backup_info, + const common::ObIArray &tenant_backup_infos, int32_t &result, + int64_t &min_start_replay_log_ts, ObBackupStatistics &backup_statistics) { int ret = OB_SUCCESS; result = OB_SUCCESS; @@ -1367,7 +1384,7 @@ int ObRootBackup::get_stopped_backup_tenant_infos(const share::ObBaseBackupInfoS } } else { for (int64_t i = 0; OB_SUCCESS == result && i < tenant_task_infos.count(); ++i) { - const ObTenantBackupTaskInfo& tenant_task_info = tenant_task_infos.at(i); + const ObTenantBackupTaskInfo &tenant_task_info = tenant_task_infos.at(i); result = tenant_task_info.result_; min_start_replay_log_ts = std::min(tenant_task_info.start_replay_log_ts_, min_start_replay_log_ts); if (OB_SUCCESS == result) { @@ -1430,7 +1447,7 @@ int ObRootBackup::cleanup_stopped_backup_task_infos() return ret; } -int ObRootBackup::cleanup_stopped_tenant_infos(const uint64_t tenant_id, ObBackupInfoManager& info_manager) +int ObRootBackup::cleanup_stopped_tenant_infos(const uint64_t tenant_id, ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; ObTenantBackupTaskInfo sys_tenant_backup_task; @@ -1555,7 +1572,7 @@ int ObRootBackup::cleanup_stopped_tenant_infos(const uint64_t tenant_id, ObBacku return ret; } -int ObRootBackup::get_lease_time(const uint64_t tenant_id, int64_t& lease_time) +int ObRootBackup::get_lease_time(const uint64_t tenant_id, int64_t &lease_time) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1700,7 +1717,7 @@ void ObRootBackup::cleanup_prepared_infos() } int ObRootBackup::check_need_cleanup_prepared_infos( - const share::ObBaseBackupInfoStruct& sys_backup_info, bool& need_clean) + const share::ObBaseBackupInfoStruct &sys_backup_info, bool &need_clean) { int ret = OB_SUCCESS; need_clean = false; @@ -1720,7 +1737,7 @@ int ObRootBackup::check_need_cleanup_prepared_infos( } int ObRootBackup::cleanup_tenant_prepared_infos( - const uint64_t tenant_id, ObISQLClient& sys_tenant_trans, ObBackupInfoManager& info_manager) + const uint64_t tenant_id, ObISQLClient &sys_tenant_trans, ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; ObTenantBackupTaskInfo task_info; @@ -1775,7 +1792,7 @@ int ObRootBackup::cleanup_tenant_prepared_infos( } int ObRootBackup::check_tenants_backup_task_failed( - const ObBaseBackupInfoStruct& info, ObBackupInfoManager& info_manager, common::ObISQLClient& sys_tenant_trans) + const ObBaseBackupInfoStruct &info, ObBackupInfoManager &info_manager, common::ObISQLClient &sys_tenant_trans) { int ret = OB_SUCCESS; ObArray tenant_ids; @@ -1893,8 +1910,8 @@ int ObRootBackup::check_tenants_backup_task_failed( return ret; } -int ObRootBackup::update_tenant_backup_task(common::ObISQLClient& trans, const share::ObTenantBackupTaskInfo& src_info, - const share::ObTenantBackupTaskInfo& dest_info) +int ObRootBackup::update_tenant_backup_task(common::ObISQLClient &trans, const share::ObTenantBackupTaskInfo &src_info, + const share::ObTenantBackupTaskInfo &dest_info) { int ret = OB_SUCCESS; ObTenantBackupTaskUpdater updater; @@ -1914,7 +1931,7 @@ int ObRootBackup::update_tenant_backup_task(common::ObISQLClient& trans, const s } int ObRootBackup::do_normal_tenant_cancel( - const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) + const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { LOG_INFO("start do normal tenant cancel", K(info)); int ret = OB_SUCCESS; @@ -2013,7 +2030,7 @@ int ObRootBackup::do_normal_tenant_cancel( } int ObRootBackup::do_sys_tenant_cancel( - const share::ObBaseBackupInfoStruct& info, share::ObBackupInfoManager& info_manager) + const share::ObBaseBackupInfoStruct &info, share::ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; ObArray tenant_ids; @@ -2081,7 +2098,7 @@ int ObRootBackup::do_sys_tenant_cancel( } int ObRootBackup::set_normal_tenant_cancel( - const uint64_t tenant_id, share::ObBackupInfoManager& sys_info_manager, common::ObISQLClient& sys_tenant_tran) + const uint64_t tenant_id, share::ObBackupInfoManager &sys_info_manager, common::ObISQLClient &sys_tenant_tran) { int ret = OB_SUCCESS; ObArray tenant_ids; @@ -2137,9 +2154,9 @@ int ObRootBackup::set_normal_tenant_cancel( return ret; } -int ObRootBackup::update_sys_tenant_backup_task(ObMySQLTransaction& trans, const share::ObBaseBackupInfoStruct& info, - const int32_t result, const int64_t min_start_relay_log_ts, const ObBackupStatistics& backup_statistics, - share::ObTenantBackupTaskInfo& tenant_task_info) +int ObRootBackup::update_sys_tenant_backup_task(ObMySQLTransaction &trans, const share::ObBaseBackupInfoStruct &info, + const int32_t result, const int64_t min_start_relay_log_ts, const ObBackupStatistics &backup_statistics, + share::ObTenantBackupTaskInfo &tenant_task_info) { int ret = OB_SUCCESS; ObTenantBackupTaskInfo src_backup_task; @@ -2192,9 +2209,9 @@ int ObRootBackup::check_can_backup() return ret; } -int ObRootBackup::do_extern_diagnose_info(const ObBaseBackupInfoStruct& info, - const ObExternBackupInfo& extern_backup_info, const ObExternBackupSetInfo& extern_backup_set_info, - const ObExternTenantLocalityInfo& tenant_locality_info, const bool is_force_stop) +int ObRootBackup::do_extern_diagnose_info(const ObBaseBackupInfoStruct &info, + const ObExternBackupInfo &extern_backup_info, const ObExternBackupSetInfo &extern_backup_set_info, + const ObExternTenantLocalityInfo &tenant_locality_info, const bool is_force_stop) { int ret = OB_SUCCESS; ObExternTenantBackupDiagnoseMgr extern_backup_diagnose_mgr; @@ -2239,7 +2256,7 @@ int ObRootBackup::do_extern_diagnose_info(const ObBaseBackupInfoStruct& info, return ret; } -int ObRootBackup::check_tenant_is_dropped(const uint64_t tenant_id, bool& is_dropped) +int ObRootBackup::check_tenant_is_dropped(const uint64_t tenant_id, bool &is_dropped) { int ret = OB_SUCCESS; is_dropped = false; @@ -2256,8 +2273,8 @@ int ObRootBackup::check_tenant_is_dropped(const uint64_t tenant_id, bool& is_dro return ret; } -int ObRootBackup::do_with_all_finished_info(const share::ObBaseBackupInfoStruct& info, - share::ObBackupItemTransUpdater& sys_updater, share::ObBackupInfoManager& info_manager) +int ObRootBackup::do_with_all_finished_info(const share::ObBaseBackupInfoStruct &info, + share::ObBackupItemTransUpdater &sys_updater, share::ObBackupInfoManager &info_manager) { // TODO() fix it later, use tenant backup task check result int ret = OB_SUCCESS; @@ -2345,7 +2362,7 @@ int ObRootBackup::do_with_all_finished_info(const share::ObBaseBackupInfoStruct& } int ObRootBackup::update_tenant_backup_meta_info( - const ObPartitionKey& pkey, const int64_t pg_count, const int64_t partition_count) + const ObPartitionKey &pkey, const int64_t pg_count, const int64_t partition_count) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2368,7 +2385,7 @@ void ObRootBackup::reset_tenant_backup_meta_info() backup_meta_info_.reset(); } -int ObRootBackup::get_tenant_backup_meta_info(ObTenantBackupMetaInfo& meta_info) +int ObRootBackup::get_tenant_backup_meta_info(ObTenantBackupMetaInfo &meta_info) { int ret = OB_SUCCESS; meta_info.reset(); @@ -2381,7 +2398,7 @@ int ObRootBackup::get_tenant_backup_meta_info(ObTenantBackupMetaInfo& meta_info) return ret; } -int ObRootBackup::check_tenant_backup_inner_error(const share::ObBaseBackupInfoStruct& info) +int ObRootBackup::check_tenant_backup_inner_error(const share::ObBaseBackupInfoStruct &info) { int ret = OB_SUCCESS; int64_t global_broadcase_version = 0; @@ -2415,8 +2432,8 @@ int ObRootBackup::check_tenant_backup_inner_error(const share::ObBaseBackupInfoS return ret; } -int ObRootBackup::insert_tenant_backup_task_failed(ObMySQLTransaction& trans, const share::ObBaseBackupInfoStruct& info, - share::ObTenantBackupTaskInfo& tenant_backup_task) +int ObRootBackup::insert_tenant_backup_task_failed(ObMySQLTransaction &trans, const share::ObBaseBackupInfoStruct &info, + share::ObTenantBackupTaskInfo &tenant_backup_task) { int ret = OB_SUCCESS; ObBackupDest backup_dest; @@ -2482,7 +2499,7 @@ int ObRootBackup::drop_backup_point(const uint64_t tenant_id, const int64_t back return ret; } -int ObRootBackup::commit_trans(share::ObBackupItemTransUpdater& updater) +int ObRootBackup::commit_trans(share::ObBackupItemTransUpdater &updater) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -2499,8 +2516,8 @@ int ObRootBackup::commit_trans(share::ObBackupItemTransUpdater& updater) return ret; } -int ObRootBackup::add_backup_info_lock(const share::ObBaseBackupInfoStruct& info, - share::ObBackupItemTransUpdater& updater, share::ObBackupInfoManager& info_manager) +int ObRootBackup::add_backup_info_lock(const share::ObBaseBackupInfoStruct &info, + share::ObBackupItemTransUpdater &updater, share::ObBackupInfoManager &info_manager) { int ret = OB_SUCCESS; ObBaseBackupInfoStruct src_info; @@ -2518,7 +2535,7 @@ int ObRootBackup::add_backup_info_lock(const share::ObBaseBackupInfoStruct& info return ret; } -int ObRootBackup::start_trans(ObTimeoutCtx& timeout_ctx, share::ObBackupItemTransUpdater& updater) +int ObRootBackup::start_trans(ObTimeoutCtx &timeout_ctx, share::ObBackupItemTransUpdater &updater) { int ret = OB_SUCCESS; const int64_t MAX_EXECUTE_TIMEOUT_US = 600L * 1000 * 1000; // 600s @@ -2533,10 +2550,10 @@ int ObRootBackup::start_trans(ObTimeoutCtx& timeout_ctx, share::ObBackupItemTran return ret; } -int ObRootBackup::check_tenant_can_backup(const uint64_t tenant_id, ObSchemaGetterGuard& guard, bool& can_backup) +int ObRootBackup::check_tenant_can_backup(const uint64_t tenant_id, ObSchemaGetterGuard &guard, bool &can_backup) { int ret = OB_SUCCESS; - const ObSimpleTenantSchema* tenant_schema = NULL; + const ObSimpleTenantSchema *tenant_schema = NULL; can_backup = true; if (!is_inited_) { ret = OB_NOT_INIT; @@ -2557,8 +2574,8 @@ int ObRootBackup::check_tenant_can_backup(const uint64_t tenant_id, ObSchemaGett } // TODO() use inner table replace it -int ObRootBackup::get_tenant_backup_set_file_info(const share::ObBaseBackupInfoStruct& info, - const share::ObExternBackupInfo& extern_backup_info, share::ObBackupSetFileInfo& backup_set_file_info) +int ObRootBackup::get_tenant_backup_set_file_info(const share::ObBaseBackupInfoStruct &info, + const share::ObExternBackupInfo &extern_backup_info, share::ObBackupSetFileInfo &backup_set_file_info) { int ret = OB_SUCCESS; backup_set_file_info.reset(); @@ -2575,7 +2592,7 @@ int ObRootBackup::get_tenant_backup_set_file_info(const share::ObBaseBackupInfoS } int ObRootBackup::get_tenant_backup_set_file_info( - const share::ObTenantBackupTaskInfo& tenant_task_info, share::ObBackupSetFileInfo& backup_set_file_info) + const share::ObTenantBackupTaskInfo &tenant_task_info, share::ObBackupSetFileInfo &backup_set_file_info) { int ret = OB_SUCCESS; backup_set_file_info.reset(); @@ -2592,7 +2609,7 @@ int ObRootBackup::get_tenant_backup_set_file_info( } int ObRootBackup::add_extern_backup_set_file_info( - const ObBackupSetFileInfo& backup_set_file_info, const bool is_force_stop) + const ObBackupSetFileInfo &backup_set_file_info, const bool is_force_stop) { int ret = OB_SUCCESS; ObExternBackupSetFileInfoMgr extern_backup_set_file_info_mgr; @@ -2625,7 +2642,7 @@ int ObRootBackup::add_extern_backup_set_file_info( } int ObRootBackup::update_extern_backup_set_file_info( - const ObBackupSetFileInfo& backup_set_file_info, const bool is_force_stop) + const ObBackupSetFileInfo &backup_set_file_info, const bool is_force_stop) { int ret = OB_SUCCESS; ObExternBackupSetFileInfoMgr extern_backup_set_file_info_mgr; @@ -2657,7 +2674,7 @@ int ObRootBackup::update_extern_backup_set_file_info( return ret; } -int ObRootBackup::add_backup_set_file_info(const ObBackupSetFileInfo& backup_set_file_info) +int ObRootBackup::add_backup_set_file_info(const ObBackupSetFileInfo &backup_set_file_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2673,7 +2690,7 @@ int ObRootBackup::add_backup_set_file_info(const ObBackupSetFileInfo& backup_set } int ObRootBackup::update_backup_set_file_info( - const ObBackupSetFileInfo& backup_set_file_info, common::ObISQLClient& trans) + const ObBackupSetFileInfo &backup_set_file_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -2689,7 +2706,7 @@ int ObRootBackup::update_backup_set_file_info( } int ObRootBackup::update_backup_set_file_info( - const share::ObBackupSetFileInfo& backup_set_file_info, common::ObMySQLTransaction& trans) + const share::ObBackupSetFileInfo &backup_set_file_info, common::ObMySQLTransaction &trans) { int ret = OB_SUCCESS; ObBackupSetFileInfo src_backup_set_file_info; @@ -2716,7 +2733,7 @@ int ObRootBackup::update_backup_set_file_info( return ret; } -int ObRootBackup::get_dropped_tenant_id_list(const int64_t sys_backup_schema_version, ObIArray& tenant_ids) +int ObRootBackup::get_dropped_tenant_id_list(const int64_t sys_backup_schema_version, ObIArray &tenant_ids) { int ret = OB_SUCCESS; tenant_ids.reset(); @@ -2750,7 +2767,7 @@ int ObRootBackup::get_dropped_tenant_id_list(const int64_t sys_backup_schema_ver } int ObRootBackup::update_dropped_tenants_backup_set_file_info( - const common::ObIArray& backup_set_file_infos, common::ObISQLClient& trans) + const common::ObIArray &backup_set_file_infos, common::ObISQLClient &trans) { int ret = OB_SUCCESS; const bool for_update = true; @@ -2763,7 +2780,7 @@ int ObRootBackup::update_dropped_tenants_backup_set_file_info( } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_file_infos.count(); ++i) { src_backup_set_file_info.reset(); - const ObBackupSetFileInfo& dst_backup_set_file_info = backup_set_file_infos.at(i); + const ObBackupSetFileInfo &dst_backup_set_file_info = backup_set_file_infos.at(i); if (OB_FAIL(ObBackupSetFilesOperator::get_tenant_backup_set_file_info(dst_backup_set_file_info.tenant_id_, dst_backup_set_file_info.backup_set_id_, dst_backup_set_file_info.incarnation_, @@ -2785,7 +2802,7 @@ int ObRootBackup::update_dropped_tenants_backup_set_file_info( } int ObRootBackup::update_dropped_tenant_backup_set_file_info( - const ObBackupSetFileInfo& sys_backup_set_file_info, const uint64_t tenant_id, ObISQLClient& trans) + const ObBackupSetFileInfo &sys_backup_set_file_info, const uint64_t tenant_id, ObISQLClient &trans) { int ret = OB_SUCCESS; const bool for_update = true; @@ -2830,7 +2847,7 @@ int ObRootBackup::update_dropped_tenant_backup_set_file_info( } int ObRootBackup::do_extern_single_backup_set_info( - const share::ObBackupSetFileInfo& backup_set_file_info, const bool is_force_stop) + const share::ObBackupSetFileInfo &backup_set_file_info, const bool is_force_stop) { int ret = OB_SUCCESS; ObExternSingleBackupSetInfoMgr extern_single_backup_set_info_mgr; @@ -2864,8 +2881,8 @@ int ObRootBackup::do_extern_single_backup_set_info( return ret; } -int ObRootBackup::calculate_tenant_start_replay_log_ts(const share::ObTenantBackupTaskInfo& tenant_task_info, - share::ObIBackupLeaseService& backup_lease_service, int64_t& start_replay_log_ts) +int ObRootBackup::calculate_tenant_start_replay_log_ts(const share::ObTenantBackupTaskInfo &tenant_task_info, + share::ObIBackupLeaseService &backup_lease_service, int64_t &start_replay_log_ts) { int ret = OB_SUCCESS; ObBackupBaseDataPathInfo path_info; @@ -2907,9 +2924,9 @@ int ObRootBackup::calculate_tenant_start_replay_log_ts(const share::ObTenantBack return ret; } -int ObRootBackup::do_tenant_backup_index_reform(const share::ObTenantBackupTaskInfo& tenant_task_info, - const ObBackupBaseDataPathInfo& path_info, share::ObIBackupLeaseService& backup_lease_service, - storage::ObPhyRestoreMetaIndexStore& meta_index_store) +int ObRootBackup::do_tenant_backup_index_reform(const share::ObTenantBackupTaskInfo &tenant_task_info, + const ObBackupBaseDataPathInfo &path_info, share::ObIBackupLeaseService &backup_lease_service, + storage::ObPhyRestoreMetaIndexStore &meta_index_store) { int ret = OB_SUCCESS; storage::ObBackupMetaIndexReformer meta_index_reformer; @@ -2928,9 +2945,9 @@ int ObRootBackup::do_tenant_backup_index_reform(const share::ObTenantBackupTaskI return ret; } -int ObRootBackup::do_get_tenant_start_replay_log_ts(const share::ObTenantBackupTaskInfo& tenant_task_info, - const ObBackupBaseDataPathInfo& path_info, storage::ObPhyRestoreMetaIndexStore& meta_index_store, - int64_t& start_replay_log_ts) +int ObRootBackup::do_get_tenant_start_replay_log_ts(const share::ObTenantBackupTaskInfo &tenant_task_info, + const ObBackupBaseDataPathInfo &path_info, storage::ObPhyRestoreMetaIndexStore &meta_index_store, + int64_t &start_replay_log_ts) { int ret = OB_SUCCESS; start_replay_log_ts = INT64_MAX; @@ -2971,8 +2988,8 @@ int ObRootBackup::do_get_tenant_start_replay_log_ts(const share::ObTenantBackupT return ret; } -int ObRootBackup::get_dropped_tenant_backup_set_file_info(const share::ObTenantBackupTaskInfo& sys_task_info, - const common::ObIArray& tenant_ids, common::ObIArray& backup_set_file_infos) +int ObRootBackup::get_dropped_tenant_backup_set_file_info(const share::ObTenantBackupTaskInfo &sys_task_info, + const common::ObIArray &tenant_ids, common::ObIArray &backup_set_file_infos) { int ret = OB_SUCCESS; ObBackupSetFileInfo sys_backup_set_file_info; @@ -3024,7 +3041,7 @@ int ObRootBackup::get_dropped_tenant_backup_set_file_info(const share::ObTenantB } int ObRootBackup::update_dropped_tenants_extern_backup_set_file_info( - const common::ObIArray& backup_set_file_infos) + const common::ObIArray &backup_set_file_infos) { int ret = OB_SUCCESS; bool is_force_stop = false; @@ -3036,7 +3053,7 @@ int ObRootBackup::update_dropped_tenants_extern_backup_set_file_info( } else if (FALSE_IT(is_force_stop = OB_SUCCESS != extern_device_error_)) { } else { for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_file_infos.count(); ++i) { - const ObBackupSetFileInfo& backup_set_file_info = backup_set_file_infos.at(i); + const ObBackupSetFileInfo &backup_set_file_info = backup_set_file_infos.at(i); if (OB_FAIL(update_extern_backup_set_file_info(backup_set_file_info, is_force_stop))) { LOG_WARN("failed to update dropped tenants extern backup set file info", K(ret), K(backup_set_file_info)); } @@ -3046,7 +3063,7 @@ int ObRootBackup::update_dropped_tenants_extern_backup_set_file_info( } int ObRootBackup::insert_tenant_backup_set_file_failed( - ObMySQLTransaction& trans, const share::ObTenantBackupTaskInfo& task_info) + ObMySQLTransaction &trans, const share::ObTenantBackupTaskInfo &task_info) { int ret = OB_SUCCESS; ObBackupSetFileInfo backup_set_file_info; @@ -3069,7 +3086,7 @@ int ObRootBackup::insert_tenant_backup_set_file_failed( } int ObRootBackup::do_tenant_update_task_his_and_backup_set_file( - const share::ObTenantBackupTaskInfo& tenant_task_info, const ObBackupSetFileInfo& backup_set_file_info) + const share::ObTenantBackupTaskInfo &tenant_task_info, const ObBackupSetFileInfo &backup_set_file_info) { int ret = OB_SUCCESS; ObMySQLTransaction trans; @@ -3127,10 +3144,10 @@ ObTenantBackup::ObTenantBackup() backup_lease_service_(NULL) {} -int ObTenantBackup::init(const ObBaseBackupInfoStruct& info, share::schema::ObMultiVersionSchemaService& schema_service, - ObRootBalancer& root_balancer, common::ObMySQLProxy& sql_proxy, ObServerManager& server_mgr, - ObRebalanceTaskMgr& rebalancer_mgr, obrpc::ObSrvRpcProxy& rpc_proxy, ObRootBackup& root_backup, - share::ObIBackupLeaseService& backup_lease_service) +int ObTenantBackup::init(const ObBaseBackupInfoStruct &info, share::schema::ObMultiVersionSchemaService &schema_service, + ObRootBalancer &root_balancer, common::ObMySQLProxy &sql_proxy, ObServerManager &server_mgr, + ObRebalanceTaskMgr &rebalancer_mgr, obrpc::ObSrvRpcProxy &rpc_proxy, ObRootBackup &root_backup, + share::ObIBackupLeaseService &backup_lease_service) { int ret = OB_SUCCESS; if (is_inited_) { @@ -3161,7 +3178,7 @@ int ObTenantBackup::init(const ObBaseBackupInfoStruct& info, share::schema::ObMu return ret; } -int ObTenantBackup::get_tenant_backup_task_info(ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::get_tenant_backup_task_info(ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; task_info.reset(); @@ -3197,7 +3214,7 @@ int ObTenantBackup::do_backup() if (OB_FAIL(get_tenant_backup_task_info(task_info, trans))) { LOG_WARN("failed to get tenant backup task info", K(ret), K(tenant_id_), K(backup_set_id_), K(incarnation_)); } else { - const ObTenantBackupTaskInfo::BackupStatus& status = task_info.status_; + const ObTenantBackupTaskInfo::BackupStatus &status = task_info.status_; switch (status) { case ObTenantBackupTaskInfo::GENERATE: if (OB_FAIL(do_generate(task_info, trans))) { @@ -3241,7 +3258,7 @@ int ObTenantBackup::do_backup() return ret; } -int ObTenantBackup::do_generate(const share::ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::do_generate(const share::ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; int64_t MAX_BATCH_GENERATE_TASK_NUM = 1024; @@ -3320,14 +3337,14 @@ int ObTenantBackup::do_generate(const share::ObTenantBackupTaskInfo& task_info, return ret; } -int ObTenantBackup::generate_tablegroup_backup_task(const share::ObTenantBackupTaskInfo& task_info, - const ObBreakPointPGInfo& point_pg_info, const int64_t max_batch_generate_task_num, - ObIArray& pg_backup_task_infos, bool& is_finish) +int ObTenantBackup::generate_tablegroup_backup_task(const share::ObTenantBackupTaskInfo &task_info, + const ObBreakPointPGInfo &point_pg_info, const int64_t max_batch_generate_task_num, + ObIArray &pg_backup_task_infos, bool &is_finish) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; ObArray tablegroup_ids; - const ObTablegroupSchema* tablegroup_schema = NULL; + const ObTablegroupSchema *tablegroup_schema = NULL; is_finish = false; int64_t table_id_index = 0; ObBreakPointPGInfo point_info = point_pg_info; @@ -3413,14 +3430,14 @@ int ObTenantBackup::generate_tablegroup_backup_task(const share::ObTenantBackupT return ret; } -int ObTenantBackup::generate_standalone_backup_task(const share::ObTenantBackupTaskInfo& task_info, - const ObBreakPointPGInfo& point_pg_info, const int64_t max_batch_generate_task_num, - ObIArray& pg_backup_task_infos) +int ObTenantBackup::generate_standalone_backup_task(const share::ObTenantBackupTaskInfo &task_info, + const ObBreakPointPGInfo &point_pg_info, const int64_t max_batch_generate_task_num, + ObIArray &pg_backup_task_infos) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; ObArray table_ids; - const ObSimpleTableSchemaV2* table_schema = NULL; + const ObSimpleTableSchemaV2 *table_schema = NULL; int64_t table_id_index = 0; if (!is_inited_) { @@ -3489,8 +3506,8 @@ int ObTenantBackup::generate_standalone_backup_task(const share::ObTenantBackupT return ret; } -int ObTenantBackup::inner_generate_pg_backup_task(const share::ObTenantBackupTaskInfo& task_info, const ObPGKey& pg_key, - share::ObPGBackupTaskInfo& pg_backup_task_info) +int ObTenantBackup::inner_generate_pg_backup_task(const share::ObTenantBackupTaskInfo &task_info, const ObPGKey &pg_key, + share::ObPGBackupTaskInfo &pg_backup_task_info) { int ret = OB_SUCCESS; pg_backup_task_info.reset(); @@ -3516,7 +3533,7 @@ int ObTenantBackup::inner_generate_pg_backup_task(const share::ObTenantBackupTas return ret; } -int ObTenantBackup::do_backup(const share::ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::do_backup(const share::ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3560,7 +3577,7 @@ int ObTenantBackup::do_backup(const share::ObTenantBackupTaskInfo& task_info, co int64_t output_bytes = 0; for (int64_t i = 0; i < pg_task_infos.count(); ++i) { - const ObPGBackupTaskInfo& pg_task_info = pg_task_infos.at(i); + const ObPGBackupTaskInfo &pg_task_info = pg_task_infos.at(i); const int32_t pg_backup_result = pg_task_info.result_; if (OB_SUCCESS == task_info_result) { task_info_result = pg_backup_result; @@ -3603,8 +3620,8 @@ int ObTenantBackup::do_backup(const share::ObTenantBackupTaskInfo& task_info, co return ret; } -int ObTenantBackup::update_tenant_backup_task(const share::ObTenantBackupTaskInfo& src_info, - const share::ObTenantBackupTaskInfo& dest_info, common::ObISQLClient& trans) +int ObTenantBackup::update_tenant_backup_task(const share::ObTenantBackupTaskInfo &src_info, + const share::ObTenantBackupTaskInfo &dest_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; share::ObTenantBackupTaskUpdater tenant_task_updater; @@ -3623,8 +3640,8 @@ int ObTenantBackup::update_tenant_backup_task(const share::ObTenantBackupTaskInf return ret; } -int ObTenantBackup::get_finished_backup_task(const share::ObTenantBackupTaskInfo& task_info, - common::ObIArray& pg_task_infos, common::ObISQLClient& trans) +int ObTenantBackup::get_finished_backup_task(const share::ObTenantBackupTaskInfo &task_info, + common::ObIArray &pg_task_infos, common::ObISQLClient &trans) { int ret = OB_SUCCESS; pg_task_infos.reset(); @@ -3650,7 +3667,7 @@ int ObTenantBackup::get_finished_backup_task(const share::ObTenantBackupTaskInfo return ret; } -int ObTenantBackup::get_breakpoint_pg_info(ObBreakPointPGInfo& breakpoint_pg_info) +int ObTenantBackup::get_breakpoint_pg_info(ObBreakPointPGInfo &breakpoint_pg_info) { int ret = OB_SUCCESS; ObPGBackupTaskInfo pg_task_info; @@ -3672,7 +3689,7 @@ int ObTenantBackup::get_breakpoint_pg_info(ObBreakPointPGInfo& breakpoint_pg_inf } int ObTenantBackup::find_break_table_id_index( - const common::ObIArray& table_ids, const ObBreakPointPGInfo& breakpoint_pg_info, int64_t& index) + const common::ObIArray &table_ids, const ObBreakPointPGInfo &breakpoint_pg_info, int64_t &index) { int ret = OB_SUCCESS; index = 0; @@ -3698,7 +3715,7 @@ int ObTenantBackup::find_break_table_id_index( } int ObTenantBackup::find_tg_partition_index( - const ObBreakPointPGInfo& breakpoint_pg_info, share::schema::ObTablegroupPartitionKeyIter& pkey_iter) + const ObBreakPointPGInfo &breakpoint_pg_info, share::schema::ObTablegroupPartitionKeyIter &pkey_iter) { int ret = OB_SUCCESS; if (!breakpoint_pg_info.is_valid()) { @@ -3721,7 +3738,7 @@ int ObTenantBackup::find_tg_partition_index( } int ObTenantBackup::find_sd_partition_index( - const ObBreakPointPGInfo& breakpoint_pg_info, share::schema::ObTablePartitionKeyIter& pkey_iter) + const ObBreakPointPGInfo &breakpoint_pg_info, share::schema::ObTablePartitionKeyIter &pkey_iter) { int ret = OB_SUCCESS; if (!breakpoint_pg_info.is_valid()) { @@ -3743,7 +3760,7 @@ int ObTenantBackup::find_sd_partition_index( return ret; } -int ObTenantBackup::do_finish(const share::ObTenantBackupTaskInfo& task_info) +int ObTenantBackup::do_finish(const share::ObTenantBackupTaskInfo &task_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -3756,7 +3773,7 @@ int ObTenantBackup::do_finish(const share::ObTenantBackupTaskInfo& task_info) return ret; } -int ObTenantBackup::upload_pg_list(const ObTenantBackupTaskInfo& task_info) +int ObTenantBackup::upload_pg_list(const ObTenantBackupTaskInfo &task_info) { int ret = OB_SUCCESS; ObExternPGListMgr pg_list_mgr; @@ -3789,12 +3806,12 @@ int ObTenantBackup::upload_pg_list(const ObTenantBackupTaskInfo& task_info) return ret; } -int ObTenantBackup::add_tablegroup_key_to_extern_list(ObExternPGListMgr& pg_list_mgr) +int ObTenantBackup::add_tablegroup_key_to_extern_list(ObExternPGListMgr &pg_list_mgr) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; ObArray tablegroup_ids; - const ObTablegroupSchema* tablegroup_schema = NULL; + const ObTablegroupSchema *tablegroup_schema = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("tenant backup do not init", K(ret)); @@ -3831,12 +3848,12 @@ int ObTenantBackup::add_tablegroup_key_to_extern_list(ObExternPGListMgr& pg_list return ret; } -int ObTenantBackup::add_standalone_key_to_extern_list(ObExternPGListMgr& pg_list_mgr) +int ObTenantBackup::add_standalone_key_to_extern_list(ObExternPGListMgr &pg_list_mgr) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; ObArray table_ids; - const ObSimpleTableSchemaV2* table_schema = NULL; + const ObSimpleTableSchemaV2 *table_schema = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("tenant backup do not init", K(ret)); @@ -3876,7 +3893,7 @@ int ObTenantBackup::add_standalone_key_to_extern_list(ObExternPGListMgr& pg_list return ret; } -int ObTenantBackup::check_doing_pg_tasks(const ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::check_doing_pg_tasks(const ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3909,7 +3926,7 @@ int ObTenantBackup::check_doing_pg_tasks(const ObTenantBackupTaskInfo& task_info LOG_WARN("failed to get doing pg task", K(ret), K(task_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_backup_tasks.count(); ++i) { - const ObPGBackupTaskInfo& pg_task_info = pg_backup_tasks.at(i); + const ObPGBackupTaskInfo &pg_task_info = pg_backup_tasks.at(i); if (OB_SUCCESS != (tmp_ret = check_doing_pg_task(pg_task_info, task_start_time, current_time, trans))) { LOG_WARN("failed to check doing pg task", K(tmp_ret), K(pg_task_info)); } @@ -3918,8 +3935,8 @@ int ObTenantBackup::check_doing_pg_tasks(const ObTenantBackupTaskInfo& task_info return ret; } -int ObTenantBackup::check_doing_pg_task(const ObPGBackupTaskInfo& pg_backup_task, const int64_t task_start_time, - const int64_t current_time, common::ObISQLClient& trans) +int ObTenantBackup::check_doing_pg_task(const ObPGBackupTaskInfo &pg_backup_task, const int64_t task_start_time, + const int64_t current_time, common::ObISQLClient &trans) { int ret = OB_SUCCESS; @@ -3964,7 +3981,7 @@ int ObTenantBackup::check_doing_pg_task(const ObPGBackupTaskInfo& pg_backup_task return ret; } -int ObTenantBackup::check_backup_task_on_progress(const ObPGBackupTaskInfo& pg_task_info, bool& is_exist) +int ObTenantBackup::check_backup_task_on_progress(const ObPGBackupTaskInfo &pg_task_info, bool &is_exist) { int ret = OB_SUCCESS; is_exist = true; @@ -3977,7 +3994,7 @@ int ObTenantBackup::check_backup_task_on_progress(const ObPGBackupTaskInfo& pg_t LOG_WARN("check backup task on progress get invalid argument", K(ret), K(pg_task_info)); } else { share::ObServerStatus server_status; - const common::ObAddr& dest = pg_task_info.server_; + const common::ObAddr &dest = pg_task_info.server_; if (OB_FAIL(server_mgr_->is_server_exist(dest, is_exist))) { LOG_WARN("fail to check server exist", K(ret)); } else if (!is_exist) { @@ -3997,7 +4014,7 @@ int ObTenantBackup::check_backup_task_on_progress(const ObPGBackupTaskInfo& pg_t return ret; } -int ObTenantBackup::check_task_in_rebalancer_mgr(const ObPGBackupTaskInfo& pg_task_info, bool& is_exist) +int ObTenantBackup::check_task_in_rebalancer_mgr(const ObPGBackupTaskInfo &pg_task_info, bool &is_exist) { int ret = OB_SUCCESS; ObBackupTaskInfo mock_backup_task_info; @@ -4023,7 +4040,7 @@ int ObTenantBackup::check_task_in_rebalancer_mgr(const ObPGBackupTaskInfo& pg_ta } int ObTenantBackup::check_doing_task_finished( - const ObPGBackupTaskInfo& pg_task_info, common::ObISQLClient& trans, bool& is_finished) + const ObPGBackupTaskInfo &pg_task_info, common::ObISQLClient &trans, bool &is_finished) { int ret = OB_SUCCESS; ObPartitionKey pkey; @@ -4050,7 +4067,7 @@ int ObTenantBackup::check_doing_task_finished( return ret; } -int ObTenantBackup::update_lost_task_finished(const ObPGBackupTaskInfo& pg_task_info, common::ObISQLClient& trans) +int ObTenantBackup::update_lost_task_finished(const ObPGBackupTaskInfo &pg_task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray pkeys; @@ -4074,7 +4091,7 @@ int ObTenantBackup::update_lost_task_finished(const ObPGBackupTaskInfo& pg_task_ ObPartitionKey pkey; for (int64_t i = 0; OB_SUCC(ret) && i < pg_task_infos.count(); ++i) { pkey.reset(); - const ObPGBackupTaskInfo& pg_backup_task = pg_task_infos.at(i); + const ObPGBackupTaskInfo &pg_backup_task = pg_task_infos.at(i); if (ObPGBackupTaskInfo::FINISH == pg_backup_task.status_) { // do nothing } else if (OB_FAIL(pkey.init(pg_backup_task.table_id_, pg_backup_task.partition_id_, 0))) { @@ -4096,9 +4113,9 @@ int ObTenantBackup::update_lost_task_finished(const ObPGBackupTaskInfo& pg_task_ return ret; } -int ObTenantBackup::do_with_finished_task(const share::ObTenantBackupTaskInfo& task_info, - const common::ObIArray& pg_task_infos, common::ObISQLClient& trans, - bool& can_report_task) +int ObTenantBackup::do_with_finished_task(const share::ObTenantBackupTaskInfo &task_info, + const common::ObIArray &pg_task_infos, common::ObISQLClient &trans, + bool &can_report_task) { int ret = OB_SUCCESS; can_report_task = false; @@ -4120,9 +4137,9 @@ int ObTenantBackup::do_with_finished_task(const share::ObTenantBackupTaskInfo& t return ret; } -int ObTenantBackup::check_finished_task_result(const share::ObTenantBackupTaskInfo& task_info, - const common::ObIArray& pg_task_infos, common::ObISQLClient& trans, bool& need_retry, - bool& can_report_task) +int ObTenantBackup::check_finished_task_result(const share::ObTenantBackupTaskInfo &task_info, + const common::ObIArray &pg_task_infos, common::ObISQLClient &trans, bool &need_retry, + bool &can_report_task) { int ret = OB_SUCCESS; need_retry = false; @@ -4141,7 +4158,7 @@ int ObTenantBackup::check_finished_task_result(const share::ObTenantBackupTaskIn LOG_WARN("failed to do with finished task", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_task_infos.count(); ++i) { - const ObPGBackupTaskInfo& pg_task_info = pg_task_infos.at(i); + const ObPGBackupTaskInfo &pg_task_info = pg_task_infos.at(i); // TODO() add ret_code with not need retry const int32_t result = pg_task_info.result_; if (OB_SUCCESS == result) { @@ -4179,7 +4196,7 @@ int ObTenantBackup::check_finished_task_result(const share::ObTenantBackupTaskIn } int ObTenantBackup::reset_pg_backup_tasks( - const common::ObIArray& pg_task_infos, common::ObISQLClient& trans) + const common::ObIArray &pg_task_infos, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray reset_task_infos; @@ -4190,7 +4207,7 @@ int ObTenantBackup::reset_pg_backup_tasks( LOG_WARN("tenant backup do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_task_infos.count(); ++i) { - const ObPGBackupTaskInfo& pg_task_info = pg_task_infos.at(i); + const ObPGBackupTaskInfo &pg_task_info = pg_task_infos.at(i); if (OB_SUCCESS == pg_task_info.result_) { // do nothing } else { @@ -4229,7 +4246,7 @@ int ObTenantBackup::reset_pg_backup_tasks( } int ObTenantBackup::update_tenant_backup_task_result( - const ObTenantBackupTaskInfo& task_info, const int32_t result, common::ObISQLClient& trans) + const ObTenantBackupTaskInfo &task_info, const int32_t result, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObTenantBackupTaskInfo dest_task_info; @@ -4248,8 +4265,8 @@ int ObTenantBackup::update_tenant_backup_task_result( return ret; } -int ObTenantBackup::do_tenat_backup_when_succeed(const share::ObTenantBackupTaskInfo& task_info, - const ObIArray& pg_task_infos, common::ObISQLClient& trans, bool& can_report_task) +int ObTenantBackup::do_tenat_backup_when_succeed(const share::ObTenantBackupTaskInfo &task_info, + const ObIArray &pg_task_infos, common::ObISQLClient &trans, bool &can_report_task) { int ret = OB_SUCCESS; can_report_task = false; @@ -4266,8 +4283,8 @@ int ObTenantBackup::do_tenat_backup_when_succeed(const share::ObTenantBackupTask return ret; } -int ObTenantBackup::do_tenant_backup_when_failed(const share::ObTenantBackupTaskInfo& task_info, - const ObIArray& pg_task_infos, common::ObISQLClient& trans, bool& can_report_task) +int ObTenantBackup::do_tenant_backup_when_failed(const share::ObTenantBackupTaskInfo &task_info, + const ObIArray &pg_task_infos, common::ObISQLClient &trans, bool &can_report_task) { int ret = OB_SUCCESS; can_report_task = false; @@ -4288,7 +4305,7 @@ int ObTenantBackup::do_tenant_backup_when_failed(const share::ObTenantBackupTask } // TODO() need add obtest -int ObTenantBackup::cancel_doing_pg_tasks(const share::ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::cancel_doing_pg_tasks(const share::ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; ObArray pg_backup_tasks; @@ -4308,8 +4325,8 @@ int ObTenantBackup::cancel_doing_pg_tasks(const share::ObTenantBackupTaskInfo& t } else { LOG_INFO("get one doing pg task", K(pg_backup_tasks.count())); for (int64_t i = 0; OB_SUCC(ret) && i < pg_backup_tasks.count(); ++i) { - const ObPGBackupTaskInfo& pg_backup_task = pg_backup_tasks.at(i); - const ObAddr& task_server = pg_backup_task.server_; + const ObPGBackupTaskInfo &pg_backup_task = pg_backup_tasks.at(i); + const ObAddr &task_server = pg_backup_task.server_; obrpc::ObCancelTaskArg rpc_arg; rpc_arg.task_id_ = pg_backup_task.trace_id_; if (OB_FAIL(rpc_proxy_->to(task_server).cancel_sys_task(rpc_arg))) { @@ -4325,7 +4342,7 @@ int ObTenantBackup::cancel_doing_pg_tasks(const share::ObTenantBackupTaskInfo& t return ret; } -int ObTenantBackup::clean_pg_backup_task(common::ObISQLClient& trans, const share::ObTenantBackupTaskInfo& task_info) +int ObTenantBackup::clean_pg_backup_task(common::ObISQLClient &trans, const share::ObTenantBackupTaskInfo &task_info) { // TODO backup fix it int ret = OB_SUCCESS; @@ -4334,7 +4351,7 @@ int ObTenantBackup::clean_pg_backup_task(common::ObISQLClient& trans, const shar return ret; } -int ObTenantBackup::do_cancel(const share::ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::do_cancel(const share::ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { LOG_INFO("start do cancel", K(task_info)); int ret = OB_SUCCESS; @@ -4405,7 +4422,7 @@ int ObTenantBackup::do_cancel(const share::ObTenantBackupTaskInfo& task_info, co } int ObTenantBackup::get_table_count_with_partition(const uint64_t tenant_id, const int64_t tablegroup_id, - share::schema::ObSchemaGetterGuard& schema_guard, int64_t& table_count) + share::schema::ObSchemaGetterGuard &schema_guard, int64_t &table_count) { int ret = OB_SUCCESS; table_count = 0; @@ -4419,7 +4436,7 @@ int ObTenantBackup::get_table_count_with_partition(const uint64_t tenant_id, con } else { for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) { const uint64_t table_id = table_ids.at(i); - const ObSimpleTableSchemaV2* table_schema = NULL; + const ObSimpleTableSchemaV2 *table_schema = NULL; if (OB_FAIL(schema_guard.get_table_schema(table_id, table_schema))) { LOG_WARN("failed to get table schema", K(ret), K(table_id)); } else if (OB_ISNULL(table_schema)) { @@ -4434,7 +4451,7 @@ int ObTenantBackup::get_table_count_with_partition(const uint64_t tenant_id, con } int ObTenantBackup::check_standalone_table_need_backup( - const share::schema::ObSimpleTableSchemaV2* table_schema, bool& need_backup) + const share::schema::ObSimpleTableSchemaV2 *table_schema, bool &need_backup) { int ret = OB_SUCCESS; ObIndexStatus status; @@ -4460,7 +4477,7 @@ int ObTenantBackup::check_standalone_table_need_backup( return ret; } -int ObTenantBackup::cancel_pending_pg_tasks(const ObTenantBackupTaskInfo& task_info, common::ObISQLClient& trans) +int ObTenantBackup::cancel_pending_pg_tasks(const ObTenantBackupTaskInfo &task_info, common::ObISQLClient &trans) { int ret = OB_SUCCESS; share::ObPGBackupTaskUpdater pg_task_updater; @@ -4479,7 +4496,7 @@ int ObTenantBackup::cancel_pending_pg_tasks(const ObTenantBackupTaskInfo& task_i return ret; } -int ObTenantBackup::commit_trans(ObMySQLTransaction& trans) +int ObTenantBackup::commit_trans(ObMySQLTransaction &trans) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -4496,7 +4513,7 @@ int ObTenantBackup::commit_trans(ObMySQLTransaction& trans) return ret; } -int ObTenantBackup::start_trans(ObTimeoutCtx& timeout_ctx, ObMySQLTransaction& trans) +int ObTenantBackup::start_trans(ObTimeoutCtx &timeout_ctx, ObMySQLTransaction &trans) { int ret = OB_SUCCESS; const int64_t MAX_EXECUTE_TIMEOUT_US = 600L * 1000 * 1000; // 600s @@ -4512,7 +4529,7 @@ int ObTenantBackup::start_trans(ObTimeoutCtx& timeout_ctx, ObMySQLTransaction& t } int ObTenantBackup::add_finish_backup_rootservice_event( - const share::ObTenantBackupTaskInfo& tenant_backup_task, const share::ObPGBackupTaskInfo& pg_backup_task) + const share::ObTenantBackupTaskInfo &tenant_backup_task, const share::ObPGBackupTaskInfo &pg_backup_task) { int ret = OB_SUCCESS; char comment[MAX_ROOTSERVICE_EVENT_VALUE_LENGTH] = ""; @@ -4573,7 +4590,7 @@ int ObTenantBackup::add_finish_backup_rootservice_event( return ret; } -int ObBackupUtil::check_sys_tenant_trans_alive(share::ObBackupInfoManager& info_manager, common::ObISQLClient& trans) +int ObBackupUtil::check_sys_tenant_trans_alive(share::ObBackupInfoManager &info_manager, common::ObISQLClient &trans) { int ret = OB_SUCCESS; const uint64_t tenant_id = OB_SYS_TENANT_ID; @@ -4591,7 +4608,7 @@ int ObBackupUtil::check_sys_tenant_trans_alive(share::ObBackupInfoManager& info_ return ret; } -int ObBackupUtil::check_sys_clean_info_trans_alive(common::ObISQLClient& trans) +int ObBackupUtil::check_sys_clean_info_trans_alive(common::ObISQLClient &trans) { int ret = OB_SUCCESS; const uint64_t tenant_id = OB_SYS_TENANT_ID; @@ -4609,14 +4626,14 @@ int ObBackupUtil::check_sys_clean_info_trans_alive(common::ObISQLClient& trans) return ret; } -int ObBackupUtil::get_now_time(common::ObISQLClient& trans, int64_t& now_ts) +int ObBackupUtil::get_now_time(common::ObISQLClient &trans, int64_t &now_ts) { int ret = OB_SUCCESS; now_ts = 0; ObSqlString sql; const int64_t tenant_id = OB_SYS_TENANT_ID; ObMySQLProxy::MySQLResult res; - sqlclient::ObMySQLResult* result = NULL; + sqlclient::ObMySQLResult *result = NULL; if (OB_FAIL(sql.assign_fmt("SELECT TIME_TO_USEC(now(6)) AS now_ts"))) { LOG_WARN("fail to assign sql", K(ret)); } else if (OB_FAIL(trans.read(res, tenant_id, sql.ptr()))) { @@ -4639,7 +4656,7 @@ int ObBackupUtil::get_now_time(common::ObISQLClient& trans, int64_t& now_ts) } int ObBackupUtil::check_backup_dest_lifecycle( - const share::ObBackupDest& backup_dest, const bool is_update_reserved_backup_timestamp) + const share::ObBackupDest &backup_dest, const bool is_update_reserved_backup_timestamp) { int ret = OB_SUCCESS; ObStorageUtil util(false /*need_retry*/); diff --git a/src/share/backup/ob_backup_info_mgr.cpp b/src/share/backup/ob_backup_info_mgr.cpp index 82a6917bd8f6c666c6bf7ef0b422e12511b01442..d4cc728465178efd262cab78f7960defe3c8ef4a 100644 --- a/src/share/backup/ob_backup_info_mgr.cpp +++ b/src/share/backup/ob_backup_info_mgr.cpp @@ -79,13 +79,13 @@ ObLogArchiveInfoMgr::ObLogArchiveInfoMgr() ObLogArchiveInfoMgr::~ObLogArchiveInfoMgr() {} -ObLogArchiveInfoMgr& ObLogArchiveInfoMgr::get_instance() +ObLogArchiveInfoMgr &ObLogArchiveInfoMgr::get_instance() { static ObLogArchiveInfoMgr mgr; return mgr; } -int ObLogArchiveInfoMgr::init(common::ObMySQLProxy& sql_proxy) +int ObLogArchiveInfoMgr::init(common::ObMySQLProxy &sql_proxy) { int ret = OB_SUCCESS; lib::ObLabel label("BACKUP_LR_INFO"); @@ -103,7 +103,7 @@ int ObLogArchiveInfoMgr::init(common::ObMySQLProxy& sql_proxy) } int ObLogArchiveInfoMgr::get_log_archive_status( - const uint64_t tenant_id, const int64_t need_ts, ObLogArchiveSimpleInfo& status) + const uint64_t tenant_id, const int64_t need_ts, ObLogArchiveSimpleInfo &status) { int ret = OB_SUCCESS; const int64_t CACHE_EXPIRED_TIME = 1 * 1000 * 1000; // 1s @@ -145,7 +145,7 @@ int ObLogArchiveInfoMgr::get_log_archive_status( return ret; } -int ObLogArchiveInfoMgr::get_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo& status) +int ObLogArchiveInfoMgr::get_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo &status) { int ret = OB_SUCCESS; @@ -168,7 +168,7 @@ int ObLogArchiveInfoMgr::try_retire_status_() if (status_map_.size() >= OB_MAX_SERVER_TENANT_CNT) { for (STATUS_MAP::const_iterator it = status_map_.begin(); OB_SUCC(ret) && it != status_map_.end(); ++it) { const uint64_t tenant_id = it->first; - const ObLogArchiveSimpleInfo& status = it->second; + const ObLogArchiveSimpleInfo &status = it->second; if (status.update_ts_ < del_ts) { del_tenant_id = tenant_id; del_ts = status.update_ts_; @@ -190,7 +190,7 @@ int ObLogArchiveInfoMgr::try_retire_status_() return ret; } -int ObLogArchiveInfoMgr::renew_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo& status) +int ObLogArchiveInfoMgr::renew_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo &status) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr info_mgr; @@ -267,7 +267,7 @@ void ObBackupInfoMgr::ObBackupInfoUpdateTask::runTimerTask() } } -ObBackupInfoMgr& ObBackupInfoMgr::get_instance() +ObBackupInfoMgr &ObBackupInfoMgr::get_instance() { static ObBackupInfoMgr backup_info; return backup_info; @@ -281,7 +281,6 @@ ObBackupInfoMgr::ObBackupInfoMgr() cur_backup_info_(nullptr), cur_backup_piece_(nullptr), cur_restore_job_(nullptr), - cur_base_backup_started_(nullptr), lock_(ObLatchIds::BACKUP_INFO_MGR_LOCK), mutex_(ObLatchIds::BACKUP_INFO_MGR_LOCK), is_backup_loaded_(false), @@ -295,7 +294,7 @@ ObBackupInfoMgr::~ObBackupInfoMgr() destroy(); } -int ObBackupInfoMgr::init(common::ObMySQLProxy& sql_proxy, ObBackupDestDetector& backup_dest_detector) +int ObBackupInfoMgr::init(common::ObMySQLProxy &sql_proxy, ObBackupDestDetector &backup_dest_detector) { int ret = OB_SUCCESS; if (is_inited_) { @@ -309,7 +308,6 @@ int ObBackupInfoMgr::init(common::ObMySQLProxy& sql_proxy, ObBackupDestDetector& sql_proxy_ = &sql_proxy; cur_backup_info_ = &backup_infos_[0]; cur_backup_piece_ = &backup_pieces_[0]; - cur_base_backup_started_ = &is_base_backup_started_[0]; backup_dest_detector_ = &backup_dest_detector; is_inited_ = true; } @@ -346,7 +344,7 @@ void ObBackupInfoMgr::destroy() is_inited_ = false; } -int ObBackupInfoMgr::get_log_archive_backup_info(ObLogArchiveBackupInfo& info) +int ObBackupInfoMgr::get_log_archive_backup_info(ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; ObNonFrozenBackupPieceInfo backup_piece; @@ -357,7 +355,7 @@ int ObBackupInfoMgr::get_log_archive_backup_info(ObLogArchiveBackupInfo& info) } int ObBackupInfoMgr::get_log_archive_backup_info_and_piece( - ObLogArchiveBackupInfo& info, ObNonFrozenBackupPieceInfo& piece) + ObLogArchiveBackupInfo &info, ObNonFrozenBackupPieceInfo &piece) { int ret = OB_SUCCESS; bool is_loaded = true; @@ -392,7 +390,7 @@ int ObBackupInfoMgr::get_log_archive_backup_info_and_piece( return ret; } -int ObBackupInfoMgr::get_restore_info_from_cache(const uint64_t tenant_id, ObSimplePhysicalRestoreJob& simple_job_info) +int ObBackupInfoMgr::get_restore_info_from_cache(const uint64_t tenant_id, ObSimplePhysicalRestoreJob &simple_job_info) { int ret = OB_ENTRY_NOT_EXIST; @@ -403,7 +401,7 @@ int ObBackupInfoMgr::get_restore_info_from_cache(const uint64_t tenant_id, ObSim SpinRLockGuard guard(lock_); if (is_restore_loaded_) { for (int64_t i = 0; i < cur_restore_job_->count(); ++i) { - ObPhysicalRestoreJob& cur_job = cur_restore_job_->at(i); + ObPhysicalRestoreJob &cur_job = cur_restore_job_->at(i); if (cur_job.tenant_id_ == tenant_id) { if (OB_FAIL(cur_job.copy_to(simple_job_info))) { LOG_WARN("failed to copy to simple job info", K(ret), K(cur_job)); @@ -417,7 +415,7 @@ int ObBackupInfoMgr::get_restore_info_from_cache(const uint64_t tenant_id, ObSim return ret; } -int ObBackupInfoMgr::get_restore_status_from_cache(const uint64_t tenant_id, PhysicalRestoreStatus& status) +int ObBackupInfoMgr::get_restore_status_from_cache(const uint64_t tenant_id, PhysicalRestoreStatus &status) { int ret = OB_ENTRY_NOT_EXIST; status = PHYSICAL_RESTORE_MAX_STATUS; @@ -429,7 +427,7 @@ int ObBackupInfoMgr::get_restore_status_from_cache(const uint64_t tenant_id, Phy SpinRLockGuard guard(lock_); if (is_restore_loaded_) { for (int64_t i = 0; i < cur_restore_job_->count(); ++i) { - ObPhysicalRestoreJob& cur_job = cur_restore_job_->at(i); + ObPhysicalRestoreJob &cur_job = cur_restore_job_->at(i); if (cur_job.tenant_id_ == tenant_id) { status = cur_job.status_; ret = OB_SUCCESS; @@ -442,13 +440,13 @@ int ObBackupInfoMgr::get_restore_status_from_cache(const uint64_t tenant_id, Phy return ret; } -int ObBackupInfoMgr::get_restore_info(const uint64_t tenant_id, ObPhysicalRestoreInfo& info) +int ObBackupInfoMgr::get_restore_info(const uint64_t tenant_id, ObPhysicalRestoreInfo &info) { return get_restore_info(false /*need_valid_restore_schema_version*/, tenant_id, info); } int ObBackupInfoMgr::get_restore_info( - const bool need_valid_restore_schema_version, const uint64_t tenant_id, ObPhysicalRestoreInfo& info) + const bool need_valid_restore_schema_version, const uint64_t tenant_id, ObPhysicalRestoreInfo &info) { int ret = OB_SUCCESS; ObSimplePhysicalRestoreJob simple_job_info; @@ -492,7 +490,7 @@ int ObBackupInfoMgr::get_restore_info( return ret; } -int ObBackupInfoMgr::get_restore_job_id(const uint64_t tenant_id, int64_t& job_id) +int ObBackupInfoMgr::get_restore_job_id(const uint64_t tenant_id, int64_t &job_id) { int ret = OB_SUCCESS; ObSimplePhysicalRestoreJob simple_job_info; @@ -520,7 +518,7 @@ int ObBackupInfoMgr::get_restore_job_id(const uint64_t tenant_id, int64_t& job_i } int ObBackupInfoMgr::get_restore_piece_list( - const uint64_t tenant_id, common::ObIArray& piece_list) + const uint64_t tenant_id, common::ObIArray &piece_list) { int ret = OB_SUCCESS; ObSimplePhysicalRestoreJob simple_job_info; @@ -550,7 +548,7 @@ int ObBackupInfoMgr::get_restore_piece_list( } int ObBackupInfoMgr::get_restore_set_list( - const uint64_t tenant_id, common::ObIArray& set_list) + const uint64_t tenant_id, common::ObIArray &set_list) { int ret = OB_SUCCESS; ObSimplePhysicalRestoreJob simple_job_info; @@ -579,7 +577,7 @@ int ObBackupInfoMgr::get_restore_set_list( return ret; } -int ObBackupInfoMgr::get_restore_status(const uint64_t tenant_id, PhysicalRestoreStatus& status) +int ObBackupInfoMgr::get_restore_status(const uint64_t tenant_id, PhysicalRestoreStatus &status) { int ret = OB_SUCCESS; bool found = false; @@ -606,7 +604,7 @@ int ObBackupInfoMgr::get_restore_status(const uint64_t tenant_id, PhysicalRestor return ret; } -int ObBackupInfoMgr::get_backup_snapshot_version(int64_t& backup_snapshot_version) +int ObBackupInfoMgr::get_backup_snapshot_version(int64_t &backup_snapshot_version) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr info_mgr; @@ -630,7 +628,7 @@ int ObBackupInfoMgr::get_backup_snapshot_version(int64_t& backup_snapshot_versio return ret; } -int ObBackupInfoMgr::get_log_archive_checkpoint(int64_t& snapshot_version) +int ObBackupInfoMgr::get_log_archive_checkpoint(int64_t &snapshot_version) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr info_mgr; @@ -654,7 +652,7 @@ int ObBackupInfoMgr::get_log_archive_checkpoint(int64_t& snapshot_version) } int ObBackupInfoMgr::get_delay_delete_schema_version(const uint64_t tenant_id, - share::schema::ObMultiVersionSchemaService& schema_service, bool& is_backup, int64_t& reserved_schema_version) + share::schema::ObMultiVersionSchemaService &schema_service, bool &is_backup, int64_t &reserved_schema_version) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr info_mgr; @@ -700,7 +698,7 @@ int ObBackupInfoMgr::get_delay_delete_schema_version(const uint64_t tenant_id, return ret; } -int ObBackupInfoMgr::check_if_doing_backup(bool& is_doing) +int ObBackupInfoMgr::check_if_doing_backup(bool &is_doing) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr info_mgr; @@ -734,7 +732,7 @@ int ObBackupInfoMgr::check_if_doing_backup(bool& is_doing) return ret; } -int ObBackupInfoMgr::check_if_doing_backup_backup(bool& is_doing) +int ObBackupInfoMgr::check_if_doing_backup_backup(bool &is_doing) { int ret = OB_SUCCESS; is_doing = false; @@ -796,10 +794,9 @@ int ObBackupInfoMgr::reload() const uint64_t tenant_id = OB_SYS_TENANT_ID; lib::ObMutexGuard mutex_guard(mutex_); - ObLogArchiveBackupInfo* new_backup_info = &backup_infos_[0]; - ObNonFrozenBackupPieceInfo* new_backup_piece = &backup_pieces_[0]; - RestoreJobArray* new_restore_job = &restore_jobs_[0]; - bool* new_is_backup_started = &is_base_backup_started_[0]; + ObLogArchiveBackupInfo *new_backup_info = &backup_infos_[0]; + ObNonFrozenBackupPieceInfo *new_backup_piece = &backup_pieces_[0]; + RestoreJobArray *new_restore_job = &restore_jobs_[0]; if (new_backup_info == cur_backup_info_) { new_backup_info = &backup_infos_[1]; @@ -812,10 +809,6 @@ int ObBackupInfoMgr::reload() new_restore_job = &restore_jobs_[1]; } - if (new_is_backup_started == is_base_backup_started_) { - new_is_backup_started = &is_base_backup_started_[1]; - } - // reload backup info if (!is_inited_) { ret = OB_NOT_INIT; @@ -826,8 +819,6 @@ int ObBackupInfoMgr::reload() LOG_WARN("failed to get log archive backup info and piece", K(ret)); } else if (OB_FAIL(info_manager.init(tenant_id, *sql_proxy_))) { LOG_WARN("failed to init info manager", K(ret)); - } else if (OB_FAIL(info_manager.is_backup_started(*new_is_backup_started))) { - LOG_WARN("failed to check is backup started", K(ret)); } else if (REACH_TIME_INTERVAL(OB_DEFAULT_BACKUP_LOG_INTERVAL) || new_backup_info->status_.status_ != cur_backup_info_->status_.status_ || new_backup_info->status_.round_ != cur_backup_info_->status_.round_ || @@ -839,7 +830,6 @@ int ObBackupInfoMgr::reload() SpinWLockGuard guard(lock_); cur_backup_info_ = new_backup_info; cur_backup_piece_ = new_backup_piece; - cur_base_backup_started_ = new_is_backup_started; is_backup_loaded_ = true; } @@ -868,8 +858,8 @@ int ObBackupInfoMgr::reload() return ret; } -int ObBackupInfoMgr::fetch_sys_log_archive_backup_info_and_piece(common::ObMySQLProxy& sql_proxy, - ObLogArchiveBackupInfo& new_backup_info, ObNonFrozenBackupPieceInfo& new_backup_piece) +int ObBackupInfoMgr::fetch_sys_log_archive_backup_info_and_piece(common::ObMySQLProxy &sql_proxy, + ObLogArchiveBackupInfo &new_backup_info, ObNonFrozenBackupPieceInfo &new_backup_piece) { int ret = OB_SUCCESS; ObLogArchiveBackupInfoMgr info_mgr; @@ -934,36 +924,7 @@ int64_t ObBackupInfoMgr::get_log_archive_checkpoint_interval() const return ATOMIC_LOAD(&log_archive_checkpoint_interval_); } -int ObBackupInfoMgr::is_base_backup_start(bool& is_started) -{ - int ret = OB_SUCCESS; - bool is_loaded = true; - is_started = false; - - if (!is_inited_) { - ret = OB_NOT_INIT; - LOG_WARN("not inited", K(ret)); - } else { - SpinRLockGuard guard(lock_); - is_loaded = is_backup_loaded_; - if (is_loaded) { - is_started = *cur_base_backup_started_; - } - } - - if (OB_SUCC(ret)) { - if (!is_loaded) { - if (REACH_TIME_INTERVAL(OB_DEFAULT_BACKUP_LOG_INTERVAL)) { - LOG_WARN("not loaded yet, try again", K(ret)); - } - } else if (REACH_TIME_INTERVAL(OB_DEFAULT_BACKUP_LOG_INTERVAL)) { - FLOG_INFO("is_base_backup_start", K(ret), K(is_started)); - } - } - return ret; -} - -int ObBackupInfoMgr::get_base_data_restore_schema_version(const uint64_t tenant_id, int64_t& schema_version) +int ObBackupInfoMgr::get_base_data_restore_schema_version(const uint64_t tenant_id, int64_t &schema_version) { int ret = OB_SUCCESS; ObSimplePhysicalRestoreJob simple_job_info; @@ -1002,14 +963,14 @@ ObRestoreBackupInfoUtil::GetRestoreBackupInfoParam::GetRestoreBackupInfoParam() {} int ObRestoreBackupInfoUtil::GetRestoreBackupInfoParam::get_largest_backup_set_path( - share::ObSimpleBackupSetPath& simple_path) const + share::ObSimpleBackupSetPath &simple_path) const { int ret = OB_SUCCESS; simple_path.reset(); int64_t idx = -1; int64_t largest_backup_set_id = -1; for (int64_t i = 0; OB_SUCC(ret) && i < backup_set_path_list_.count(); ++i) { - const share::ObSimpleBackupSetPath& path = backup_set_path_list_.at(i); + const share::ObSimpleBackupSetPath &path = backup_set_path_list_.at(i); if (path.backup_set_id_ > largest_backup_set_id) { largest_backup_set_id = path.backup_set_id_; idx = i; @@ -1028,7 +989,7 @@ int ObRestoreBackupInfoUtil::GetRestoreBackupInfoParam::get_largest_backup_set_p } int ObRestoreBackupInfoUtil::GetRestoreBackupInfoParam::get_smallest_backup_piece_path( - share::ObSimpleBackupPiecePath& simple_path) const + share::ObSimpleBackupPiecePath &simple_path) const { int ret = OB_SUCCESS; simple_path.reset(); @@ -1041,7 +1002,7 @@ int ObRestoreBackupInfoUtil::GetRestoreBackupInfoParam::get_smallest_backup_piec return ret; } -int ObRestoreBackupInfoUtil::get_restore_backup_info(const GetRestoreBackupInfoParam& param, ObRestoreBackupInfo& info) +int ObRestoreBackupInfoUtil::get_restore_backup_info(const GetRestoreBackupInfoParam ¶m, ObRestoreBackupInfo &info) { int ret = OB_SUCCESS; bool is_cluster_level = param.backup_set_path_list_.empty(); @@ -1058,7 +1019,7 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info(const GetRestoreBackupInfoP } int ObRestoreBackupInfoUtil::get_restore_backup_info_v1_( - const GetRestoreBackupInfoParam& param, ObRestoreBackupInfo& info) + const GetRestoreBackupInfoParam ¶m, ObRestoreBackupInfo &info) { int ret = OB_SUCCESS; ObClusterBackupDest dest; @@ -1075,13 +1036,13 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v1_( ObTenantNameSimpleMgr tenant_name_mgr; ObExternPGListMgr pg_list_mgr; uint64_t backup_tenant_id = 0; - const char* backup_dest = param.backup_dest_; - const char* backup_cluster_name = param.backup_cluster_name_; + const char *backup_dest = param.backup_dest_; + const char *backup_cluster_name = param.backup_cluster_name_; const int64_t cluster_id = param.cluster_id_; const int64_t incarnation = param.incarnation_; - const char* backup_tenant_name = param.backup_tenant_name_; + const char *backup_tenant_name = param.backup_tenant_name_; const int64_t restore_timestamp = param.restore_timestamp_; - const char* passwd_array = param.passwd_array_; + const char *passwd_array = param.passwd_array_; ObFakeBackupLeaseService fake_backup_lease; if (OB_ISNULL(backup_dest) || OB_ISNULL(backup_cluster_name) || cluster_id <= 0 || incarnation < 0 || @@ -1176,7 +1137,7 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v1_( } int ObRestoreBackupInfoUtil::get_restore_backup_info_v2_( - const GetRestoreBackupInfoParam& param, ObRestoreBackupInfo& info) + const GetRestoreBackupInfoParam ¶m, ObRestoreBackupInfo &info) { int ret = OB_SUCCESS; ObFakeBackupLeaseService fake_backup_lease; @@ -1187,12 +1148,12 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v2_( ObSimpleBackupSetPath simple_set_path; // largest backup set path ObSimpleBackupPiecePath simple_piece_path; // smallest backup piece path ObBackupPath piece_backup_path; - const char* backup_dest = param.backup_dest_; - const char* backup_cluster_name = param.backup_cluster_name_; + const char *backup_dest = param.backup_dest_; + const char *backup_cluster_name = param.backup_cluster_name_; const int64_t cluster_id = param.cluster_id_; const int64_t incarnation = param.incarnation_; const int64_t restore_timestamp = param.restore_timestamp_; - const char* passwd_array = param.passwd_array_; + const char *passwd_array = param.passwd_array_; const int64_t cluster_version = ObClusterVersion::get_instance().get_cluster_version(); ObExternLogArchiveBackupInfo log_archive_backup_info; @@ -1261,13 +1222,13 @@ int ObRestoreBackupInfoUtil::get_restore_backup_info_v2_( } int ObRestoreBackupInfoUtil::get_restore_sys_table_ids( - const ObPhysicalRestoreInfo& info, common::ObIArray& pkey_list) + const ObPhysicalRestoreInfo &info, common::ObIArray &pkey_list) { UNUSEDx(info, pkey_list); return OB_SUCCESS; } -ObRestoreFatalErrorReporter& ObRestoreFatalErrorReporter::get_instance() +ObRestoreFatalErrorReporter &ObRestoreFatalErrorReporter::get_instance() { static ObRestoreFatalErrorReporter reporter; return reporter; @@ -1284,7 +1245,7 @@ ObRestoreFatalErrorReporter::ObRestoreFatalErrorReporter() ObRestoreFatalErrorReporter::~ObRestoreFatalErrorReporter() {} -int ObRestoreFatalErrorReporter::init(obrpc::ObCommonRpcProxy& rpc_proxy, share::ObRsMgr& rs_mgr) +int ObRestoreFatalErrorReporter::init(obrpc::ObCommonRpcProxy &rpc_proxy, share::ObRsMgr &rs_mgr) { int ret = OB_SUCCESS; @@ -1299,8 +1260,8 @@ int ObRestoreFatalErrorReporter::init(obrpc::ObCommonRpcProxy& rpc_proxy, share: return ret; } -int ObRestoreFatalErrorReporter::add_restore_error_task(const uint64_t tenant_id, const PhysicalRestoreMod& mod, - const int32_t result, const int64_t job_id, const common::ObAddr& addr) +int ObRestoreFatalErrorReporter::add_restore_error_task(const uint64_t tenant_id, const PhysicalRestoreMod &mod, + const int32_t result, const int64_t job_id, const common::ObAddr &addr) { int ret = OB_SUCCESS; bool found = false; @@ -1400,7 +1361,7 @@ int ObRestoreFatalErrorReporter::report_restore_errors() if (OB_SUCC(ret) && report_results.count() > 0) { for (int64_t i = 0; !has_set_stop() && i < report_results.count(); ++i) { // ignore ret - obrpc::ObPhysicalRestoreResult& result = report_results.at(i); + obrpc::ObPhysicalRestoreResult &result = report_results.at(i); if (OB_SUCCESS != (tmp_ret = report_restore_error_(result))) { ret = OB_SUCC(ret) ? tmp_ret : ret; LOG_WARN("failed to report restore error", K(tmp_ret), K(ret), K(result)); @@ -1413,7 +1374,7 @@ int ObRestoreFatalErrorReporter::report_restore_errors() return ret; } -int ObRestoreFatalErrorReporter::remove_restore_error_task_(const obrpc::ObPhysicalRestoreResult& result) +int ObRestoreFatalErrorReporter::remove_restore_error_task_(const obrpc::ObPhysicalRestoreResult &result) { int ret = OB_SUCCESS; @@ -1436,7 +1397,7 @@ int ObRestoreFatalErrorReporter::remove_restore_error_task_(const obrpc::ObPhysi return ret; } -int ObRestoreFatalErrorReporter::report_restore_error_(const obrpc::ObPhysicalRestoreResult& result) +int ObRestoreFatalErrorReporter::report_restore_error_(const obrpc::ObPhysicalRestoreResult &result) { int ret = OB_SUCCESS; common::ObAddr rs_addr; @@ -1457,7 +1418,7 @@ int ObRestoreFatalErrorReporter::report_restore_error_(const obrpc::ObPhysicalRe return ret; } -ObBackupDestDetector& ObBackupDestDetector::get_instance() +ObBackupDestDetector &ObBackupDestDetector::get_instance() { static ObBackupDestDetector detector; return detector; @@ -1554,7 +1515,7 @@ void ObBackupDestDetector::wakeup() (void)cond_.broadcast(); // ignore ret } -int ObBackupDestDetector::get_is_backup_dest_bad(const int64_t round_id, bool& is_bad) +int ObBackupDestDetector::get_is_backup_dest_bad(const int64_t round_id, bool &is_bad) { int ret = OB_SUCCESS; is_bad = false; @@ -1590,7 +1551,7 @@ int ObBackupDestDetector::get_is_backup_dest_bad(const int64_t round_id, bool& i return ret; } -int ObBackupDestDetector::update_backup_info(const ObLogArchiveBackupInfo& info) +int ObBackupDestDetector::update_backup_info(const ObLogArchiveBackupInfo &info) { int ret = OB_SUCCESS; bool is_changed = false; @@ -1658,7 +1619,7 @@ int ObBackupDestDetector::check_backup_dest() return ret; } -int ObBackupDestDetector::check_backup_dest_(ObLogArchiveBackupInfo& backup_info, bool& is_bad) +int ObBackupDestDetector::check_backup_dest_(ObLogArchiveBackupInfo &backup_info, bool &is_bad) { int ret = OB_SUCCESS; bool need_check = false; diff --git a/src/share/backup/ob_backup_info_mgr.h b/src/share/backup/ob_backup_info_mgr.h index 22fe5dd1901e795b14db05d17e76be17317efa8b..d0839a6cc254829a20740697d44d61ede2acd1e5 100644 --- a/src/share/backup/ob_backup_info_mgr.h +++ b/src/share/backup/ob_backup_info_mgr.h @@ -48,23 +48,23 @@ struct ObLogArchiveSimpleInfo final { // 用于切主后确认pg的checkpoint ts,可能会触发内部表的访问。 class ObLogArchiveInfoMgr final { public: - static ObLogArchiveInfoMgr& get_instance(); + static ObLogArchiveInfoMgr &get_instance(); - int init(common::ObMySQLProxy& sql_proxy); - int get_log_archive_status(const uint64_t tenant_id, const int64_t need_ts, ObLogArchiveSimpleInfo& status); + int init(common::ObMySQLProxy &sql_proxy); + int get_log_archive_status(const uint64_t tenant_id, const int64_t need_ts, ObLogArchiveSimpleInfo &status); TO_STRING_KV(K_(update_count)); private: ObLogArchiveInfoMgr(); ~ObLogArchiveInfoMgr(); - int get_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo& status); + int get_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo &status); int try_retire_status_(); - int renew_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo& status); + int renew_log_archive_status_(const uint64_t tenant_id, ObLogArchiveSimpleInfo &status); private: typedef common::hash::ObHashMap STATUS_MAP; bool is_inited_; - common::ObMySQLProxy* sql_proxy_; + common::ObMySQLProxy *sql_proxy_; common::SpinRWLock lock_; lib::ObMutex mutex_; STATUS_MAP status_map_; @@ -75,41 +75,40 @@ private: class ObBackupInfoMgr final { public: typedef common::ObArray RestoreJobArray; - static ObBackupInfoMgr& get_instance(); + static ObBackupInfoMgr &get_instance(); - int init(common::ObMySQLProxy& sql_proxy, ObBackupDestDetector& backup_dest_detector); + int init(common::ObMySQLProxy &sql_proxy, ObBackupDestDetector &backup_dest_detector); int start(); void stop(); void wait(); void destroy(); - int get_log_archive_backup_info(ObLogArchiveBackupInfo& info); + int get_log_archive_backup_info(ObLogArchiveBackupInfo &info); int get_log_archive_backup_info_and_piece( - ObLogArchiveBackupInfo& new_backup_info, ObNonFrozenBackupPieceInfo& new_backup_piece); - int get_backup_snapshot_version(int64_t& snapshot_version); - int get_log_archive_checkpoint(int64_t& snapshot_version); + ObLogArchiveBackupInfo &new_backup_info, ObNonFrozenBackupPieceInfo &new_backup_piece); + int get_backup_snapshot_version(int64_t &snapshot_version); + int get_log_archive_checkpoint(int64_t &snapshot_version); int get_delay_delete_schema_version(const uint64_t tenant_id, - share::schema::ObMultiVersionSchemaService& schema_service, bool& is_backup, int64_t& reserved_schema_version); - int check_if_doing_backup(bool& is_doing); - int check_if_doing_backup_backup(bool& is_doing); - int get_restore_info(const uint64_t tenant_id, ObPhysicalRestoreInfo& info); + share::schema::ObMultiVersionSchemaService &schema_service, bool &is_backup, int64_t &reserved_schema_version); + int check_if_doing_backup(bool &is_doing); + int check_if_doing_backup_backup(bool &is_doing); + int get_restore_info(const uint64_t tenant_id, ObPhysicalRestoreInfo &info); int get_restore_info( - const bool need_valid_restore_schema_version, const uint64_t tenant_id, ObPhysicalRestoreInfo& info); - int get_restore_status(const uint64_t tenant_id, PhysicalRestoreStatus& status); - int get_restore_job_id(const uint64_t tenant_id, int64_t& job_id); - int get_restore_piece_list(const uint64_t tenant_id, common::ObIArray& piece_list); - int get_restore_set_list(const uint64_t tenant_id, common::ObIArray& set_list); + const bool need_valid_restore_schema_version, const uint64_t tenant_id, ObPhysicalRestoreInfo &info); + int get_restore_status(const uint64_t tenant_id, PhysicalRestoreStatus &status); + int get_restore_job_id(const uint64_t tenant_id, int64_t &job_id); + int get_restore_piece_list(const uint64_t tenant_id, common::ObIArray &piece_list); + int get_restore_set_list(const uint64_t tenant_id, common::ObIArray &set_list); int reload(); - int is_base_backup_start(bool& is_started); - int get_base_data_restore_schema_version(const uint64_t tenant_id, int64_t& schema_version); - static int fetch_sys_log_archive_backup_info_and_piece(common::ObMySQLProxy& sql_proxy, - ObLogArchiveBackupInfo& new_backup_info, ObNonFrozenBackupPieceInfo& new_backup_piece); + int get_base_data_restore_schema_version(const uint64_t tenant_id, int64_t &schema_version); + static int fetch_sys_log_archive_backup_info_and_piece(common::ObMySQLProxy &sql_proxy, + ObLogArchiveBackupInfo &new_backup_info, ObNonFrozenBackupPieceInfo &new_backup_piece); int64_t get_log_archive_checkpoint_interval() const; private: static const int64_t DEFAULT_UPDATE_INTERVAL_US = 10 * 1000 * 1000; // 10s - int get_restore_info_from_cache(const uint64_t tenant_id, ObSimplePhysicalRestoreJob& simple_job_info); - int get_restore_status_from_cache(const uint64_t tenant_id, PhysicalRestoreStatus& status); - int check_backup_dest_(ObLogArchiveBackupInfo& backup_info); + int get_restore_info_from_cache(const uint64_t tenant_id, ObSimplePhysicalRestoreJob &simple_job_info); + int get_restore_status_from_cache(const uint64_t tenant_id, PhysicalRestoreStatus &status); + int check_backup_dest_(ObLogArchiveBackupInfo &backup_info); int update_log_archive_checkpoint_interval_(); private: @@ -127,22 +126,20 @@ private: private: bool is_inited_; - common::ObMySQLProxy* sql_proxy_; + common::ObMySQLProxy *sql_proxy_; common::ObTimer timer_; ObBackupInfoUpdateTask update_task_; ObLogArchiveBackupInfo backup_infos_[2]; - ObLogArchiveBackupInfo* cur_backup_info_; + ObLogArchiveBackupInfo *cur_backup_info_; ObNonFrozenBackupPieceInfo backup_pieces_[2]; - ObNonFrozenBackupPieceInfo* cur_backup_piece_; + ObNonFrozenBackupPieceInfo *cur_backup_piece_; RestoreJobArray restore_jobs_[2]; - RestoreJobArray* cur_restore_job_; - bool is_base_backup_started_[2]; - bool* cur_base_backup_started_; + RestoreJobArray *cur_restore_job_; common::SpinRWLock lock_; lib::ObMutex mutex_; bool is_backup_loaded_; bool is_restore_loaded_; - ObBackupDestDetector* backup_dest_detector_; + ObBackupDestDetector *backup_dest_detector_; int64_t log_archive_checkpoint_interval_; DISALLOW_COPY_AND_ASSIGN(ObBackupInfoMgr); }; @@ -151,38 +148,38 @@ class ObRestoreBackupInfoUtil final { public: struct GetRestoreBackupInfoParam final { GetRestoreBackupInfoParam(); - const char* backup_dest_; - const char* backup_cluster_name_; + const char *backup_dest_; + const char *backup_cluster_name_; int64_t cluster_id_; int64_t incarnation_; - const char* backup_tenant_name_; + const char *backup_tenant_name_; int64_t restore_timestamp_; - const char* passwd_array_; + const char *passwd_array_; common::ObArray backup_set_path_list_; common::ObArray backup_piece_path_list_; - int get_largest_backup_set_path(share::ObSimpleBackupSetPath& simple_path) const; - int get_smallest_backup_piece_path(share::ObSimpleBackupPiecePath& simple_path) const; + int get_largest_backup_set_path(share::ObSimpleBackupSetPath &simple_path) const; + int get_smallest_backup_piece_path(share::ObSimpleBackupPiecePath &simple_path) const; }; - static int get_restore_backup_info(const GetRestoreBackupInfoParam& param, ObRestoreBackupInfo& info); + static int get_restore_backup_info(const GetRestoreBackupInfoParam ¶m, ObRestoreBackupInfo &info); static int get_restore_sys_table_ids( - const ObPhysicalRestoreInfo& info, common::ObIArray& pkey_list); + const ObPhysicalRestoreInfo &info, common::ObIArray &pkey_list); private: // get info from cluster backup dest level - static int get_restore_backup_info_v1_(const GetRestoreBackupInfoParam& param, ObRestoreBackupInfo& info); + static int get_restore_backup_info_v1_(const GetRestoreBackupInfoParam ¶m, ObRestoreBackupInfo &info); // get info from simple path level - static int get_restore_backup_info_v2_(const GetRestoreBackupInfoParam& param, ObRestoreBackupInfo& info); + static int get_restore_backup_info_v2_(const GetRestoreBackupInfoParam ¶m, ObRestoreBackupInfo &info); }; class ObRestoreFatalErrorReporter : public share::ObThreadPool { public: - static ObRestoreFatalErrorReporter& get_instance(); + static ObRestoreFatalErrorReporter &get_instance(); - int init(obrpc::ObCommonRpcProxy& rpc_proxy, share::ObRsMgr& rs_mgr); - int add_restore_error_task(const uint64_t tenant_id, const PhysicalRestoreMod& mod, const int32_t result, - const int64_t job_id, const common::ObAddr& addr); + int init(obrpc::ObCommonRpcProxy &rpc_proxy, share::ObRsMgr &rs_mgr); + int add_restore_error_task(const uint64_t tenant_id, const PhysicalRestoreMod &mod, const int32_t result, + const int64_t job_id, const common::ObAddr &addr); virtual int start() override; virtual void stop() override; virtual void wait() override; @@ -192,13 +189,13 @@ private: virtual ~ObRestoreFatalErrorReporter(); virtual void run1() override; int report_restore_errors(); - int report_restore_error_(const obrpc::ObPhysicalRestoreResult& result); - int remove_restore_error_task_(const obrpc::ObPhysicalRestoreResult& result); + int report_restore_error_(const obrpc::ObPhysicalRestoreResult &result); + int remove_restore_error_task_(const obrpc::ObPhysicalRestoreResult &result); private: bool is_inited_; - obrpc::ObCommonRpcProxy* rpc_proxy_; - share::ObRsMgr* rs_mgr_; + obrpc::ObCommonRpcProxy *rpc_proxy_; + share::ObRsMgr *rs_mgr_; lib::ObMutex mutex_; common::ObSEArray report_results_; // assume most time less than 16 restore task DISALLOW_COPY_AND_ASSIGN(ObRestoreFatalErrorReporter); @@ -206,21 +203,21 @@ private: class ObBackupDestDetector : public share::ObThreadPool { public: - static ObBackupDestDetector& get_instance(); + static ObBackupDestDetector &get_instance(); int init(); virtual int start() override; virtual void stop() override; virtual void wait() override; void wakeup(); - int get_is_backup_dest_bad(const int64_t round_id, bool& is_bad); - int update_backup_info(const ObLogArchiveBackupInfo& info); + int get_is_backup_dest_bad(const int64_t round_id, bool &is_bad); + int update_backup_info(const ObLogArchiveBackupInfo &info); private: ObBackupDestDetector(); virtual ~ObBackupDestDetector(); virtual void run1() override; int check_backup_dest(); - int check_backup_dest_(ObLogArchiveBackupInfo& backup_info, bool& is_bad); + int check_backup_dest_(ObLogArchiveBackupInfo &backup_info, bool &is_bad); void idle(); private: diff --git a/src/share/backup/ob_backup_struct.cpp b/src/share/backup/ob_backup_struct.cpp index d70f80506c623dd7fd7995b5711d47843142f51d..32fb5ea170d61e88a7e3d07590f48fff180b6d16 100644 --- a/src/share/backup/ob_backup_struct.cpp +++ b/src/share/backup/ob_backup_struct.cpp @@ -2020,7 +2020,8 @@ bool ObTenantBackupTaskItem::is_valid() const bool ObTenantBackupTaskItem::is_same_task(const ObTenantBackupTaskItem& other) const { - return tenant_id_ == other.tenant_id_ && backup_set_id_ == other.backup_set_id_ && incarnation_ == other.incarnation_; + return tenant_id_ == other.tenant_id_ && backup_set_id_ == other.backup_set_id_ && + incarnation_ == other.incarnation_ && copy_id_ == other.copy_id_; } bool ObTenantBackupTaskItem::is_result_succeed() const @@ -2067,6 +2068,21 @@ int ObTenantBackupTaskItem::set_backup_task_status(const char* buf) return ret; } +uint64_t ObTenantBackupTaskItem::hash() const +{ + uint64_t hash_val = 0; + hash_val = murmurhash(&tenant_id_, sizeof(tenant_id_), hash_val); + hash_val = murmurhash(&incarnation_, sizeof(incarnation_), hash_val); + hash_val = murmurhash(&backup_set_id_, sizeof(backup_set_id_), hash_val); + hash_val = murmurhash(©_id_, sizeof(copy_id_), hash_val); + return hash_val; +} + +bool ObTenantBackupTaskItem::operator==(const ObTenantBackupTaskItem &other) const +{ + return is_same_task(other); +} + ObPGBackupTaskItem::ObPGBackupTaskItem() : tenant_id_(OB_INVALID_ID), table_id_(OB_INVALID_ID), diff --git a/src/share/backup/ob_backup_struct.h b/src/share/backup/ob_backup_struct.h index 5867b52dd739ca1e0a0ea7ecdf8539b060495cef..99ee0a258f1fc412d7a199812a2d1652103cee9c 100644 --- a/src/share/backup/ob_backup_struct.h +++ b/src/share/backup/ob_backup_struct.h @@ -949,7 +949,9 @@ public: bool is_same_task(const ObTenantBackupTaskItem& other) const; bool is_result_succeed() const; const char* get_backup_task_status_str() const; - int set_backup_task_status(const char* buf); + int set_backup_task_status(const char *buf); + uint64_t hash() const; + bool operator==(const ObTenantBackupTaskItem &other) const; TO_STRING_KV(K_(tenant_id), K_(backup_set_id), K_(incarnation), K_(snapshot_version), K_(prev_full_backup_set_id), K_(prev_inc_backup_set_id), K_(prev_backup_data_version), K_(pg_count), K_(macro_block_count), diff --git a/src/share/backup/ob_log_archive_backup_info_mgr.cpp b/src/share/backup/ob_log_archive_backup_info_mgr.cpp index 95b861582323dd5572d698e4f564087706f92493..9a0bc6418120bf473371b5ea7d3ed0c29bea0ef8 100644 --- a/src/share/backup/ob_log_archive_backup_info_mgr.cpp +++ b/src/share/backup/ob_log_archive_backup_info_mgr.cpp @@ -1971,7 +1971,7 @@ int ObLogArchiveBackupInfoMgr::delete_log_archive_info( info.status_.tenant_id_, info.status_.round_))) { LOG_WARN("failed to assign sql", K(ret), K(info)); - } else if (is_backup_backup_ && OB_FAIL(sql.append(" and copy_id = %ld", info.status_.copy_id_))) { + } else if (is_backup_backup_ && OB_FAIL(sql.append_fmt(" and copy_id = %ld", info.status_.copy_id_))) { LOG_WARN("failed to apend copy id", K(ret), K(sql)); } else if (OB_FAIL(sql_client.write(OB_SYS_TENANT_ID, sql.ptr(), affected_rows))) { LOG_WARN("failed to write sql", K(ret), K(sql)); @@ -4052,3 +4052,39 @@ bool ObLogArchiveBackupInfoMgr::CompareBackupPieceInfo::operator()( return b_ret; } + +int ObLogArchiveBackupInfoMgr::get_tenant_backup_piece_infos_with_file_status( + common::ObISQLClient &sql_client, + const int64_t incarnation, + const uint64_t tenant_id, + const ObBackupFileStatus::STATUS &file_status, + const bool is_backup_backup, + common::ObIArray &piece_infos) +{ + int ret = OB_SUCCESS; + ObSqlString sql; + piece_infos.reset(); + + if (OB_INVALID_ID == tenant_id || incarnation <= 0 || !ObBackupFileStatus::is_valid(file_status)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid args", KR(ret), K(tenant_id), K(incarnation), K(file_status)); + } else if (OB_FAIL(sql.assign_fmt( + "SELECT * FROM %s WHERE incarnation = %ld AND tenant_id = %lu AND file_status = '%s'", + OB_ALL_BACKUP_PIECE_FILES_TNAME, incarnation, tenant_id, ObBackupFileStatus::get_str(file_status)))) { + LOG_WARN("failed to assign sql", KR(ret), K(incarnation), K(tenant_id)); + } else if (is_backup_backup) { + if (OB_FAIL(sql.append_fmt(" AND copy_id > 0"))) { + LOG_WARN("failed to apend sql", K(ret)); + } + } else { + if (OB_FAIL(sql.append_fmt(" AND copy_id = 0"))) { + LOG_WARN("failed to apend sql", K(ret)); + } + } + + if (OB_FAIL(ret)) { + } else if (OB_FAIL(get_backup_piece_list_(sql_client, sql, piece_infos))) { + LOG_WARN("failed to get backup piece list", KR(ret), K(sql)); + } + return ret; +} diff --git a/src/share/backup/ob_log_archive_backup_info_mgr.h b/src/share/backup/ob_log_archive_backup_info_mgr.h index 7fa131ff45109d392c629c31acbc8ae571008587..eb888c6e7984544765dda08edd25426e9b152251 100644 --- a/src/share/backup/ob_log_archive_backup_info_mgr.h +++ b/src/share/backup/ob_log_archive_backup_info_mgr.h @@ -35,15 +35,15 @@ public: void reset(); bool is_valid() const; int64_t get_write_buf_size() const; - int write_buf(char* buf, const int64_t buf_len, int64_t& pos) const; - int read_buf(const char* buf, const int64_t buf_len); - - int update(const ObTenantLogArchiveStatus& status); - int get_last(ObTenantLogArchiveStatus& status); - int get_log_archive_status(const int64_t restore_timestamp, ObTenantLogArchiveStatus& status); - int get_log_archive_status(common::ObIArray& status_array); - int mark_log_archive_deleted(const common::ObIArray& round_ids); - int delete_marked_log_archive_info(const common::ObIArray& round_ids); + int write_buf(char *buf, const int64_t buf_len, int64_t &pos) const; + int read_buf(const char *buf, const int64_t buf_len); + + int update(const ObTenantLogArchiveStatus &status); + int get_last(ObTenantLogArchiveStatus &status); + int get_log_archive_status(const int64_t restore_timestamp, ObTenantLogArchiveStatus &status); + int get_log_archive_status(common::ObIArray &status_array); + int mark_log_archive_deleted(const common::ObIArray &round_ids); + int delete_marked_log_archive_info(const common::ObIArray &round_ids); bool is_empty() const { return status_array_.empty(); @@ -70,13 +70,13 @@ public: void reset(); bool is_valid() const; int64_t get_write_buf_size() const; - int write_buf(char* buf, const int64_t buf_len, int64_t& pos) const; - int read_buf(const char* buf, const int64_t buf_len); + int write_buf(char *buf, const int64_t buf_len, int64_t &pos) const; + int read_buf(const char *buf, const int64_t buf_len); - int update(const share::ObBackupPieceInfo& piece); // update or insert - int get_piece_array(common::ObIArray& piece_array); - int mark_deleting(const common::ObIArray& piece_keys); - int mark_deleted(const common::ObIArray& piece_keys); + int update(const share::ObBackupPieceInfo &piece); // update or insert + int get_piece_array(common::ObIArray &piece_array); + int mark_deleting(const common::ObIArray &piece_keys); + int mark_deleted(const common::ObIArray &piece_keys); bool is_all_piece_info_deleted() const; TO_STRING_KV(K_(piece_array)); @@ -100,218 +100,221 @@ public: return OB_SUCCESS; } - int check_sys_log_archive_status(common::ObISQLClient& sql_client); - int get_log_archive_backup_info(common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, - const ObBackupInnerTableVersion& version, ObLogArchiveBackupInfo& info); + int check_sys_log_archive_status(common::ObISQLClient &sql_client); + int get_log_archive_backup_info(common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, + const ObBackupInnerTableVersion &version, ObLogArchiveBackupInfo &info); int get_log_archive_backup_info_compatible( - common::ObISQLClient& sql_client, const uint64_t tenant_id, ObLogArchiveBackupInfo& info); - int get_non_frozen_backup_piece(common::ObISQLClient& sql_client, const bool for_update, - const ObLogArchiveBackupInfo& info, ObNonFrozenBackupPieceInfo& non_frozen_piece); - int get_non_frozen_backup_piece(common::ObISQLClient& sql_client, const bool for_update, - const share::ObBackupPieceInfoKey& cur_key, share::ObNonFrozenBackupPieceInfo& piece); - int get_backup_piece(common::ObISQLClient& sql_client, const bool for_update, const share::ObBackupPieceInfoKey& key, - share::ObBackupPieceInfo& piece); + common::ObISQLClient &sql_client, const uint64_t tenant_id, ObLogArchiveBackupInfo &info); + int get_non_frozen_backup_piece(common::ObISQLClient &sql_client, const bool for_update, + const ObLogArchiveBackupInfo &info, ObNonFrozenBackupPieceInfo &non_frozen_piece); + int get_non_frozen_backup_piece(common::ObISQLClient &sql_client, const bool for_update, + const share::ObBackupPieceInfoKey &cur_key, share::ObNonFrozenBackupPieceInfo &piece); + int get_backup_piece(common::ObISQLClient &sql_client, const bool for_update, const share::ObBackupPieceInfoKey &key, + share::ObBackupPieceInfo &piece); int get_log_archive_backup_backup_info( - common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo& info); + common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo &info); int update_log_archive_backup_info( - common::ObISQLClient& sql_client, const ObBackupInnerTableVersion& version, const ObLogArchiveBackupInfo& info); - int update_backup_piece(ObMySQLTransaction& trans, const ObNonFrozenBackupPieceInfo& non_frozen_piece); - int update_backup_piece(common::ObISQLClient& sql_client, const share::ObBackupPieceInfo& piece); - int get_log_archive_checkpoint(common::ObISQLClient& sql_client, const uint64_t tenant_id, int64_t& checkpoint_ts); - int get_create_tenant_timestamp(common::ObISQLClient& sql_client, const uint64_t tenant_id, int64_t& create_ts); - - int update_log_archive_status_history(common::ObISQLClient& sql_proxy, const ObLogArchiveBackupInfo& info, - const int64_t inner_table_version, share::ObIBackupLeaseService& backup_lease_service); - int delete_tenant_log_archive_status_v2(common::ObISQLClient& sql_proxy, const uint64_t tenant_id); - int delete_tenant_log_archive_status_v1(common::ObISQLClient& sql_proxy, const uint64_t tenant_id); - int get_all_active_log_archive_tenants(common::ObISQLClient& sql_proxy, common::ObIArray& tenant_ids); + common::ObISQLClient &sql_client, const ObBackupInnerTableVersion &version, const ObLogArchiveBackupInfo &info); + int update_backup_piece(ObMySQLTransaction &trans, const ObNonFrozenBackupPieceInfo &non_frozen_piece); + int update_backup_piece(common::ObISQLClient &sql_client, const share::ObBackupPieceInfo &piece); + int get_log_archive_checkpoint(common::ObISQLClient &sql_client, const uint64_t tenant_id, int64_t &checkpoint_ts); + int get_create_tenant_timestamp(common::ObISQLClient &sql_client, const uint64_t tenant_id, int64_t &create_ts); + + int update_log_archive_status_history(common::ObISQLClient &sql_proxy, const ObLogArchiveBackupInfo &info, + const int64_t inner_table_version, share::ObIBackupLeaseService &backup_lease_service); + int delete_tenant_log_archive_status_v2(common::ObISQLClient &sql_proxy, const uint64_t tenant_id); + int delete_tenant_log_archive_status_v1(common::ObISQLClient &sql_proxy, const uint64_t tenant_id); + int get_all_active_log_archive_tenants(common::ObISQLClient &sql_proxy, common::ObIArray &tenant_ids); int get_last_extern_log_archive_backup_info( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, ObTenantLogArchiveStatus& last_status); + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, ObTenantLogArchiveStatus &last_status); int update_extern_log_archive_backup_info( - const ObLogArchiveBackupInfo& info, share::ObIBackupLeaseService& backup_lease_service); + const ObLogArchiveBackupInfo &info, share::ObIBackupLeaseService &backup_lease_service); int update_external_backup_piece( - const share::ObNonFrozenBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service); - int update_external_backup_piece(const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service); - int update_external_backup_backup_piece(const share::ObClusterBackupDest& cluster_backup_dest, - const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service); + const share::ObNonFrozenBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service); + int update_external_backup_piece(const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service); + int update_external_backup_backup_piece(const share::ObClusterBackupDest &cluster_backup_dest, + const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service); int update_external_single_backup_piece_info( - const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service); - int read_external_single_backup_piece_info(const ObBackupPath& path, const ObString& storage_info, - ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service); + const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service); + int read_external_single_backup_piece_info(const ObBackupPath &path, const ObString &storage_info, + ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service); int read_extern_log_archive_backup_info( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, ObExternLogArchiveBackupInfo& info); + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, ObExternLogArchiveBackupInfo &info); - int get_log_archive_history_info(common::ObISQLClient& sql_client, const uint64_t tenant_id, + int get_log_archive_history_info(common::ObISQLClient &sql_client, const uint64_t tenant_id, const int64_t archive_round, const int64_t copy_id, const bool for_update, - ObLogArchiveBackupInfo& archive_backup_info); - int get_log_archive_history_infos(common::ObISQLClient& sql_client, const uint64_t tenant_id, const bool for_update, - common::ObIArray& infos); + ObLogArchiveBackupInfo &archive_backup_info); + int get_log_archive_history_infos(common::ObISQLClient &sql_client, const uint64_t tenant_id, const bool for_update, + common::ObIArray &infos); int get_all_log_archive_history_infos( - common::ObISQLClient& sql_client, common::ObIArray& infos); - int get_same_round_log_archive_history_infos(common::ObISQLClient& sql_client, const int64_t round, - const bool for_update, common::ObIArray& infos); - int mark_log_archive_history_info_deleted(const ObLogArchiveBackupInfo& info, common::ObISQLClient& sql_client); - int delete_log_archive_info(const ObLogArchiveBackupInfo& info, common::ObISQLClient& sql_client); - int delete_all_backup_backup_log_archive_info(common::ObISQLClient& sql_client); - int delete_backup_backup_log_archive_info(const uint64_t tenant_id, common::ObISQLClient& sql_client); - - int mark_extern_log_archive_backup_info_deleted(const ObClusterBackupDest& cluster_backup_dest, - const uint64_t tenant_id, const common::ObIArray& round_ids, - share::ObIBackupLeaseService& backup_lease_service); - int delete_marked_extern_log_archive_backup_info(const ObClusterBackupDest& current_backup_dest, - const uint64_t tenant_id, const common::ObIArray& round_ids, bool& is_empty, - share::ObIBackupLeaseService& backup_lease_service); + common::ObISQLClient &sql_client, common::ObIArray &infos); + int get_same_round_log_archive_history_infos(common::ObISQLClient &sql_client, const int64_t round, + const bool for_update, common::ObIArray &infos); + int mark_log_archive_history_info_deleted(const ObLogArchiveBackupInfo &info, common::ObISQLClient &sql_client); + int delete_log_archive_info(const ObLogArchiveBackupInfo &info, common::ObISQLClient &sql_client); + int delete_all_backup_backup_log_archive_info(common::ObISQLClient &sql_client); + int delete_backup_backup_log_archive_info(const uint64_t tenant_id, common::ObISQLClient &sql_client); + + int mark_extern_log_archive_backup_info_deleted(const ObClusterBackupDest &cluster_backup_dest, + const uint64_t tenant_id, const common::ObIArray &round_ids, + share::ObIBackupLeaseService &backup_lease_service); + int delete_marked_extern_log_archive_backup_info(const ObClusterBackupDest ¤t_backup_dest, + const uint64_t tenant_id, const common::ObIArray &round_ids, bool &is_empty, + share::ObIBackupLeaseService &backup_lease_service); // for backup backup int get_all_backup_backup_log_archive_status( - common::ObISQLClient& sql_client, const bool for_update, common::ObIArray& infos); - int get_backup_backup_log_archive_round_list(common::ObISQLClient& sql_client, const int64_t log_archive_round, - const bool for_update, common::ObIArray& infos); - int get_all_same_round_in_progress_backup_info(common::ObISQLClient& sql_client, const int64_t round, - common::ObIArray& info_list); - int get_all_same_round_log_archive_infos(common::ObISQLClient& sql_client, const uint64_t tenant_id, - const int64_t round, common::ObIArray& info_list); - int get_backup_piece_list(common::ObISQLClient& sql_client, const uint64_t tenant_id, const int64_t copy_id, - common::ObIArray& info_list); - int check_has_round_mode_archive_in_dest(common::ObISQLClient& sql_client, const share::ObBackupDest& backup_dest, - const uint64_t tenant_id, bool& has_round_mode); - int check_has_piece_mode_archive_in_dest(common::ObISQLClient& sql_client, const share::ObBackupDest& backup_dest, - const uint64_t tenant_id, bool& has_piece_mode); - int get_backup_piece_tenant_list(common::ObISQLClient& sql_client, const int64_t backup_piece_id, - const int64_t copy_id, common::ObIArray& info_list); + common::ObISQLClient &sql_client, const bool for_update, common::ObIArray &infos); + int get_backup_backup_log_archive_round_list(common::ObISQLClient &sql_client, const int64_t log_archive_round, + const bool for_update, common::ObIArray &infos); + int get_all_same_round_in_progress_backup_info(common::ObISQLClient &sql_client, const int64_t round, + common::ObIArray &info_list); + int get_all_same_round_log_archive_infos(common::ObISQLClient &sql_client, const uint64_t tenant_id, + const int64_t round, common::ObIArray &info_list); + int get_backup_piece_list(common::ObISQLClient &sql_client, const uint64_t tenant_id, const int64_t copy_id, + common::ObIArray &info_list); + int check_has_round_mode_archive_in_dest(common::ObISQLClient &sql_client, const share::ObBackupDest &backup_dest, + const uint64_t tenant_id, bool &has_round_mode); + int check_has_piece_mode_archive_in_dest(common::ObISQLClient &sql_client, const share::ObBackupDest &backup_dest, + const uint64_t tenant_id, bool &has_piece_mode); + int get_backup_piece_tenant_list(common::ObISQLClient &sql_client, const int64_t backup_piece_id, + const int64_t copy_id, common::ObIArray &info_list); int get_backup_piece_copy_list(const int64_t incarnation, const uint64_t tenant_id, const int64_t round_id, - const int64_t piece_id, const ObBackupBackupCopyIdLevel copy_id_level, common::ObISQLClient& sql_client, - common::ObIArray& info_list); + const int64_t piece_id, const ObBackupBackupCopyIdLevel copy_id_level, common::ObISQLClient &sql_client, + common::ObIArray &info_list); int get_all_cluster_level_backup_piece_copy_count(const int64_t incarnation, const uint64_t tenant_id, - const int64_t round_id, const int64_t piece_id, common::ObISQLClient& sql_client, int64_t& copy_count); - int get_max_backup_piece(common::ObISQLClient& sql_client, const int64_t incarnation, const uint64_t tenant_id, - const int64_t copy_id, share::ObBackupPieceInfo& piece); - int get_max_frozen_backup_piece(common::ObISQLClient& sql_client, const int64_t incarnation, const uint64_t tenant_id, - const int64_t copy_id, share::ObBackupPieceInfo& piece); - int get_last_piece_in_round(common::ObISQLClient& sql_client, const int64_t incarnation, const uint64_t tenant_id, - const int64_t round_id, share::ObBackupPieceInfo& piece); - int get_external_backup_piece_info(const share::ObBackupPath& path, const common::ObString& storage_info, - share::ObExternalBackupPieceInfo& info, share::ObIBackupLeaseService& backup_lease_service); - int sync_backup_backup_piece_info(const uint64_t tenant_id, const ObClusterBackupDest& src_backup_dest, - const ObClusterBackupDest& dst_backup_dest, share::ObIBackupLeaseService& backup_lease_service); + const int64_t round_id, const int64_t piece_id, common::ObISQLClient &sql_client, int64_t ©_count); + int get_max_backup_piece(common::ObISQLClient &sql_client, const int64_t incarnation, const uint64_t tenant_id, + const int64_t copy_id, share::ObBackupPieceInfo &piece); + int get_max_frozen_backup_piece(common::ObISQLClient &sql_client, const int64_t incarnation, const uint64_t tenant_id, + const int64_t copy_id, share::ObBackupPieceInfo &piece); + int get_last_piece_in_round(common::ObISQLClient &sql_client, const int64_t incarnation, const uint64_t tenant_id, + const int64_t round_id, share::ObBackupPieceInfo &piece); + int get_external_backup_piece_info(const share::ObBackupPath &path, const common::ObString &storage_info, + share::ObExternalBackupPieceInfo &info, share::ObIBackupLeaseService &backup_lease_service); + int sync_backup_backup_piece_info(const uint64_t tenant_id, const ObClusterBackupDest &src_backup_dest, + const ObClusterBackupDest &dst_backup_dest, share::ObIBackupLeaseService &backup_lease_service); // for backup data clean - int get_round_backup_piece_infos(common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, + int get_round_backup_piece_infos(common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, const int64_t incarnation, const int64_t log_archive_round, const bool is_backup_backup, - common::ObIArray& piece_infos); - int get_backup_log_archive_history_infos(common::ObISQLClient& sql_client, const uint64_t tenant_id, - const bool for_update, common::ObIArray& infos); - int get_backup_log_archive_info_from_original_piece_infos(common::ObISQLClient& sql_client, const uint64_t tenant_id, - const bool for_update, common::ObIArray& infos); - int get_backup_log_archive_info_from_piece_info(common::ObISQLClient& sql_client, const uint64_t tenant_id, - const int64_t piece_id, const int64_t copy_id, const bool for_update, ObLogArchiveBackupInfo& info); - - int get_original_backup_log_piece_infos(common::ObISQLClient& sql_client, const bool for_update, - const uint64_t tenant_id, common::ObIArray& piece_infos); - int get_backup_piece(common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, - const int64_t backup_piece_id, const int64_t copy_id, ObBackupPieceInfo& piece_info); - int get_tenant_ids_with_piece_id(common::ObISQLClient& sql_client, const int64_t backup_piece_id, - const int64_t copy_id, common::ObIArray& tenant_ids); - int get_tenant_ids_with_round_id(common::ObISQLClient& sql_client, const bool for_update, - const int64_t backup_round_id, const int64_t copy_id, common::ObIArray& tenant_ids); - int get_backup_tenant_ids_with_snapshot(common::ObISQLClient& sql_client, const int64_t snapshot_version, - const bool is_backup_backup, common::ObIArray& tenant_ids); - int mark_extern_backup_piece_deleting(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const common::ObIArray& piece_keys, const bool is_backup_backup, - share::ObIBackupLeaseService& backup_lease_service); - int mark_extern_backup_piece_deleted(const ObClusterBackupDest& current_backup_dest, const uint64_t tenant_id, - const common::ObIArray& piece_keys, const bool is_backup_backup, - bool& is_all_deleted, share::ObIBackupLeaseService& backup_lease_service); + common::ObIArray &piece_infos); + int get_backup_log_archive_history_infos(common::ObISQLClient &sql_client, const uint64_t tenant_id, + const bool for_update, common::ObIArray &infos); + int get_backup_log_archive_info_from_original_piece_infos(common::ObISQLClient &sql_client, const uint64_t tenant_id, + const bool for_update, common::ObIArray &infos); + int get_backup_log_archive_info_from_piece_info(common::ObISQLClient &sql_client, const uint64_t tenant_id, + const int64_t piece_id, const int64_t copy_id, const bool for_update, ObLogArchiveBackupInfo &info); + + int get_original_backup_log_piece_infos(common::ObISQLClient &sql_client, const bool for_update, + const uint64_t tenant_id, common::ObIArray &piece_infos); + int get_backup_piece(common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, + const int64_t backup_piece_id, const int64_t copy_id, ObBackupPieceInfo &piece_info); + int get_tenant_ids_with_piece_id(common::ObISQLClient &sql_client, const int64_t backup_piece_id, + const int64_t copy_id, common::ObIArray &tenant_ids); + int get_tenant_ids_with_round_id(common::ObISQLClient &sql_client, const bool for_update, + const int64_t backup_round_id, const int64_t copy_id, common::ObIArray &tenant_ids); + int get_backup_tenant_ids_with_snapshot(common::ObISQLClient &sql_client, const int64_t snapshot_version, + const bool is_backup_backup, common::ObIArray &tenant_ids); + int mark_extern_backup_piece_deleting(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const common::ObIArray &piece_keys, const bool is_backup_backup, + share::ObIBackupLeaseService &backup_lease_service); + int mark_extern_backup_piece_deleted(const ObClusterBackupDest ¤t_backup_dest, const uint64_t tenant_id, + const common::ObIArray &piece_keys, const bool is_backup_backup, + bool &is_all_deleted, share::ObIBackupLeaseService &backup_lease_service); int get_extern_backup_info_path( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath& path); - int get_external_backup_piece_path(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const bool is_backup_backup, share::ObBackupPath& path); - int delete_extern_backup_info_file(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id); + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath &path); + int get_external_backup_piece_path(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const bool is_backup_backup, share::ObBackupPath &path); + int delete_extern_backup_info_file(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id); int update_extern_backup_info_file_timestamp( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id); - int delete_extern_backup_piece_file(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service); + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id); + int delete_extern_backup_piece_file(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service); int update_extern_backup_piece_file_timestamp( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, const bool is_backup_backup); - int get_tenant_backup_piece_infos(common::ObISQLClient& sql_client, const int64_t incarnation, + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, const bool is_backup_backup); + int get_tenant_backup_piece_infos(common::ObISQLClient &sql_client, const int64_t incarnation, const uint64_t tenant_id, const int64_t round_id, const int64_t piece_id, - common::ObIArray& piece_infos); + common::ObIArray &piece_infos); int get_max_backup_piece_id_in_backup_dest(const share::ObBackupBackupCopyIdLevel copy_id_level, - const share::ObBackupDest& backup_dest, const uint64_t tenant_id, common::ObISQLClient& sql_client, - int64_t& piece_id); - int get_min_available_backup_piece_id_in_backup_dest(const share::ObBackupDest& backup_dest, - const int64_t incarnation, const uint64_t tenant_id, const int64_t copy_id, common::ObISQLClient& sql_client, - int64_t& piece_id); + const share::ObBackupDest &backup_dest, const uint64_t tenant_id, common::ObISQLClient &sql_client, + int64_t &piece_id); + int get_min_available_backup_piece_id_in_backup_dest(const share::ObBackupDest &backup_dest, + const int64_t incarnation, const uint64_t tenant_id, const int64_t copy_id, common::ObISQLClient &sql_client, + int64_t &piece_id); int check_has_incomplete_file_info_smaller_than_backup_piece_id(const int64_t incarnation, const uint64_t tenant_id, - const int64_t backup_piece_id, const share::ObBackupDest& backup_dest, common::ObISQLClient& sql_client, - bool& has_incomplet_before); + const int64_t backup_piece_id, const share::ObBackupDest &backup_dest, common::ObISQLClient &sql_client, + bool &has_incomplet_before); + int get_tenant_backup_piece_infos_with_file_status(common::ObISQLClient &sql_client, const int64_t incarnation, + const uint64_t tenant_id, const ObBackupFileStatus::STATUS &file_status, const bool is_backup_backup, + common::ObIArray &piece_infos); private: - int parse_backup_backup_log_archive_status_(sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info); - int parse_his_backup_backup_log_archive_status_(sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info); + int parse_backup_backup_log_archive_status_(sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info); + int parse_his_backup_backup_log_archive_status_(sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info); int get_log_archive_backup_info_with_lock_( - common::ObISQLClient& sql_client, const uint64_t tenant_id, ObLogArchiveBackupInfo& info); + common::ObISQLClient &sql_client, const uint64_t tenant_id, ObLogArchiveBackupInfo &info); int get_log_archive_status_( - common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo& info); - int parse_log_archive_status_result_(common::sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info); - int parse_log_archive_status_(common::sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info); - int get_non_frozen_backup_piece_(common::ObISQLClient& sql_client, const bool for_update, - const share::ObBackupPieceInfoKey& cur_key, ObNonFrozenBackupPieceInfo& non_frozen_piece); - int get_backup_piece_list_(common::ObISQLClient& proxy, const common::ObSqlString& sql, - common::ObIArray& piece_list); - int parse_backup_piece_(sqlclient::ObMySQLResult& result, ObBackupPieceInfo& info); - int update_log_archive_backup_info_(common::ObISQLClient& sql_client, const ObLogArchiveBackupInfo& info); - int update_log_archive_status_(common::ObISQLClient& sql_client, const ObLogArchiveBackupInfo& info); + common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo &info); + int parse_log_archive_status_result_(common::sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info); + int parse_log_archive_status_(common::sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info); + int get_non_frozen_backup_piece_(common::ObISQLClient &sql_client, const bool for_update, + const share::ObBackupPieceInfoKey &cur_key, ObNonFrozenBackupPieceInfo &non_frozen_piece); + int get_backup_piece_list_(common::ObISQLClient &proxy, const common::ObSqlString &sql, + common::ObIArray &piece_list); + int parse_backup_piece_(sqlclient::ObMySQLResult &result, ObBackupPieceInfo &info); + int update_log_archive_backup_info_(common::ObISQLClient &sql_client, const ObLogArchiveBackupInfo &info); + int update_log_archive_status_(common::ObISQLClient &sql_client, const ObLogArchiveBackupInfo &info); int get_extern_backup_info_path_( - const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath& path); + const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, share::ObBackupPath &path); int inner_get_log_archvie_history_infos( - sqlclient::ObMySQLResult& result, common::ObIArray& infos); - int parse_log_archvie_history_status_(common::sqlclient::ObMySQLResult& result, ObLogArchiveBackupInfo& info); + sqlclient::ObMySQLResult &result, common::ObIArray &infos); + int parse_log_archvie_history_status_(common::sqlclient::ObMySQLResult &result, ObLogArchiveBackupInfo &info); - int write_extern_log_archive_backup_info(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const ObExternLogArchiveBackupInfo& info, share::ObIBackupLeaseService& backup_lease_service); + int write_extern_log_archive_backup_info(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const ObExternLogArchiveBackupInfo &info, share::ObIBackupLeaseService &backup_lease_service); int inner_read_extern_log_archive_backup_info( - const ObBackupPath& path, const char* storage_info, ObExternLogArchiveBackupInfo& info); - const char* get_cur_table_name_() const; - const char* get_his_table_name_() const; + const ObBackupPath &path, const char *storage_info, ObExternLogArchiveBackupInfo &info); + const char *get_cur_table_name_() const; + const char *get_his_table_name_() const; // 备份备份的任务都记录在系统租户的表中 uint64_t get_real_tenant_id(const uint64_t tenant_id) const; int update_external_backup_piece_( - const share::ObBackupPieceInfo& piece, bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service); - int update_external_backup_piece_(const share::ObNonFrozenBackupPieceInfo& piece, bool is_backup_backup, - share::ObIBackupLeaseService& backup_lease_service); - int update_external_backup_piece_(const share::ObClusterBackupDest& cluster_backup_dest, - const share::ObBackupPieceInfo piece, bool is_backup_backup, share::ObIBackupLeaseService& backup_lease_service); - int update_external_backup_piece_(const share::ObClusterBackupDest& cluster_backup_dest, - const share::ObNonFrozenBackupPieceInfo& piece, bool is_backup_backup, - share::ObIBackupLeaseService& backup_lease_service); - int inner_read_external_backup_piece_info_(const ObBackupPath& path, const char* storage_info, - share::ObExternalBackupPieceInfo& info, share::ObIBackupLeaseService& backup_lease_service); - int inner_write_extern_log_archive_backup_piece_info_(const ObBackupPath& path, const char* storage_info, - const share::ObExternalBackupPieceInfo& info, share::ObIBackupLeaseService& backup_lease_service); - int get_external_backup_piece_path_(const ObClusterBackupDest& cluster_backup_dest, const uint64_t tenant_id, - const bool is_backup_backup, share::ObBackupPath& path); + const share::ObBackupPieceInfo &piece, bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service); + int update_external_backup_piece_(const share::ObNonFrozenBackupPieceInfo &piece, bool is_backup_backup, + share::ObIBackupLeaseService &backup_lease_service); + int update_external_backup_piece_(const share::ObClusterBackupDest &cluster_backup_dest, + const share::ObBackupPieceInfo piece, bool is_backup_backup, share::ObIBackupLeaseService &backup_lease_service); + int update_external_backup_piece_(const share::ObClusterBackupDest &cluster_backup_dest, + const share::ObNonFrozenBackupPieceInfo &piece, bool is_backup_backup, + share::ObIBackupLeaseService &backup_lease_service); + int inner_read_external_backup_piece_info_(const ObBackupPath &path, const char *storage_info, + share::ObExternalBackupPieceInfo &info, share::ObIBackupLeaseService &backup_lease_service); + int inner_write_extern_log_archive_backup_piece_info_(const ObBackupPath &path, const char *storage_info, + const share::ObExternalBackupPieceInfo &info, share::ObIBackupLeaseService &backup_lease_service); + int get_external_backup_piece_path_(const ObClusterBackupDest &cluster_backup_dest, const uint64_t tenant_id, + const bool is_backup_backup, share::ObBackupPath &path); int write_external_single_backup_piece_info_( - const ObBackupPieceInfo& piece, share::ObIBackupLeaseService& backup_lease_service); + const ObBackupPieceInfo &piece, share::ObIBackupLeaseService &backup_lease_service); int trans_log_archive_info_from_piece_info_( - const ObBackupPieceInfo& piece_info, ObLogArchiveBackupInfo& log_archive_info); + const ObBackupPieceInfo &piece_info, ObLogArchiveBackupInfo &log_archive_info); int get_log_archive_backup_info_v1_( - common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo& info); + common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo &info); int get_log_archive_backup_info_v2_( - common::ObISQLClient& sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo& info); + common::ObISQLClient &sql_client, const bool for_update, const uint64_t tenant_id, ObLogArchiveBackupInfo &info); - int update_log_archive_backup_info_v1_(common::ObISQLClient& sql_client, const ObLogArchiveBackupInfo& info); - int update_log_archive_backup_info_v2_(common::ObISQLClient& sql_client, const ObLogArchiveBackupInfo& info); + int update_log_archive_backup_info_v1_(common::ObISQLClient &sql_client, const ObLogArchiveBackupInfo &info); + int update_log_archive_backup_info_v2_(common::ObISQLClient &sql_client, const ObLogArchiveBackupInfo &info); private: struct CompareBackupPieceInfo { - explicit CompareBackupPieceInfo(int32_t& result) : result_(result) + explicit CompareBackupPieceInfo(int32_t &result) : result_(result) {} - bool operator()(const share::ObBackupPieceInfo& lhs, const share::ObBackupPieceInfo& rhs); - int32_t& result_; + bool operator()(const share::ObBackupPieceInfo &lhs, const share::ObBackupPieceInfo &rhs); + int32_t &result_; }; private: diff --git a/src/share/backup/ob_tenant_backup_clean_info_updater.cpp b/src/share/backup/ob_tenant_backup_clean_info_updater.cpp index 35f06847deb332b560abbaf97366ae32ab9cbe12..ea0342e83e08da388d5759992eecc9b73dcbfb6f 100644 --- a/src/share/backup/ob_tenant_backup_clean_info_updater.cpp +++ b/src/share/backup/ob_tenant_backup_clean_info_updater.cpp @@ -20,7 +20,7 @@ using namespace share; ObTenantBackupCleanInfoUpdater::ObTenantBackupCleanInfoUpdater() : is_inited_(false), sql_proxy_(NULL) {} -int ObTenantBackupCleanInfoUpdater::init(common::ObISQLClient& sql_proxy) +int ObTenantBackupCleanInfoUpdater::init(common::ObISQLClient &sql_proxy) { int ret = OB_SUCCESS; if (is_inited_) { @@ -34,7 +34,7 @@ int ObTenantBackupCleanInfoUpdater::init(common::ObISQLClient& sql_proxy) } int ObTenantBackupCleanInfoUpdater::insert_backup_clean_info( - const uint64_t tenant_id, const ObBackupCleanInfo& clean_info) + const uint64_t tenant_id, const ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; @@ -52,7 +52,7 @@ int ObTenantBackupCleanInfoUpdater::insert_backup_clean_info( } int ObTenantBackupCleanInfoUpdater::get_backup_clean_info( - const uint64_t tenant_id, const bool for_update, ObBackupCleanInfo& clean_info) + const uint64_t tenant_id, const bool for_update, ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -71,7 +71,7 @@ int ObTenantBackupCleanInfoUpdater::get_backup_clean_info( } int ObTenantBackupCleanInfoUpdater::update_backup_clean_info( - const uint64_t tenant_id, const ObBackupCleanInfo& src_clean_info, const ObBackupCleanInfo& dest_clean_info) + const uint64_t tenant_id, const ObBackupCleanInfo &src_clean_info, const ObBackupCleanInfo &dest_clean_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -92,7 +92,7 @@ int ObTenantBackupCleanInfoUpdater::update_backup_clean_info( return ret; } -int ObTenantBackupCleanInfoUpdater::remove_clean_info(const uint64_t tenant_id, const ObBackupCleanInfo& clean_info) +int ObTenantBackupCleanInfoUpdater::remove_clean_info(const uint64_t tenant_id, const ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -108,7 +108,7 @@ int ObTenantBackupCleanInfoUpdater::remove_clean_info(const uint64_t tenant_id, } int ObTenantBackupCleanInfoUpdater::check_can_update_backup_clean_info( - const ObBackupCleanInfoStatus::STATUS& src_status, const ObBackupCleanInfoStatus::STATUS& dest_status) + const ObBackupCleanInfoStatus::STATUS &src_status, const ObBackupCleanInfoStatus::STATUS &dest_status) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -156,7 +156,7 @@ int ObTenantBackupCleanInfoUpdater::check_can_update_backup_clean_info( } int ObTenantBackupCleanInfoUpdater::get_backup_clean_info_status( - const uint64_t tenant_id, ObISQLClient& trans, ObBackupCleanInfoStatus::STATUS& status) + const uint64_t tenant_id, ObISQLClient &trans, ObBackupCleanInfoStatus::STATUS &status) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -169,7 +169,7 @@ int ObTenantBackupCleanInfoUpdater::get_backup_clean_info_status( } int ObTenantBackupCleanInfoUpdater::get_deleted_tenant_clean_infos( - common::ObIArray& deleted_tenant_clean_infos) + common::ObIArray &deleted_tenant_clean_infos) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -182,7 +182,7 @@ int ObTenantBackupCleanInfoUpdater::get_deleted_tenant_clean_infos( return ret; } -int ObTenantBackupCleanInfoUpdater::check_clean_task_is_dong(bool& is_doing) +int ObTenantBackupCleanInfoUpdater::check_clean_task_is_dong(bool &is_doing) { int ret = OB_SUCCESS; is_doing = false; @@ -207,7 +207,7 @@ int ObTenantBackupCleanInfoUpdater::check_clean_task_is_dong(bool& is_doing) ObBackupCleanInfoHistoryUpdater::ObBackupCleanInfoHistoryUpdater() : is_inited_(false), sql_proxy_(NULL) {} -int ObBackupCleanInfoHistoryUpdater::init(common::ObISQLClient& sql_proxy) +int ObBackupCleanInfoHistoryUpdater::init(common::ObISQLClient &sql_proxy) { int ret = OB_SUCCESS; if (is_inited_) { @@ -220,7 +220,7 @@ int ObBackupCleanInfoHistoryUpdater::init(common::ObISQLClient& sql_proxy) return ret; } -int ObBackupCleanInfoHistoryUpdater::insert_backup_clean_info(const ObBackupCleanInfo& clean_info) +int ObBackupCleanInfoHistoryUpdater::insert_backup_clean_info(const ObBackupCleanInfo &clean_info) { int ret = OB_SUCCESS; if (!is_inited_) { diff --git a/src/share/config/ob_config.cpp b/src/share/config/ob_config.cpp index 8a2593808e6b3ed77063366980c470573867d090..dcf60ecbcb9fc0b3a2bc5b6e58d4a284677dacbf 100644 --- a/src/share/config/ob_config.cpp +++ b/src/share/config/ob_config.cpp @@ -19,25 +19,25 @@ using namespace oceanbase::share; namespace oceanbase { namespace common { -const char* log_archive_config_keywords[] = { +const char *log_archive_config_keywords[] = { "MANDATORY", "OPTIONAL", "COMPRESSION", }; -const char* log_archive_compression_values[] = { +const char *log_archive_compression_values[] = { "disable", "enable", "lz4_1.0", "zstd_1.3.8", }; -const char* log_archive_encryption_mode_values[] = { +const char *log_archive_encryption_mode_values[] = { "None", "Transparent Encryption", }; -const char* log_archive_encryption_algorithm_values[] = { +const char *log_archive_encryption_algorithm_values[] = { "None", "", }; @@ -66,7 +66,7 @@ ObConfigItem::~ObConfigItem() } void ObConfigItem::init( - Scope::ScopeInfo scope_info, const char* name, const char* def, const char* info, const ObParameterAttr attr) + Scope::ScopeInfo scope_info, const char *name, const char *def, const char *info, const ObParameterAttr attr) { if (OB_ISNULL(name) || OB_ISNULL(def) || OB_ISNULL(info)) { OB_LOG(ERROR, "name or def or info is null", K(name), K(def), K(info)); @@ -84,8 +84,8 @@ void ObConfigItem::init( } // ObConfigIntListItem -ObConfigIntListItem::ObConfigIntListItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigIntListItem::ObConfigIntListItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) : value_() { if (OB_LIKELY(NULL != container)) { @@ -94,12 +94,12 @@ ObConfigIntListItem::ObConfigIntListItem(ObConfigContainer* container, Scope::Sc init(scope_info, name, def, info, attr); } -bool ObConfigIntListItem::set(const char* str) +bool ObConfigIntListItem::set(const char *str) { UNUSED(str); - char* saveptr = NULL; - char* s = NULL; - char* endptr = NULL; + char *saveptr = NULL; + char *s = NULL; + char *endptr = NULL; value_.valid_ = true; while (value_.size_--) { @@ -129,8 +129,8 @@ bool ObConfigIntListItem::set(const char* str) ObConfigStrListItem::ObConfigStrListItem() : value_() {} -ObConfigStrListItem::ObConfigStrListItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigStrListItem::ObConfigStrListItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) : value_() { if (OB_LIKELY(NULL != container)) { @@ -139,11 +139,11 @@ ObConfigStrListItem::ObConfigStrListItem(ObConfigContainer* container, Scope::Sc init(scope_info, name, def, info, attr); } -int ObConfigStrListItem::tryget(const int64_t idx, char* buf, const int64_t buf_len) const +int ObConfigStrListItem::tryget(const int64_t idx, char *buf, const int64_t buf_len) const { int ret = OB_SUCCESS; - const struct ObInnerConfigStrListItem* inner_value = &value_; - ObLatch& latch = const_cast(inner_value->rwlock_); + const struct ObInnerConfigStrListItem *inner_value = &value_; + ObLatch &latch = const_cast(inner_value->rwlock_); if (OB_ISNULL(buf) || OB_UNLIKELY(idx < 0) || OB_UNLIKELY(idx >= MAX_INDEX_SIZE) || OB_UNLIKELY(buf_len <= 0)) { ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "input argument is invalid", K(buf), K(idx), K(buf_len), K(ret)); @@ -155,7 +155,7 @@ int ObConfigStrListItem::tryget(const int64_t idx, char* buf, const int64_t buf_ } else { // tryrdlock succ int print_size = 0; int32_t min_len = 0; - const char* segment_str = NULL; + const char *segment_str = NULL; if (idx >= inner_value->size_) { ret = OB_ARRAY_OUT_OF_RANGE; } else { @@ -183,10 +183,10 @@ int ObConfigStrListItem::tryget(const int64_t idx, char* buf, const int64_t buf_ return ret; } -int ObConfigStrListItem::get(const int64_t idx, char* buf, const int64_t buf_len) const +int ObConfigStrListItem::get(const int64_t idx, char *buf, const int64_t buf_len) const { int ret = OB_SUCCESS; - const struct ObInnerConfigStrListItem* inner_value = &value_; + const struct ObInnerConfigStrListItem *inner_value = &value_; if (OB_ISNULL(buf) || idx < 0 || idx >= MAX_INDEX_SIZE || buf_len <= 0) { ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "input argument is invalid", K(buf), K(idx), K(buf_len), K(ret)); @@ -196,8 +196,8 @@ int ObConfigStrListItem::get(const int64_t idx, char* buf, const int64_t buf_len } else { int print_size = 0; int32_t min_len = 0; - const char* segment_str = NULL; - ObLatch& latch = const_cast(inner_value->rwlock_); + const char *segment_str = NULL; + ObLatch &latch = const_cast(inner_value->rwlock_); ObLatchRGuard rd_guard(latch, ObLatchIds::CONFIG_LOCK); if (idx >= inner_value->size_) { ret = OB_ARRAY_OUT_OF_RANGE; @@ -225,7 +225,7 @@ int ObConfigStrListItem::get(const int64_t idx, char* buf, const int64_t buf_len return ret; } -bool ObConfigStrListItem::set(const char* str) +bool ObConfigStrListItem::set(const char *str) { bool bret = true; UNUSED(str); @@ -274,8 +274,8 @@ bool ObConfigStrListItem::set(const char* str) } // ObConfigIntegralItem -void ObConfigIntegralItem::init(Scope::ScopeInfo scope_info, const char* name, const char* def, const char* range, - const char* info, const ObParameterAttr attr) +void ObConfigIntegralItem::init(Scope::ScopeInfo scope_info, const char *name, const char *def, const char *range, + const char *info, const ObParameterAttr attr) { ObConfigItem::init(scope_info, name, def, info, attr); if (OB_ISNULL(range)) { @@ -285,12 +285,12 @@ void ObConfigIntegralItem::init(Scope::ScopeInfo scope_info, const char* name, c } } -bool ObConfigIntegralItem::parse_range(const char* range) +bool ObConfigIntegralItem::parse_range(const char *range) { char buff[64] = {'\0'}; - const char* p_left = NULL; - char* p_middle = NULL; - char* p_right = NULL; + const char *p_left = NULL; + char *p_middle = NULL; + char *p_right = NULL; bool bool_ret = true; int ret = OB_SUCCESS; int64_t pos = 0; @@ -351,8 +351,8 @@ bool ObConfigIntegralItem::parse_range(const char* range) } // ObConfigDoubleItem -ObConfigDoubleItem::ObConfigDoubleItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* range, const char* info, const ObParameterAttr attr) +ObConfigDoubleItem::ObConfigDoubleItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *range, const char *info, const ObParameterAttr attr) : value_(0) { if (OB_LIKELY(NULL != container)) { @@ -361,8 +361,8 @@ ObConfigDoubleItem::ObConfigDoubleItem(ObConfigContainer* container, Scope::Scop init(scope_info, name, def, range, info, attr); } -ObConfigDoubleItem::ObConfigDoubleItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigDoubleItem::ObConfigDoubleItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) : value_(0) { if (OB_LIKELY(NULL != container)) { @@ -371,8 +371,8 @@ ObConfigDoubleItem::ObConfigDoubleItem(ObConfigContainer* container, Scope::Scop init(scope_info, name, def, "", info, attr); } -void ObConfigDoubleItem::init(Scope::ScopeInfo scope_info, const char* name, const char* def, const char* range, - const char* info, const ObParameterAttr attr) +void ObConfigDoubleItem::init(Scope::ScopeInfo scope_info, const char *name, const char *def, const char *range, + const char *info, const ObParameterAttr attr) { ObConfigItem::init(scope_info, name, def, info, attr); if (OB_ISNULL(range)) { @@ -382,13 +382,13 @@ void ObConfigDoubleItem::init(Scope::ScopeInfo scope_info, const char* name, con } } -double ObConfigDoubleItem::parse(const char* str, bool& valid) const +double ObConfigDoubleItem::parse(const char *str, bool &valid) const { double v = 0.0; if (OB_ISNULL(str) || OB_UNLIKELY('\0' == str[0])) { valid = false; } else { - char* endptr = NULL; + char *endptr = NULL; v = strtod(str, &endptr); if (OB_ISNULL(endptr) || OB_UNLIKELY('\0' != *endptr)) { valid = false; @@ -399,12 +399,12 @@ double ObConfigDoubleItem::parse(const char* str, bool& valid) const return v; } -bool ObConfigDoubleItem::parse_range(const char* range) +bool ObConfigDoubleItem::parse_range(const char *range) { char buff[64] = {'\0'}; - const char* p_left = NULL; - char* p_middle = NULL; - char* p_right = NULL; + const char *p_left = NULL; + char *p_middle = NULL; + char *p_right = NULL; bool bool_ret = true; int ret = OB_SUCCESS; int64_t pos = 0; @@ -460,8 +460,8 @@ bool ObConfigDoubleItem::parse_range(const char* range) } // ObConfigCapacityItem -ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* range, const char* info, const ObParameterAttr attr) +ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *range, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -469,8 +469,8 @@ ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer* container, Scope:: init(scope_info, name, def, range, info, attr); } -ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -478,7 +478,7 @@ ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer* container, Scope:: init(scope_info, name, def, "", info, attr); } -int64_t ObConfigCapacityItem::parse(const char* str, bool& valid) const +int64_t ObConfigCapacityItem::parse(const char *str, bool &valid) const { int64_t ret = ObConfigCapacityParser::get(str, valid); if (!valid) { @@ -488,8 +488,8 @@ int64_t ObConfigCapacityItem::parse(const char* str, bool& valid) const } // ObConfigTimeItem -ObConfigTimeItem::ObConfigTimeItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* range, const char* info, const ObParameterAttr attr) +ObConfigTimeItem::ObConfigTimeItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *range, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -497,8 +497,8 @@ ObConfigTimeItem::ObConfigTimeItem(ObConfigContainer* container, Scope::ScopeInf init(scope_info, name, def, range, info, attr); } -ObConfigTimeItem::ObConfigTimeItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigTimeItem::ObConfigTimeItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -506,7 +506,7 @@ ObConfigTimeItem::ObConfigTimeItem(ObConfigContainer* container, Scope::ScopeInf init(scope_info, name, def, "", info, attr); } -int64_t ObConfigTimeItem::parse(const char* str, bool& valid) const +int64_t ObConfigTimeItem::parse(const char *str, bool &valid) const { int64_t value = ObConfigTimeParser::get(str, valid); if (!valid) { @@ -516,8 +516,8 @@ int64_t ObConfigTimeItem::parse(const char* str, bool& valid) const } // ObConfigIntItem -ObConfigIntItem::ObConfigIntItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* range, const char* info, const ObParameterAttr attr) +ObConfigIntItem::ObConfigIntItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *range, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -525,8 +525,8 @@ ObConfigIntItem::ObConfigIntItem(ObConfigContainer* container, Scope::ScopeInfo init(scope_info, name, def, range, info, attr); } -ObConfigIntItem::ObConfigIntItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigIntItem::ObConfigIntItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -534,7 +534,7 @@ ObConfigIntItem::ObConfigIntItem(ObConfigContainer* container, Scope::ScopeInfo init(scope_info, name, def, "", info, attr); } -int64_t ObConfigIntItem::parse(const char* str, bool& valid) const +int64_t ObConfigIntItem::parse(const char *str, bool &valid) const { int64_t value = ObConfigIntParser::get(str, valid); if (!valid) { @@ -544,8 +544,8 @@ int64_t ObConfigIntItem::parse(const char* str, bool& valid) const } // ObConfigMomentItem -ObConfigMomentItem::ObConfigMomentItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigMomentItem::ObConfigMomentItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) : value_() { if (OB_LIKELY(NULL != container)) { @@ -554,7 +554,7 @@ ObConfigMomentItem::ObConfigMomentItem(ObConfigContainer* container, Scope::Scop init(scope_info, name, def, info, attr); } -bool ObConfigMomentItem::set(const char* str) +bool ObConfigMomentItem::set(const char *str) { int ret = true; struct tm tm_value; @@ -573,8 +573,8 @@ bool ObConfigMomentItem::set(const char* str) } // ObConfigBoolItem -ObConfigBoolItem::ObConfigBoolItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigBoolItem::ObConfigBoolItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) : value_(false) { if (OB_LIKELY(NULL != container)) { @@ -583,7 +583,7 @@ ObConfigBoolItem::ObConfigBoolItem(ObConfigContainer* container, Scope::ScopeInf init(scope_info, name, def, info, attr); } -bool ObConfigBoolItem::set(const char* str) +bool ObConfigBoolItem::set(const char *str) { bool valid = false; const bool value = parse(str, valid); @@ -595,7 +595,7 @@ bool ObConfigBoolItem::set(const char* str) return valid; } -bool ObConfigBoolItem::parse(const char* str, bool& valid) const +bool ObConfigBoolItem::parse(const char *str, bool &valid) const { bool value = true; if (OB_ISNULL(str)) { @@ -611,8 +611,8 @@ bool ObConfigBoolItem::parse(const char* str, bool& valid) const } // ObConfigStringItem -ObConfigStringItem::ObConfigStringItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, const char* name, - const char* def, const char* info, const ObParameterAttr attr) +ObConfigStringItem::ObConfigStringItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, const char *name, + const char *def, const char *info, const ObParameterAttr attr) { if (OB_LIKELY(NULL != container)) { container->set_refactored(ObConfigStringKey(name), this, 1); @@ -620,10 +620,10 @@ ObConfigStringItem::ObConfigStringItem(ObConfigContainer* container, Scope::Scop init(scope_info, name, def, info, attr); } -int ObConfigStringItem::copy(char* buf, const int64_t buf_len) +int ObConfigStringItem::copy(char *buf, const int64_t buf_len) { int ret = OB_SUCCESS; - const char* inner_value = value_str_; + const char *inner_value = value_str_; if (OB_FAIL(databuff_printf(buf, buf_len, "%s", inner_value))) { OB_LOG(WARN, "buffer not enough", K(ret), K(buf_len), K_(value_str)); @@ -631,8 +631,8 @@ int ObConfigStringItem::copy(char* buf, const int64_t buf_len) return ret; } -ObConfigLogArchiveOptionsItem::ObConfigLogArchiveOptionsItem(ObConfigContainer* container, Scope::ScopeInfo scope_info, - const char* name, const char* def, const char* info, const ObParameterAttr attr) +ObConfigLogArchiveOptionsItem::ObConfigLogArchiveOptionsItem(ObConfigContainer *container, Scope::ScopeInfo scope_info, + const char *name, const char *def, const char *info, const ObParameterAttr attr) : value_() { if (OB_LIKELY(NULL != container)) { @@ -641,7 +641,7 @@ ObConfigLogArchiveOptionsItem::ObConfigLogArchiveOptionsItem(ObConfigContainer* init(scope_info, name, def, info, attr); } -bool ObConfigLogArchiveOptionsItem::set(const char* str) +bool ObConfigLogArchiveOptionsItem::set(const char *str) { UNUSED(str); value_.valid_ = true; @@ -659,8 +659,8 @@ bool ObConfigLogArchiveOptionsItem::set(const char* str) value_.valid_ = false; OB_LOG(WARN, "failed to format_option_str", KR(ret), K(tmp_str)); } else { - char* saveptr = NULL; - char* s = STRTOK_R(format_str_buf, " ", &saveptr); + char *saveptr = NULL; + char *s = STRTOK_R(format_str_buf, " ", &saveptr); bool is_equal_sign_demanded = false; int64_t key_idx = -1; if (OB_LIKELY(NULL != s)) { @@ -713,7 +713,7 @@ bool ObConfigLogArchiveOptionsItem::set(const char* str) return value_.valid_; } -int64_t ObConfigLogArchiveOptionsItem::get_keywords_idx(const char* str, bool& is_key) +int64_t ObConfigLogArchiveOptionsItem::get_keywords_idx(const char *str, bool &is_key) { int64_t idx = -1; is_key = false; @@ -726,7 +726,7 @@ int64_t ObConfigLogArchiveOptionsItem::get_keywords_idx(const char* str, bool& i return idx; } -int64_t ObConfigLogArchiveOptionsItem::get_compression_option_idx(const char* str) +int64_t ObConfigLogArchiveOptionsItem::get_compression_option_idx(const char *str) { int64_t idx = -1; for (int i = 0; i < ARRAYSIZEOF(log_archive_compression_values) && idx < 0; ++i) { @@ -769,7 +769,7 @@ void ObConfigLogArchiveOptionsItem::process_isolated_option_(const int64_t idx) } } -void ObConfigLogArchiveOptionsItem::process_kv_option_(const int64_t key_idx, const char* value) +void ObConfigLogArchiveOptionsItem::process_kv_option_(const int64_t key_idx, const char *value) { static bool compression_state_map[] = { false, @@ -841,7 +841,7 @@ bool ObConfigLogArchiveOptionsItem::ObInnerConfigLogArchiveOptionsItem::is_encry return is_valid; } -int ObConfigLogArchiveOptionsItem::format_option_str(const char* src, int64_t src_len, char* dest, int64_t dest_len) +int ObConfigLogArchiveOptionsItem::format_option_str(const char *src, int64_t src_len, char *dest, int64_t dest_len) { int ret = OB_SUCCESS; @@ -849,8 +849,8 @@ int ObConfigLogArchiveOptionsItem::format_option_str(const char* src, int64_t sr ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "invalid arguments", KR(ret), KP(src), KP(dest), K(src_len), K(dest_len)); } else { - const char* source_str = src; - const char* locate_str = NULL; + const char *source_str = src; + const char *locate_str = NULL; int64_t source_left_len = src_len; int32_t locate = -1; int64_t pos = 0; diff --git a/src/share/ob_debug_sync_point.h b/src/share/ob_debug_sync_point.h index 1f2a35a04e419f99b3e28abbbdba40a0f0152b2b..76078b9532f7275bcfbe482d3fa4851dd61d11b6 100644 --- a/src/share/ob_debug_sync_point.h +++ b/src/share/ob_debug_sync_point.h @@ -210,7 +210,7 @@ class ObString; ACT(BEFORE_PHYSICAL_RESTORE_REBUILD_INDEX, ) \ ACT(BEFORE_PHYSICAL_RESTORE_POST_CHECK, ) \ ACT(BACKUP_BEFROE_CHOOSE_SRC, ) \ - ACT(BACKUP_BEFROE_BUILD_TABLE_PARTITION_INFO,) \ + ACT(BACKUP_BEFROE_BUILD_TABLE_PARTITION_INFO, ) \ ACT(HANG_UPDATE_RS_LIST, ) \ ACT(PARTITION_BACKUP_TASK_BEFORE_ADD_TASK_IN_MGR, ) \ ACT(HANG_BEFORE_RESOLVER_FINISH, ) \ @@ -274,7 +274,7 @@ class ObString; ACT(BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG, ) \ ACT(SLOW_TXN_DURING_2PC_COMMIT_PHASE_FOR_PHYSICAL_BACKUP_1055, ) \ ACT(BEFORE_FORCE_DROP_SCHEMA, ) \ - ACT(BLOCK_CLOG_PRIMARY_RECONFIRM,) \ + ACT(BLOCK_CLOG_PRIMARY_RECONFIRM, ) \ ACT(BEFORE_DEAL_WITH_FAILED_BACKUP_BACKUPSET_TASK, ) \ ACT(BEFORE_START_BACKUP_ARCHIVELOG_TASK, ) \ ACT(SYNC_REPORT, ) \ @@ -290,6 +290,7 @@ class ObString; ACT(BEFORE_BACKUP_BACKUPPIECE_TASK_COMMIT, ) \ ACT(BEFORE_CHECK_BACKUP_TASK_DATA_AVAILABLE, ) \ ACT(BACKUP_BACKUPPIECE_AFTER_SCHEDULE, ) \ + ACT(FOLLOWER_BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG, ) \ ACT(MAX_DEBUG_SYNC_POINT, ) DECLARE_ENUM(ObDebugSyncPoint, debug_sync_point, OB_DEBUG_SYNC_POINT_DEF); diff --git a/src/storage/ob_freeze_info_snapshot_mgr.cpp b/src/storage/ob_freeze_info_snapshot_mgr.cpp index c1bf8fc3e73f9b1784f6f0f24db4b987dc27448c..c4772d8f40a6a6abfce33ecce9aac138ae725575 100644 --- a/src/storage/ob_freeze_info_snapshot_mgr.cpp +++ b/src/storage/ob_freeze_info_snapshot_mgr.cpp @@ -48,8 +48,6 @@ ObFreezeInfoSnapshotMgr::ObFreezeInfoSnapshotMgr() schema_cache_(schema_query_set_), info_list_(), snapshots_(), - backup_snapshot_version_(0), - delay_delete_snapshot_version_(0), cur_idx_(0), lock_() {} @@ -57,7 +55,7 @@ ObFreezeInfoSnapshotMgr::ObFreezeInfoSnapshotMgr() ObFreezeInfoSnapshotMgr::~ObFreezeInfoSnapshotMgr() {} -int ObFreezeInfoSnapshotMgr::init(ObISQLClient& sql_proxy, bool is_remote) +int ObFreezeInfoSnapshotMgr::init(ObISQLClient &sql_proxy, bool is_remote) { int ret = OB_SUCCESS; if (OB_UNLIKELY(inited_)) { @@ -124,7 +122,7 @@ int64_t ObFreezeInfoSnapshotMgr::get_latest_frozen_timestamp() { int64_t frozen_timestamp = 0; RLockGuard lock_guard(lock_); - ObIArray& info_list = info_list_[cur_idx_]; + ObIArray &info_list = info_list_[cur_idx_]; if (0 != info_list.count()) { frozen_timestamp = info_list.at(info_list.count() - 1).freeze_ts; @@ -132,7 +130,7 @@ int64_t ObFreezeInfoSnapshotMgr::get_latest_frozen_timestamp() return frozen_timestamp; } -int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version(const int64_t major_version, FreezeInfoLite& freeze_info) +int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version(const int64_t major_version, FreezeInfoLite &freeze_info) { int ret = OB_SUCCESS; bool unused = false; @@ -142,7 +140,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version(const int64_t majo } int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version( - const int64_t major_version, FreezeInfoLite& freeze_info, bool& is_first_major_version) + const int64_t major_version, FreezeInfoLite &freeze_info, bool &is_first_major_version) { int ret = OB_SUCCESS; is_first_major_version = false; @@ -152,12 +150,12 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version( } int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version_( - const int64_t major_version, FreezeInfoLite& freeze_info, bool& is_first_major_version) + const int64_t major_version, FreezeInfoLite &freeze_info, bool &is_first_major_version) { int ret = OB_SUCCESS; is_first_major_version = false; - ObIArray& info_list = info_list_[cur_idx_]; + ObIArray &info_list = info_list_[cur_idx_]; if (OB_UNLIKELY(!inited_)) { ret = OB_NOT_INIT; @@ -169,7 +167,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version_( while (l < r && !found) { int64_t mid = (l + r) >> 1; - FreezeInfoLite& tmp_info = info_list.at(mid); + FreezeInfoLite &tmp_info = info_list.at(mid); if (major_version < tmp_info.freeze_version) { r = mid; } else if (major_version > tmp_info.freeze_version) { @@ -192,7 +190,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version_( } int ObFreezeInfoSnapshotMgr::get_freeze_info_behind_major_version( - const int64_t major_version, ObIArray& freeze_infos) + const int64_t major_version, ObIArray &freeze_infos) { int ret = OB_SUCCESS; RLockGuard lock_guard(lock_); @@ -204,7 +202,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_behind_major_version( ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "Invalid argument to get freeze info", K(ret), K(major_version)); } else { - ObIArray& info_list = info_list_[cur_idx_]; + ObIArray &info_list = info_list_[cur_idx_]; bool found = false; int64_t mid = 0; int64_t l = 0; @@ -212,7 +210,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_behind_major_version( while (l < r && !found) { mid = (l + r) >> 1; - FreezeInfoLite& tmp_info = info_list.at(mid); + FreezeInfoLite &tmp_info = info_list.at(mid); if (major_version < tmp_info.freeze_version) { r = mid; } else if (major_version > tmp_info.freeze_version) { @@ -236,7 +234,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_behind_major_version( } int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version( - const uint64_t table_id, const int64_t major_version, FreezeInfo& freeze_info) + const uint64_t table_id, const int64_t major_version, FreezeInfo &freeze_info) { uint64_t tenant_id = get_tenant_id(table_id); bool async = is_schema_cache_related_table(table_id); @@ -244,13 +242,13 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_major_version( } int ObFreezeInfoSnapshotMgr::get_tenant_freeze_info_by_major_version( - const uint64_t tenant_id, const int64_t major_version, FreezeInfo& freeze_info) + const uint64_t tenant_id, const int64_t major_version, FreezeInfo &freeze_info) { return get_tenant_freeze_info_by_major_version_(tenant_id, major_version, true, freeze_info); } int ObFreezeInfoSnapshotMgr::get_tenant_freeze_info_by_major_version_( - const uint64_t tenant_id, const int64_t major_version, const bool async, FreezeInfo& freeze_info) + const uint64_t tenant_id, const int64_t major_version, const bool async, FreezeInfo &freeze_info) { int ret = OB_SUCCESS; @@ -272,12 +270,12 @@ int ObFreezeInfoSnapshotMgr::get_tenant_freeze_info_by_major_version_( } int ObFreezeInfoSnapshotMgr::get_freeze_info_by_snapshot_version( - const int64_t snapshot_version, FreezeInfoLite& freeze_info) + const int64_t snapshot_version, FreezeInfoLite &freeze_info) { int ret = OB_SUCCESS; RLockGuard lock_guard(lock_); - ObIArray& info_list = info_list_[cur_idx_]; + ObIArray &info_list = info_list_[cur_idx_]; if (snapshot_version <= 0 || INT64_MAX == snapshot_version) { ret = OB_INVALID_ARGUMENT; @@ -291,7 +289,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_snapshot_version( } else { bool found = false; for (int64_t i = 0; OB_SUCC(ret) && !found && i < info_list.count(); ++i) { - FreezeInfoLite& tmp_info = info_list.at(i); + FreezeInfoLite &tmp_info = info_list.at(i); if (snapshot_version == tmp_info.freeze_ts) { freeze_info = tmp_info; found = true; @@ -310,7 +308,7 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_snapshot_version( } int ObFreezeInfoSnapshotMgr::get_freeze_info_by_snapshot_version( - const uint64_t table_id, const int64_t snapshot_version, FreezeInfo& freeze_info) + const uint64_t table_id, const int64_t snapshot_version, FreezeInfo &freeze_info) { int ret = OB_SUCCESS; @@ -334,13 +332,13 @@ int ObFreezeInfoSnapshotMgr::get_freeze_info_by_snapshot_version( } int ObFreezeInfoSnapshotMgr::inner_get_neighbour_major_freeze( - const int64_t snapshot_version, NeighbourFreezeInfoLite& info) + const int64_t snapshot_version, NeighbourFreezeInfoLite &info) { int ret = OB_SUCCESS; info.reset(); - ObIArray& info_list = info_list_[cur_idx_]; + ObIArray &info_list = info_list_[cur_idx_]; if (OB_UNLIKELY(!inited_)) { ret = OB_NOT_INIT; @@ -351,13 +349,13 @@ int ObFreezeInfoSnapshotMgr::inner_get_neighbour_major_freeze( } else { bool found = false; for (int64_t i = 0; i < info_list.count() && OB_SUCC(ret) && !found; ++i) { - FreezeInfoLite& next_info = info_list.at(i); + FreezeInfoLite &next_info = info_list.at(i); if (snapshot_version < next_info.freeze_ts) { found = true; if (0 == i) { ret = OB_ENTRY_NOT_EXIST; - STORAGE_LOG(WARN, "cannot get neighbour major freeze before bootstrap", - K(ret), K(snapshot_version), K(next_info)); + STORAGE_LOG( + WARN, "cannot get neighbour major freeze before bootstrap", K(ret), K(snapshot_version), K(next_info)); } else { info.next = next_info; info.prev = info_list.at(i - 1); @@ -375,14 +373,14 @@ int ObFreezeInfoSnapshotMgr::inner_get_neighbour_major_freeze( return ret; } -int ObFreezeInfoSnapshotMgr::get_neighbour_major_freeze(const int64_t snapshot_version, NeighbourFreezeInfoLite& info) +int ObFreezeInfoSnapshotMgr::get_neighbour_major_freeze(const int64_t snapshot_version, NeighbourFreezeInfoLite &info) { RLockGuard lock_guard(lock_); return inner_get_neighbour_major_freeze(snapshot_version, info); } int ObFreezeInfoSnapshotMgr::get_neighbour_major_freeze( - const uint64_t table_id, const int64_t snapshot_version, NeighbourFreezeInfo& info) + const uint64_t table_id, const int64_t snapshot_version, NeighbourFreezeInfo &info) { int ret = OB_SUCCESS; @@ -428,7 +426,7 @@ int ObFreezeInfoSnapshotMgr::get_neighbour_major_freeze( } static inline int is_snapshot_related_to_table( - const ObPartitionKey& pkey, const int64_t create_schema_version, const ObSnapshotInfo& snapshot, bool& related) + const ObPartitionKey &pkey, const int64_t create_schema_version, const ObSnapshotInfo &snapshot, bool &related) { int ret = OB_SUCCESS; related = false; @@ -437,8 +435,8 @@ static inline int is_snapshot_related_to_table( if (!snapshot.is_valid()) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "invalid argument", K(ret), K(snapshot)); - } else if (snapshot.snapshot_type_ == share::SNAPSHOT_FOR_RESTORE_POINT - || snapshot.snapshot_type_ == share::SNAPSHOT_FOR_BACKUP_POINT) { + } else if (snapshot.snapshot_type_ == share::SNAPSHOT_FOR_RESTORE_POINT || + snapshot.snapshot_type_ == share::SNAPSHOT_FOR_BACKUP_POINT) { if (snapshot.snapshot_type_ == share::SNAPSHOT_FOR_RESTORE_POINT && is_inner_table(table_id)) { related = false; } else if (extract_tenant_id(table_id) == snapshot.tenant_id_) { @@ -465,14 +463,14 @@ static inline int is_snapshot_related_to_table( return ret; } -int ObFreezeInfoSnapshotMgr::get_multi_version_duration(const uint64_t tenant_id, int64_t& duration) const +int ObFreezeInfoSnapshotMgr::get_multi_version_duration(const uint64_t tenant_id, int64_t &duration) const { int ret = OB_SUCCESS; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); ObSchemaGetterGuard guard; ObString var_name(share::OB_SV_UNDO_RETENTION); - const ObSysVarSchema* var_schema = NULL; + const ObSysVarSchema *var_schema = NULL; ObArenaAllocator allocator(ObModIds::OB_PARTITION_SERVICE); ObObj value; @@ -495,18 +493,17 @@ int ObFreezeInfoSnapshotMgr::get_multi_version_duration(const uint64_t tenant_id return ret; } -int ObFreezeInfoSnapshotMgr::get_min_reserved_snapshot(const ObPartitionKey& pkey, const int64_t merged_version, - const int64_t create_schema_version, int64_t& snapshot_version, int64_t& backup_snapshot_version) +int ObFreezeInfoSnapshotMgr::get_min_reserved_snapshot(const ObPartitionKey &pkey, const int64_t merged_version, + const int64_t create_schema_version, int64_t &snapshot_version) { int ret = OB_SUCCESS; FreezeInfoLite freeze_info; int64_t duration = 0; bool unused = false; - backup_snapshot_version = 0; const int64_t table_id = pkey.get_table_id(); RLockGuard lock_guard(lock_); - ObIArray& snapshots = snapshots_[cur_idx_]; + ObIArray &snapshots = snapshots_[cur_idx_]; if (OB_UNLIKELY(!inited_)) { ret = OB_NOT_INIT; @@ -526,10 +523,9 @@ int ObFreezeInfoSnapshotMgr::get_min_reserved_snapshot(const ObPartitionKey& pke } snapshot_version = std::max(0L, snapshot_gc_ts_ - duration * 1000L * 1000L); snapshot_version = std::min(snapshot_version, freeze_info.freeze_ts); - backup_snapshot_version = backup_snapshot_version_; for (int64_t i = 0; i < snapshots.count() && OB_SUCC(ret); ++i) { bool related = false; - const ObSnapshotInfo& snapshot = snapshots.at(i); + const ObSnapshotInfo &snapshot = snapshots.at(i); if (OB_FAIL(is_snapshot_related_to_table(pkey, create_schema_version, snapshot, related))) { STORAGE_LOG(WARN, "fail to check snapshot relation", K(ret), K(table_id), K(snapshot)); } else if (related) { @@ -541,15 +537,15 @@ int ObFreezeInfoSnapshotMgr::get_min_reserved_snapshot(const ObPartitionKey& pke } int ObFreezeInfoSnapshotMgr::get_reserve_points(const int64_t tenant_id, const share::ObSnapShotType snapshot_type, - ObIArray& restore_points, int64_t& snapshot_gc_ts) + ObIArray &restore_points, int64_t &snapshot_gc_ts) { int ret = OB_SUCCESS; restore_points.reset(); RLockGuard lock_guard(lock_); snapshot_gc_ts = snapshot_gc_ts_; - ObIArray& snapshots = snapshots_[cur_idx_]; + ObIArray &snapshots = snapshots_[cur_idx_]; for (int64_t i = 0; i < snapshots.count() && OB_SUCC(ret); ++i) { - const ObSnapshotInfo& snapshot = snapshots.at(i); + const ObSnapshotInfo &snapshot = snapshots.at(i); if (snapshot.snapshot_type_ == snapshot_type && tenant_id == snapshot.tenant_id_) { if (OB_FAIL(restore_points.push_back(snapshot))) { STORAGE_LOG(WARN, "fail to push back snapshot", K(ret), K(snapshot)); @@ -579,7 +575,7 @@ int ObFreezeInfoSnapshotMgr::get_latest_freeze_version(int64_t &freeze_version) int ret = OB_SUCCESS; RLockGuard lock_guard(lock_); - ObIArray& info_list = info_list_[cur_idx_]; + ObIArray &info_list = info_list_[cur_idx_]; if (OB_UNLIKELY(!inited_)) { ret = OB_NOT_INIT; @@ -636,12 +632,12 @@ int ObFreezeInfoSnapshotMgr::prepare_new_info_list(const int64_t min_major_versi } int ObFreezeInfoSnapshotMgr::update_next_gc_schema_version( - const ObIArray& gc_schema_version, const int64_t gc_snapshot_ts) + const ObIArray &gc_schema_version, const int64_t gc_snapshot_ts) { int ret = OB_SUCCESS; int64_t next_idx = get_next_idx(); - hash::ObHashMap& next_gc_snapshot_info = gc_snapshot_info_[next_idx]; + hash::ObHashMap &next_gc_snapshot_info = gc_snapshot_info_[next_idx]; if (!next_gc_snapshot_info.created()) { if (OB_FAIL(next_gc_snapshot_info.create(1024, ObModIds::OB_FREEZE_INFO_CACHE))) { @@ -650,7 +646,7 @@ int ObFreezeInfoSnapshotMgr::update_next_gc_schema_version( } for (int64_t i = 0; i < gc_schema_version.count() && OB_SUCC(ret); ++i) { - const SchemaPair& pair = gc_schema_version.at(i); + const SchemaPair &pair = gc_schema_version.at(i); if (OB_INVALID_VERSION != pair.schema_version) { if (OB_FAIL(next_gc_snapshot_info.set_refactored( pair.tenant_id, GCSnapshotInfo(gc_snapshot_ts, pair.schema_version), 1 /*overwrite*/))) { @@ -671,17 +667,17 @@ int ObFreezeInfoSnapshotMgr::update_next_gc_schema_version( return ret; } -int ObFreezeInfoSnapshotMgr::update_next_info_list(const ObIArray& info_list) +int ObFreezeInfoSnapshotMgr::update_next_info_list(const ObIArray &info_list) { int ret = OB_SUCCESS; int64_t next_idx = get_next_idx(); - ObIArray& next_info_list = info_list_[next_idx]; + ObIArray &next_info_list = info_list_[next_idx]; for (int64_t i = 0; i < info_list.count() && OB_SUCC(ret); ++i) { - const FreezeInfoLite& next = info_list.at(i); + const FreezeInfoLite &next = info_list.at(i); if (next_info_list.count() > 0) { - FreezeInfoLite& prev = next_info_list.at(next_info_list.count() - 1); + FreezeInfoLite &prev = next_info_list.at(next_info_list.count() - 1); if (OB_UNLIKELY(prev.freeze_version > next.freeze_version)) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(ERROR, "freeze verison decrease is not allowed", K(ret), K(prev), K(next)); @@ -699,12 +695,12 @@ int ObFreezeInfoSnapshotMgr::update_next_info_list(const ObIArray& snapshots) +int ObFreezeInfoSnapshotMgr::update_next_snapshots(const ObIArray &snapshots) { int ret = OB_SUCCESS; int64_t next_idx = get_next_idx(); - ObIArray& next_snapshots = snapshots_[next_idx]; + ObIArray &next_snapshots = snapshots_[next_idx]; for (int64_t i = 0; i < snapshots.count() && OB_SUCC(ret); ++i) { if (OB_FAIL(next_snapshots.push_back(snapshots.at(i)))) { @@ -717,10 +713,9 @@ int ObFreezeInfoSnapshotMgr::update_next_snapshots(const ObIArray& gc_schema_version, - const ObIArray& info_list, const ObIArray& snapshots, - const int64_t backup_snapshot_version, const int64_t delay_delete_snapshot_version, const int64_t min_major_version, - bool& gc_snapshot_ts_changed) +int ObFreezeInfoSnapshotMgr::update_info(const int64_t snapshot_gc_ts, const ObIArray &gc_schema_version, + const ObIArray &info_list, const ObIArray &snapshots, + const int64_t min_major_version, bool &gc_snapshot_ts_changed) { int ret = OB_SUCCESS; @@ -747,21 +742,6 @@ int ObFreezeInfoSnapshotMgr::update_info(const int64_t snapshot_gc_ts, const ObI switch_info(); snapshot_gc_ts_ = snapshot_gc_ts; } - - if (OB_SUCC(ret)) { - if (backup_snapshot_version_ != backup_snapshot_version) { - STORAGE_LOG(INFO, "update backup snapshot_version", K(backup_snapshot_version_), K(backup_snapshot_version)); - backup_snapshot_version_ = backup_snapshot_version; - } - if (delay_delete_snapshot_version_ != delay_delete_snapshot_version) { - STORAGE_LOG(INFO, - "update delay_delete_snapshot_version", - K(delay_delete_snapshot_version_), - K(delay_delete_snapshot_version)); - delay_delete_snapshot_version_ = delay_delete_snapshot_version; - } - } - return ret; } @@ -771,7 +751,7 @@ int64_t ObFreezeInfoSnapshotMgr::get_snapshot_gc_ts() return snapshot_gc_ts_; } -ObFreezeInfoSnapshotMgr::SchemaQuerySet::SchemaQuerySet(SchemaCache& schema_cache) +ObFreezeInfoSnapshotMgr::SchemaQuerySet::SchemaQuerySet(SchemaCache &schema_cache) : schema_querys_(), schema_cache_(schema_cache), lock_(), inited_(false) {} @@ -847,7 +827,7 @@ int ObFreezeInfoSnapshotMgr::SchemaQuerySet::update_schema_cache() return ret; } -int ObFreezeInfoSnapshotMgr::SchemaQuerySet::pop_schema_query(SchemaQuery& query) +int ObFreezeInfoSnapshotMgr::SchemaQuerySet::pop_schema_query(SchemaQuery &query) { int ret = OB_SUCCESS; @@ -865,7 +845,7 @@ int ObFreezeInfoSnapshotMgr::SchemaQuerySet::pop_schema_query(SchemaQuery& query return ret; } -ObFreezeInfoSnapshotMgr::ReloadTask::ReloadTask(ObFreezeInfoSnapshotMgr& mgr, SchemaQuerySet& schema_query_set) +ObFreezeInfoSnapshotMgr::ReloadTask::ReloadTask(ObFreezeInfoSnapshotMgr &mgr, SchemaQuerySet &schema_query_set) : inited_(false), is_remote_(false), mgr_(mgr), @@ -876,7 +856,7 @@ ObFreezeInfoSnapshotMgr::ReloadTask::ReloadTask(ObFreezeInfoSnapshotMgr& mgr, Sc schema_query_set_(schema_query_set) {} -int ObFreezeInfoSnapshotMgr::ReloadTask::init(ObISQLClient& sql_proxy, bool is_remote) +int ObFreezeInfoSnapshotMgr::ReloadTask::init(ObISQLClient &sql_proxy, bool is_remote) { int ret = OB_SUCCESS; if (OB_UNLIKELY(inited_)) { @@ -892,7 +872,7 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::init(ObISQLClient& sql_proxy, bool is_r } int ObFreezeInfoSnapshotMgr::ReloadTask::get_global_info_compat_below_220( - int64_t& snapshot_gc_ts, ObIArray& gc_schema_version) + int64_t &snapshot_gc_ts, ObIArray &gc_schema_version) { int ret = OB_SUCCESS; @@ -917,7 +897,7 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::get_global_info_compat_below_220( } int ObFreezeInfoSnapshotMgr::ReloadTask::get_global_info( - int64_t& snapshot_gc_ts, ObIArray& gc_schema_version) + int64_t &snapshot_gc_ts, ObIArray &gc_schema_version) { int ret = OB_SUCCESS; @@ -928,7 +908,7 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::get_global_info( STORAGE_LOG(WARN, "fail to get global info", K(ret)); } else { for (int64_t i = 0; i < tmp.count() && OB_SUCC(ret); ++i) { - TenantIdAndSchemaVersion& pair = tmp.at(i); + TenantIdAndSchemaVersion &pair = tmp.at(i); if (OB_FAIL(gc_schema_version.push_back(SchemaPair(pair.tenant_id_, pair.schema_version_)))) { STORAGE_LOG(WARN, "fail to push back schema pair", K(ret)); } @@ -939,7 +919,7 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::get_global_info( } int ObFreezeInfoSnapshotMgr::ReloadTask::get_freeze_info( - int64_t& min_major_version, ObIArray& freeze_info) + int64_t &min_major_version, ObIArray &freeze_info) { int ret = OB_SUCCESS; @@ -954,7 +934,7 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::get_freeze_info( STORAGE_LOG(WARN, "fail to get freeze info", K(ret), K(freeze_version)); } else { for (int64_t i = 0; i < tmp.count() && OB_SUCC(ret); ++i) { - ObSimpleFrozenStatus& status = tmp.at(i); + ObSimpleFrozenStatus &status = tmp.at(i); if (OB_FAIL(freeze_info.push_back( FreezeInfoLite(status.frozen_version_, status.frozen_timestamp_, status.cluster_version_)))) { STORAGE_LOG(WARN, "fail to push back freeze info", K(ret), K(status)); @@ -965,51 +945,6 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::get_freeze_info( return ret; } -int ObFreezeInfoSnapshotMgr::ReloadTask::get_backup_snapshot_version(int64_t& backup_snapshot_version) -{ - int ret = OB_SUCCESS; - const uint64_t tenant_id = OB_SYS_TENANT_ID; - const uint64_t cluster_version = GET_MIN_CLUSTER_VERSION(); - - if (cluster_version < CLUSTER_VERSION_2250) { - backup_snapshot_version = 0; - LOG_INFO("old cluster version, no need get_backup_snapshot_version", K(cluster_version)); - } else if (OB_FAIL(ObTenantBackupInfoOperation::get_backup_snapshot_version( - *sql_proxy_, tenant_id, backup_snapshot_version))) { - LOG_WARN("failed to get backup snapshot_version", K(ret)); - } - - return ret; -} - -int ObFreezeInfoSnapshotMgr::get_local_backup_snapshot_version(int64_t& backup_snapshot_version) -{ - int ret = OB_SUCCESS; - RLockGuard lock_guard(lock_); - - if (0 == snapshot_gc_ts_ || 1 == snapshot_gc_ts_) { - if (REACH_TIME_INTERVAL(60 * 1000 * 1000)) { - TRANS_LOG(INFO, "rs havenot send the snapshot or standby ob is starting", K(snapshot_gc_ts_)); - } - ret = OB_EAGAIN; - } else { - // ATTENTION: - // 1. snapshot_gc_ts is updated incrementally - // 2. backup_snapshot_version is bigger than snapshot_gc_ts in rootservice heartbeat - // 3. it is guaranteed there exists a recover point smaller than snapshot_gc_ts - // - // Then, there should exist a recover point smaller than - // backup_snapshot_version when rootservice heartbeat is receive - if (0 == backup_snapshot_version_) { - backup_snapshot_version = snapshot_gc_ts_; - } else { - backup_snapshot_version = MIN(backup_snapshot_version_, snapshot_gc_ts_); - } - } - - return ret; -} - int ObFreezeInfoSnapshotMgr::ReloadTask::try_update_info() { int ret = OB_SUCCESS; @@ -1030,10 +965,8 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::try_update_info() ObSEArray freeze_info; ObSEArray snapshots; bool changed = false; - observer::ObService* ob_service = GCTX.ob_service_; - int64_t backup_snapshot_version = 0; + observer::ObService *ob_service = GCTX.ob_service_; int64_t min_major_version = INT64_MAX; - int64_t delay_delete_snapshot_version = 0; if (OB_FAIL(schema_query_set_.update_schema_cache())) { STORAGE_LOG(WARN, "fail to update schema cache", K(ret)); @@ -1046,18 +979,8 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::try_update_info() STORAGE_LOG(WARN, "failed to get freeze info", K(ret)); } else if (OB_FAIL(snapshot_proxy_.get_all_snapshots(*sql_proxy_, snapshots))) { STORAGE_LOG(WARN, "failed to get snapshots", K(ret)); - } else if (OB_FAIL(get_backup_snapshot_version(backup_snapshot_version))) { - LOG_WARN("failed to get backup snapshot version", K(ret)); - } else if (OB_FAIL(ObBackupInfoMgr::get_instance().get_backup_snapshot_version(delay_delete_snapshot_version))) { - LOG_WARN("failed to get delay delete snapshot version", K(ret)); - } else if (OB_FAIL(mgr_.update_info(snapshot_gc_ts, - gc_schema_version, - freeze_info, - snapshots, - backup_snapshot_version, - delay_delete_snapshot_version, - min_major_version, - changed))) { + } else if (OB_FAIL(mgr_.update_info( + snapshot_gc_ts, gc_schema_version, freeze_info, snapshots, min_major_version, changed))) { STORAGE_LOG(WARN, "update info failed", K(ret), K(snapshot_gc_ts), K(freeze_info), K(snapshots)); } else { if (changed || ob_service->is_heartbeat_expired()) { @@ -1086,12 +1009,7 @@ int ObFreezeInfoSnapshotMgr::ReloadTask::try_update_info() } } - STORAGE_LOG(DEBUG, - "reload freeze info and snapshots", - K(snapshot_gc_ts), - K(freeze_info), - K(snapshots), - K(backup_snapshot_version)); + STORAGE_LOG(DEBUG, "reload freeze info and snapshots", K(snapshot_gc_ts), K(freeze_info), K(snapshots)); } } return ret; @@ -1102,7 +1020,7 @@ void ObFreezeInfoSnapshotMgr::ReloadTask::runTimerTask() try_update_info(); } -ObFreezeInfoSnapshotMgr::SchemaCache::SchemaCache(SchemaQuerySet& schema_query_set) +ObFreezeInfoSnapshotMgr::SchemaCache::SchemaCache(SchemaQuerySet &schema_query_set) : lock_(), head_(NULL), tail_(NULL), @@ -1120,15 +1038,15 @@ ObFreezeInfoSnapshotMgr::SchemaCache::~SchemaCache() reset(); } -int ObFreezeInfoSnapshotMgr::SchemaCache::init(ObISQLClient& sql_proxy) +int ObFreezeInfoSnapshotMgr::SchemaCache::init(ObISQLClient &sql_proxy) { int ret = OB_SUCCESS; - schema_node* p = NULL; + schema_node *p = NULL; if (OB_UNLIKELY(inited_)) { ret = OB_INIT_TWICE; - } else if (NULL == (p = (schema_node*)allocator_.alloc())) { + } else if (NULL == (p = (schema_node *)allocator_.alloc())) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "fail to alloc head node", K(ret)); } else { @@ -1149,8 +1067,8 @@ void ObFreezeInfoSnapshotMgr::SchemaCache::reset() SpinLockGuard guard(lock_); - schema_node* curr = head_; - schema_node* t = NULL; + schema_node *curr = head_; + schema_node *t = NULL; while (curr) { t = curr; @@ -1165,7 +1083,7 @@ void ObFreezeInfoSnapshotMgr::SchemaCache::reset() } int ObFreezeInfoSnapshotMgr::SchemaCache::get_freeze_schema_version( - const uint64_t tenant_id, const int64_t freeze_version, const bool async, int64_t& schema_version) + const uint64_t tenant_id, const int64_t freeze_version, const bool async, int64_t &schema_version) { int ret = OB_SUCCESS; @@ -1256,7 +1174,7 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::update_schema_version(const uint64_t t return ret; } -void ObFreezeInfoSnapshotMgr::SchemaCache::insert(schema_node* p) +void ObFreezeInfoSnapshotMgr::SchemaCache::insert(schema_node *p) { p->next = head_->next; p->prev = head_; @@ -1268,7 +1186,7 @@ void ObFreezeInfoSnapshotMgr::SchemaCache::insert(schema_node* p) tail_ = p; } -void ObFreezeInfoSnapshotMgr::SchemaCache::move_forward(schema_node* p) +void ObFreezeInfoSnapshotMgr::SchemaCache::move_forward(schema_node *p) { if (!p->next) { tail_ = p->prev; @@ -1280,12 +1198,12 @@ void ObFreezeInfoSnapshotMgr::SchemaCache::move_forward(schema_node* p) insert(p); } -ObFreezeInfoSnapshotMgr::SchemaCache::schema_node* ObFreezeInfoSnapshotMgr::SchemaCache::inner_find( +ObFreezeInfoSnapshotMgr::SchemaCache::schema_node *ObFreezeInfoSnapshotMgr::SchemaCache::inner_find( const uint64_t tenant_id, const int64_t freeze_version) { - schema_node* node = NULL; - schema_node* prev = head_; - schema_node* curr = prev->next; + schema_node *node = NULL; + schema_node *prev = head_; + schema_node *curr = prev->next; while (curr) { if (curr->tenant_id == tenant_id && curr->freeze_version == freeze_version) { @@ -1301,13 +1219,13 @@ ObFreezeInfoSnapshotMgr::SchemaCache::schema_node* ObFreezeInfoSnapshotMgr::Sche } int ObFreezeInfoSnapshotMgr::SchemaCache::find( - const uint64_t tenant_id, const int64_t freeze_version, int64_t& schema_version) + const uint64_t tenant_id, const int64_t freeze_version, int64_t &schema_version) { int ret = OB_SUCCESS; SpinLockGuard guard(lock_); - schema_node* node = inner_find(tenant_id, freeze_version); + schema_node *node = inner_find(tenant_id, freeze_version); if (NULL != node) { schema_version = node->schema_version; move_forward(node); @@ -1322,7 +1240,7 @@ bool ObFreezeInfoSnapshotMgr::SchemaCache::freeze_info_exist(const int64_t freez SpinLockGuard guard(lock_); - schema_node* curr = head_; + schema_node *curr = head_; do { curr = curr->next; if (curr && curr->freeze_version == freeze_version) { @@ -1345,7 +1263,7 @@ bool ObFreezeInfoSnapshotMgr::SchemaCache::inner_schema_exist(const uint64_t ten int ret = OB_SUCCESS; bool bool_ret = false; - schema_node* node = inner_find(tenant_id, freeze_version); + schema_node *node = inner_find(tenant_id, freeze_version); if (NULL != node) { bool_ret = true; } @@ -1363,8 +1281,8 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::update_freeze_schema( if (inner_schema_exist(tenant_id, freeze_version)) { // skip } else if (cnt_ < MAX_SCHEMA_ENTRY) { - schema_node* p = NULL; - if (NULL == (p = (schema_node*)allocator_.alloc())) { + schema_node *p = NULL; + if (NULL == (p = (schema_node *)allocator_.alloc())) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "fail to alloc schema node", K(ret)); } else { @@ -1374,7 +1292,7 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::update_freeze_schema( cnt_++; } } else { - schema_node* p = tail_; + schema_node *p = tail_; p->set(tenant_id, freeze_version, schema_version); move_forward(p); } @@ -1387,12 +1305,12 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::update_freeze_schema( } int ObFreezeInfoSnapshotMgr::SchemaCache::update_freeze_schema( - const int64_t freeze_version, ObIArray& freeze_schema) + const int64_t freeze_version, ObIArray &freeze_schema) { int ret = OB_SUCCESS; for (int64_t i = 0; i < freeze_schema.count() && OB_SUCC(ret); ++i) { - SchemaPair& pair = freeze_schema.at(i); + SchemaPair &pair = freeze_schema.at(i); if (OB_FAIL(update_freeze_schema(pair.tenant_id, freeze_version, pair.schema_version))) { STORAGE_LOG(WARN, "fail to update freeze schema", K(ret), K(freeze_version), K(pair)); } @@ -1402,7 +1320,7 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::update_freeze_schema( } int ObFreezeInfoSnapshotMgr::SchemaCache::fetch_freeze_schema( - const uint64_t tenant_id, const int64_t freeze_version, int64_t& schema_version) + const uint64_t tenant_id, const int64_t freeze_version, int64_t &schema_version) { int ret = OB_SUCCESS; @@ -1417,7 +1335,7 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::fetch_freeze_schema( } int ObFreezeInfoSnapshotMgr::SchemaCache::fetch_freeze_schema(const uint64_t tenant_id, const int64_t freeze_version, - int64_t& schema_version, ObIArray& freeze_schema) + int64_t &schema_version, ObIArray &freeze_schema) { int ret = OB_SUCCESS; @@ -1433,7 +1351,7 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::fetch_freeze_schema(const uint64_t ten } } else if (tmp.count() > 0) { for (int64_t i = 0; i < tmp.count() && OB_SUCC(ret); ++i) { - TenantIdAndSchemaVersion& pair = tmp.at(i); + TenantIdAndSchemaVersion &pair = tmp.at(i); if (tenant_id == pair.tenant_id_) { schema_version = pair.schema_version_; @@ -1453,7 +1371,7 @@ int ObFreezeInfoSnapshotMgr::SchemaCache::fetch_freeze_schema(const uint64_t ten return ret; } -ObFreezeInfoSnapshotMgr& ObFreezeInfoMgrWrapper::get_instance(const uint64_t table_id) +ObFreezeInfoSnapshotMgr &ObFreezeInfoMgrWrapper::get_instance(const uint64_t table_id) { bool remote_table = OB_INVALID_ID != table_id && is_sys_table(table_id) && !ObMultiClusterUtil::is_cluster_private_table(table_id); @@ -1467,7 +1385,7 @@ ObFreezeInfoSnapshotMgr& ObFreezeInfoMgrWrapper::get_instance(const uint64_t tab } } -int ObFreezeInfoMgrWrapper::init(common::ObISQLClient& local_proxy, common::ObISQLClient& remote_proxy) +int ObFreezeInfoMgrWrapper::init(common::ObISQLClient &local_proxy, common::ObISQLClient &remote_proxy) { 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 0cb38cb2cfa6ed233c2a8dc599a8dd5002367eee..9eda436fa0dd4570f080fc4bb22b42d348efb587 100644 --- a/src/storage/ob_freeze_info_snapshot_mgr.h +++ b/src/storage/ob_freeze_info_snapshot_mgr.h @@ -62,7 +62,7 @@ public: FreezeInfo() : freeze_version(-1), freeze_ts(-1), schema_version(-1), cluster_version(0) {} - FreezeInfo& operator=(const FreezeInfoLite& o) + FreezeInfo &operator=(const FreezeInfoLite &o) { freeze_version = o.freeze_version; freeze_ts = o.freeze_ts; @@ -106,7 +106,7 @@ public: FreezeInfo next; FreezeInfoLite prev; - NeighbourFreezeInfo& operator=(const NeighbourFreezeInfoLite& o) + NeighbourFreezeInfo &operator=(const NeighbourFreezeInfoLite &o) { next = o.next; prev = o.prev; @@ -132,7 +132,7 @@ public: TO_STRING_KV(K(tenant_id), K(schema_version)); }; - int init(common::ObISQLClient& sql_proxy, bool is_remote); + int init(common::ObISQLClient &sql_proxy, bool is_remote); void init_for_test() { inited_ = true; @@ -148,57 +148,35 @@ 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 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); + 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); + 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 min_major_version, bool &changed); int64_t get_snapshot_gc_ts(); - int get_local_backup_snapshot_version(int64_t& backup_snapshot_version); - ObFreezeInfoSnapshotMgr(const ObFreezeInfoSnapshotMgr&) = delete; - ObFreezeInfoSnapshotMgr& operator=(const ObFreezeInfoSnapshotMgr&) = delete; + ObFreezeInfoSnapshotMgr(const ObFreezeInfoSnapshotMgr &) = delete; + ObFreezeInfoSnapshotMgr &operator=(const ObFreezeInfoSnapshotMgr &) = delete; ObFreezeInfoSnapshotMgr(); virtual ~ObFreezeInfoSnapshotMgr(); @@ -211,7 +189,7 @@ private: static const int64_t MAX_GC_SNAPSHOT_TS_REFRESH_TS = 10L * 60L * 1000L * 1000L; static const int64_t FLUSH_GC_SNAPSHOT_TS_REFRESH_TS = common::MODIFY_GC_SNAPSHOT_INTERVAL + 10L * 1000L * 1000L; - int get_latest_freeze_version(int64_t& freeze_version); + int get_latest_freeze_version(int64_t &freeze_version); int64_t get_next_idx() { return 1L - cur_idx_; @@ -221,21 +199,21 @@ private: cur_idx_ = get_next_idx(); } int prepare_new_info_list(const int64_t min_major_version); - virtual int get_multi_version_duration(const uint64_t tenant_id, int64_t& duration) const; - int inner_get_neighbour_major_freeze(const int64_t snapshot_version, NeighbourFreezeInfoLite& info); + virtual int get_multi_version_duration(const uint64_t tenant_id, int64_t &duration) const; + int inner_get_neighbour_major_freeze(const int64_t snapshot_version, NeighbourFreezeInfoLite &info); int update_next_gc_schema_version( - const common::ObIArray& gc_schema_version, const int64_t snapshot_gc_ts); - int update_next_info_list(const common::ObIArray& info_list); - int update_next_snapshots(const common::ObIArray& snapshots); + const common::ObIArray &gc_schema_version, const int64_t snapshot_gc_ts); + int update_next_info_list(const common::ObIArray &info_list); + int update_next_snapshots(const common::ObIArray &snapshots); int get_freeze_info_by_major_version_( - const int64_t major_version, FreezeInfoLite& freeze_info, bool& is_first_major_version); + const int64_t major_version, FreezeInfoLite &freeze_info, bool &is_first_major_version); int get_tenant_freeze_info_by_major_version_( - const uint64_t tenant_id, const int64_t major_version, const bool async, FreezeInfo& freeze_info); + const uint64_t tenant_id, const int64_t major_version, const bool async, FreezeInfo &freeze_info); class SchemaCache; class SchemaQuerySet { public: - explicit SchemaQuerySet(SchemaCache& schema_cache); + explicit SchemaQuerySet(SchemaCache &schema_cache); ~SchemaQuerySet() {} int init(); @@ -252,7 +230,7 @@ private: : tenant_id_(tenant_id), freeze_version_(freeze_version) {} - bool operator==(const SchemaQuery& o) const + bool operator==(const SchemaQuery &o) const { return (tenant_id_ == o.tenant_id_) && (freeze_version_ == o.freeze_version_); } @@ -269,10 +247,10 @@ private: int64_t freeze_version_; }; - int pop_schema_query(SchemaQuery& query); + int pop_schema_query(SchemaQuery &query); common::hash::ObHashSet schema_querys_; - SchemaCache& schema_cache_; + SchemaCache &schema_cache_; common::RWLock lock_; bool inited_; @@ -280,27 +258,26 @@ private: class ReloadTask : public common::ObTimerTask { public: - ReloadTask(ObFreezeInfoSnapshotMgr& mgr, SchemaQuerySet& schema_query_set); + ReloadTask(ObFreezeInfoSnapshotMgr &mgr, SchemaQuerySet &schema_query_set); virtual ~ReloadTask() {} - int init(common::ObISQLClient& sql_proxy, bool is_remote); + int init(common::ObISQLClient &sql_proxy, bool is_remote); virtual void runTimerTask(); int try_update_info(); private: - int get_global_info_compat_below_220(int64_t& snapshot_gc_ts, common::ObIArray& gc_schema_version); - int get_global_info(int64_t& snapshot_gc_ts, common::ObIArray& gc_schema_version); - int get_freeze_info(int64_t& min_major_version, common::ObIArray& freeze_info); - int get_backup_snapshot_version(int64_t& backup_snapshot_version); + int get_global_info_compat_below_220(int64_t &snapshot_gc_ts, common::ObIArray &gc_schema_version); + int get_global_info(int64_t &snapshot_gc_ts, common::ObIArray &gc_schema_version); + int get_freeze_info(int64_t &min_major_version, common::ObIArray &freeze_info); bool inited_; bool is_remote_; - ObFreezeInfoSnapshotMgr& mgr_; - common::ObISQLClient* sql_proxy_; + ObFreezeInfoSnapshotMgr &mgr_; + common::ObISQLClient *sql_proxy_; share::ObFreezeInfoProxy freeze_info_proxy_; share::ObSnapshotTableProxy snapshot_proxy_; int64_t last_change_ts_; - SchemaQuerySet& schema_query_set_; + SchemaQuerySet &schema_query_set_; }; // LRU cache of schema information for different tenant major version @@ -308,16 +285,16 @@ private: public: typedef common::ObSpinLockGuard SpinLockGuard; - explicit SchemaCache(SchemaQuerySet& schema_query_set); + explicit SchemaCache(SchemaQuerySet &schema_query_set); virtual ~SchemaCache(); - int init(common::ObISQLClient& sql_proxy); + int init(common::ObISQLClient &sql_proxy); void reset(); // return the schema version on success or OB_EAGAIN if major is not ready. // the LRU cache will update itself if the cache is not hit. int get_freeze_schema_version( - const uint64_t tenant_id, const int64_t freeze_version, const bool async, int64_t& schema_version); + const uint64_t tenant_id, const int64_t freeze_version, const bool async, int64_t &schema_version); int update_schema_version(const uint64_t tenant_id, const int64_t freeze_version); @@ -330,10 +307,13 @@ private: // value int64_t schema_version; // pointers - schema_node* prev; - schema_node* next; + schema_node *prev; + schema_node *next; - schema_node() { reset(); } + schema_node() + { + reset(); + } void set(const uint64_t tenant, const int64_t freeze, const int64_t schema) { @@ -354,40 +334,40 @@ private: TO_STRING_KV(K(tenant_id), K(freeze_version), K(schema_version)); }; - void insert(schema_node* p); - void move_forward(schema_node* p); - int find(const uint64_t tenant_id, const int64_t freeze_version, int64_t& schema_version); + void insert(schema_node *p); + void move_forward(schema_node *p); + int find(const uint64_t tenant_id, const int64_t freeze_version, int64_t &schema_version); bool freeze_info_exist(const int64_t freeze_version); bool schema_exist(const uint64_t tenant_id, const int64_t freeze_version); bool inner_schema_exist(const uint64_t tenant_id, const int64_t freeze_version); - schema_node* inner_find(const uint64_t tenant_id, const int64_t freeze_version); + schema_node *inner_find(const uint64_t tenant_id, const int64_t freeze_version); - virtual int fetch_freeze_schema(const uint64_t tenant_id, const int64_t freeze_version, int64_t& schema_version); - virtual int fetch_freeze_schema(const uint64_t tenant_id, const int64_t freeze_version, int64_t& schema_version, - common::ObIArray& freeze_schema); + virtual int fetch_freeze_schema(const uint64_t tenant_id, const int64_t freeze_version, int64_t &schema_version); + virtual int fetch_freeze_schema(const uint64_t tenant_id, const int64_t freeze_version, int64_t &schema_version, + common::ObIArray &freeze_schema); public: // for ut only int update_freeze_schema(const uint64_t tenant_id, const int64_t freeze_version, const int64_t schema_version); private: - int update_freeze_schema(const int64_t freeze_version, common::ObIArray& freeze_schema); + int update_freeze_schema(const int64_t freeze_version, common::ObIArray &freeze_schema); common::ObSpinLock lock_; static const int64_t MAX_SCHEMA_ENTRY = 10000L; - schema_node* head_; - schema_node* tail_; + schema_node *head_; + schema_node *tail_; int64_t cnt_; bool inited_; - common::ObISQLClient* sql_proxy_; + common::ObISQLClient *sql_proxy_; share::ObFreezeInfoProxy freeze_info_proxy_; lib::ObMemAttr mem_attr_; common::ObSliceAlloc allocator_; - SchemaQuerySet& schema_query_set_; + SchemaQuerySet &schema_query_set_; }; bool inited_; @@ -404,8 +384,6 @@ private: common::ObSEArray info_list_[2]; // lite one doesnot contain schema_version common::ObSEArray snapshots_[2]; // snapshots_ matains multi_version_start for index and // others - int64_t backup_snapshot_version_; // backup snapshot version is used for backup and recovery - int64_t delay_delete_snapshot_version_; // reserve the multi-version of __all_ddl_operatuib when backup int64_t cur_idx_; common::RWLock lock_; @@ -413,8 +391,8 @@ private: class ObFreezeInfoMgrWrapper { public: - static ObFreezeInfoSnapshotMgr& get_instance(const uint64_t table_id = common::OB_INVALID_ID); - static int init(common::ObISQLClient& local_proxy, common::ObISQLClient& remote_proxy); + static ObFreezeInfoSnapshotMgr &get_instance(const uint64_t table_id = common::OB_INVALID_ID); + static int init(common::ObISQLClient &local_proxy, common::ObISQLClient &remote_proxy); static int start(); static void wait(); static void stop(); diff --git a/src/storage/ob_multi_version_table_store.cpp b/src/storage/ob_multi_version_table_store.cpp index 64b4f3c8543d262e6d3acbc273f0355491058772..68c170acec45903e4a2931df2b5b7fe5baf68b97 100644 --- a/src/storage/ob_multi_version_table_store.cpp +++ b/src/storage/ob_multi_version_table_store.cpp @@ -41,7 +41,7 @@ ObMultiVersionTableStore::ObMultiVersionTableStore() ObMultiVersionTableStore::~ObMultiVersionTableStore() { - ObTableStore* table_store = nullptr; + ObTableStore *table_store = nullptr; if (is_inited_) { while (head_ < tail_) { @@ -62,11 +62,11 @@ ObMultiVersionTableStore::~ObMultiVersionTableStore() is_inited_ = false; } -int ObMultiVersionTableStore::init(const common::ObPartitionKey& pkey, const uint64_t table_id, - ObFreezeInfoSnapshotMgr* freeze_info_mgr, ObPGMemtableMgr* pg_memtable_mgr, const int64_t schema_version) +int ObMultiVersionTableStore::init(const common::ObPartitionKey &pkey, const uint64_t table_id, + ObFreezeInfoSnapshotMgr *freeze_info_mgr, ObPGMemtableMgr *pg_memtable_mgr, const int64_t schema_version) { int ret = OB_SUCCESS; - ObTableStore* new_store = nullptr; + ObTableStore *new_store = nullptr; if (is_inited_) { ret = OB_INIT_TWICE; @@ -108,11 +108,11 @@ int ObMultiVersionTableStore::init(const common::ObPartitionKey& pkey, const uin // used in logic split, reference tables from parent partition int ObMultiVersionTableStore::set_reference_tables( - ObTablesHandle& handle, ObTableStore*& new_table_store, const int64_t memtable_base_version, bool& need_update) + ObTablesHandle &handle, ObTableStore *&new_table_store, const int64_t memtable_base_version, bool &need_update) { int ret = OB_SUCCESS; ObTablesHandle latest_tables_handle; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; new_table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { @@ -143,10 +143,10 @@ int ObMultiVersionTableStore::set_reference_tables( // p0 Minor SSTable + memtable split and assign to p1 int ObMultiVersionTableStore::prepare_update_split_table_store( - const bool is_major_split, ObTablesHandle& handle, bool& need_update, ObTableStore*& new_table_store) + const bool is_major_split, ObTablesHandle &handle, bool &need_update, ObTableStore *&new_table_store) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; ObTablesHandle old_handle; bool is_complete = false; @@ -178,10 +178,10 @@ int ObMultiVersionTableStore::prepare_update_split_table_store( } int ObMultiVersionTableStore::check_need_split( - common::ObVersion& split_version, bool& need_split, bool& need_minor_split) + common::ObVersion &split_version, bool &need_split, bool &need_minor_split) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; ObTablesHandle old_handle; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -200,10 +200,10 @@ int ObMultiVersionTableStore::check_need_split( return ret; } -int ObMultiVersionTableStore::check_can_migrate(bool& can_migrate) +int ObMultiVersionTableStore::check_can_migrate(bool &can_migrate) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -216,10 +216,10 @@ int ObMultiVersionTableStore::check_can_migrate(bool& can_migrate) return ret; } -int ObMultiVersionTableStore::check_complete(bool& is_complete) +int ObMultiVersionTableStore::check_complete(bool &is_complete) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -232,10 +232,10 @@ int ObMultiVersionTableStore::check_complete(bool& is_complete) return ret; } -int ObMultiVersionTableStore::is_physical_split_finished(bool& is_physical_split_finish) +int ObMultiVersionTableStore::is_physical_split_finished(bool &is_physical_split_finish) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; ObTablesHandle old_handle; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -253,10 +253,10 @@ int ObMultiVersionTableStore::is_physical_split_finished(bool& is_physical_split return ret; } -int ObMultiVersionTableStore::get_physical_split_info(ObVirtualPartitionSplitInfo& split_info) +int ObMultiVersionTableStore::get_physical_split_info(ObVirtualPartitionSplitInfo &split_info) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -273,13 +273,13 @@ int ObMultiVersionTableStore::get_physical_split_info(ObVirtualPartitionSplitInf // add_sstable_with_prewarm is used after merge int ObMultiVersionTableStore::prepare_add_sstable( - AddTableParam& param, ObTableStore*& new_table_store, bool& need_update) + AddTableParam ¶m, ObTableStore *&new_table_store, bool &need_update) { int ret = OB_SUCCESS; need_update = true; bool is_equal = false; bool can_split = false; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; ObTablesHandle latest_tables_handle; new_table_store = NULL; bool need_check_split = (NULL != param.table_ && param.table_->get_partition_key() != pkey_) ? true : false; @@ -349,10 +349,10 @@ int ObMultiVersionTableStore::prepare_add_sstable( } int ObMultiVersionTableStore::prepare_remove_sstable( - AddTableParam& param, ObTablesHandle& handle, ObTableStore*& new_table_store, bool& is_equal) + AddTableParam ¶m, ObTablesHandle &handle, ObTableStore *&new_table_store, bool &is_equal) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; new_table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { @@ -404,7 +404,7 @@ int ObMultiVersionTableStore::prepare_remove_sstable( return ret; } -int ObMultiVersionTableStore::alloc_table_store(ObTableStore*& new_table_store) +int ObMultiVersionTableStore::alloc_table_store(ObTableStore *&new_table_store) { int ret = OB_SUCCESS; @@ -417,7 +417,7 @@ int ObMultiVersionTableStore::alloc_table_store(ObTableStore*& new_table_store) return ret; } -void ObMultiVersionTableStore::free_table_store(ObTableStore*& new_table_store) +void ObMultiVersionTableStore::free_table_store(ObTableStore *&new_table_store) { if (NULL != new_table_store) { LOG_INFO("succeed to free_table_store", KP(new_table_store)); @@ -426,7 +426,7 @@ void ObMultiVersionTableStore::free_table_store(ObTableStore*& new_table_store) } } -int ObMultiVersionTableStore::enable_table_store(const bool need_prewarm, ObTableStore& new_table_store) +int ObMultiVersionTableStore::enable_table_store(const bool need_prewarm, ObTableStore &new_table_store) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -445,7 +445,7 @@ int ObMultiVersionTableStore::enable_table_store(const bool need_prewarm, ObTabl if (OB_SUCC(ret) && !need_prewarm) { while (OB_SUCC(ret) && head_ < tail_) { - ObTableStore* table_store = get_store(head_); + ObTableStore *table_store = get_store(head_); if (NULL != table_store) { LOG_INFO("retire table store", K(pkey_), @@ -471,10 +471,10 @@ int ObMultiVersionTableStore::enable_table_store(const bool need_prewarm, ObTabl } int ObMultiVersionTableStore::get_read_tables( - const int64_t snapshot_version, ObTablesHandle& handle, const bool allow_not_ready, const bool print_dropped_alert) + const int64_t snapshot_version, ObTablesHandle &handle, const bool allow_not_ready, const bool print_dropped_alert) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -499,10 +499,10 @@ int ObMultiVersionTableStore::get_read_tables( return ret; } -int ObMultiVersionTableStore::get_reference_tables(ObTablesHandle& handle) +int ObMultiVersionTableStore::get_reference_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -516,10 +516,10 @@ int ObMultiVersionTableStore::get_reference_tables(ObTablesHandle& handle) return ret; } -int ObMultiVersionTableStore::get_sample_read_tables(const common::SampleInfo& sample_info, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_sample_read_tables(const common::SampleInfo &sample_info, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -534,10 +534,10 @@ int ObMultiVersionTableStore::get_sample_read_tables(const common::SampleInfo& s return ret; } -int ObMultiVersionTableStore::get_major_sstable(const ObVersion& version, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_major_sstable(const ObVersion &version, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -552,11 +552,11 @@ int ObMultiVersionTableStore::get_major_sstable(const ObVersion& version, ObTabl return ret; } -int ObMultiVersionTableStore::get_all_tables(TableSet& table_set, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_all_tables(TableSet &table_set, ObTablesHandle &handle) { int ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -574,7 +574,7 @@ int ObMultiVersionTableStore::get_all_tables(TableSet& table_set, ObTablesHandle LOG_WARN("failed to get all tables", K(ret), K(pkey_), K(table_id_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_handle.get_count(); ++i) { - ObITable* table = tmp_handle.get_table(i); + ObITable *table = tmp_handle.get_table(i); int64_t table_addr = reinterpret_cast(table); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; @@ -606,10 +606,10 @@ int ObMultiVersionTableStore::get_all_tables(TableSet& table_set, ObTablesHandle return ret; } -int ObMultiVersionTableStore::check_memtable_merged(const ObMemtable& memtable, bool& all_merged, bool& can_release) +int ObMultiVersionTableStore::check_memtable_merged(const ObMemtable &memtable, bool &all_merged, bool &can_release) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -638,10 +638,10 @@ int ObMultiVersionTableStore::check_memtable_merged(const ObMemtable& memtable, return ret; } -int ObMultiVersionTableStore::get_effective_tables(const bool include_active_memtable, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_effective_tables(const bool include_active_memtable, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -660,10 +660,10 @@ int ObMultiVersionTableStore::get_effective_tables(const bool include_active_mem return ret; } -int ObMultiVersionTableStore::get_latest_major_sstable(ObTableHandle& handle) +int ObMultiVersionTableStore::get_latest_major_sstable(ObTableHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -680,7 +680,7 @@ int ObMultiVersionTableStore::get_latest_major_sstable(ObTableHandle& handle) return ret; } -int ObMultiVersionTableStore::get_sstable_schema_version(int64_t& schema_version) +int ObMultiVersionTableStore::get_sstable_schema_version(int64_t &schema_version) { int ret = OB_SUCCESS; ObTableHandle handle; @@ -700,10 +700,10 @@ int ObMultiVersionTableStore::get_sstable_schema_version(int64_t& schema_version return ret; } -int ObMultiVersionTableStore::get_replay_tables(ObIArray& replay_tables) +int ObMultiVersionTableStore::get_replay_tables(ObIArray &replay_tables) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -718,10 +718,10 @@ int ObMultiVersionTableStore::get_replay_tables(ObIArray& re return ret; } -int ObMultiVersionTableStore::get_oldest_read_tables(const int64_t snapshot_version, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_oldest_read_tables(const int64_t snapshot_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -739,10 +739,10 @@ int ObMultiVersionTableStore::get_oldest_read_tables(const int64_t snapshot_vers } int ObMultiVersionTableStore::get_merge_tables( - const ObGetMergeTablesParam& param, const int64_t multi_version_start, ObGetMergeTablesResult& result) + const ObGetMergeTablesParam ¶m, const int64_t multi_version_start, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -776,10 +776,10 @@ int ObMultiVersionTableStore::get_merge_tables( return ret; } -int ObMultiVersionTableStore::get_split_tables(const bool is_major_split, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_split_tables(const bool is_major_split, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -802,7 +802,7 @@ int ObMultiVersionTableStore::get_split_tables(const bool is_major_split, ObTabl int ObMultiVersionTableStore::retire_prewarm_store(const int64_t duration, const int64_t minor_deferred_gc_time) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; const int64_t retire_ts = duration <= 0 ? INT64_MAX : ObTimeUtility::current_time() - duration; const int64_t retire_gc_sstbale_ts = minor_deferred_gc_time <= 0 ? INT64_MAX : ObTimeUtility::current_time() - minor_deferred_gc_time; @@ -834,7 +834,7 @@ int ObMultiVersionTableStore::retire_prewarm_store(const int64_t duration, const for (int64_t i = gc_sstable_count_ - 1; OB_SUCC(ret) && i >= 0; --i) { if (gc_sstable_infos_[i].retired_ts_ < retire_gc_sstbale_ts) { - ObGCSSTableInfo& gc_sstable_info = gc_sstable_infos_[i]; + ObGCSSTableInfo &gc_sstable_info = gc_sstable_infos_[i]; LOG_INFO("retire gc sstable", K(gc_sstable_count_), K(minor_deferred_gc_time), K(gc_sstable_info)); gc_sstable_info.sstable_->dec_ref(); gc_sstable_info.reset(); @@ -851,7 +851,7 @@ int ObMultiVersionTableStore::retire_prewarm_store(const int64_t duration, const int ObMultiVersionTableStore::retire_head_store() { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -872,10 +872,10 @@ int ObMultiVersionTableStore::retire_head_store() return ret; } -int ObMultiVersionTableStore::get_latest_table_count(int64_t& latest_table_count) +int ObMultiVersionTableStore::get_latest_table_count(int64_t &latest_table_count) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -889,10 +889,10 @@ int ObMultiVersionTableStore::get_latest_table_count(int64_t& latest_table_count return ret; } -int ObMultiVersionTableStore::check_latest_table_count_safe(bool& is_safe) +int ObMultiVersionTableStore::check_latest_table_count_safe(bool &is_safe) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -906,10 +906,10 @@ int ObMultiVersionTableStore::check_latest_table_count_safe(bool& is_safe) return ret; } -int ObMultiVersionTableStore::latest_has_major_sstable(bool& has_major) +int ObMultiVersionTableStore::latest_has_major_sstable(bool &has_major) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -923,7 +923,7 @@ int ObMultiVersionTableStore::latest_has_major_sstable(bool& has_major) return ret; } -int64_t ObMultiVersionTableStore::to_string(char* buf, const int64_t buf_len) const +int64_t ObMultiVersionTableStore::to_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; if (OB_ISNULL(buf) || buf_len <= 0) { @@ -940,13 +940,13 @@ int64_t ObMultiVersionTableStore::to_string(char* buf, const int64_t buf_len) co K_(head)); J_ARRAY_START(); for (int64_t tmp_pos = head_; tmp_pos < tail_; ++tmp_pos) { - const ObTableStore* table_store = table_stores_[get_idx(tmp_pos)]; + const ObTableStore *table_store = table_stores_[get_idx(tmp_pos)]; J_KV(K(tmp_pos), K(table_store)); } J_ARRAY_END(); J_ARRAY_START(); for (int64_t i = 0; i < gc_sstable_count_; ++i) { - const ObGCSSTableInfo& gc_info = gc_sstable_infos_[i]; + const ObGCSSTableInfo &gc_info = gc_sstable_infos_[i]; if (gc_info.sstable_ != NULL) { J_KV("retired_ts", gc_info.retired_ts_, "table_key", gc_info.sstable_->get_key()); } else { @@ -975,10 +975,10 @@ int ObMultiVersionTableStore::finish_replay(const int64_t multi_version_start) return ret; } -int ObMultiVersionTableStore::check_ready_for_read(bool& is_ready) +int ObMultiVersionTableStore::check_ready_for_read(bool &is_ready) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -993,12 +993,11 @@ int ObMultiVersionTableStore::check_ready_for_read(bool& is_ready) return ret; } -int ObMultiVersionTableStore::need_remove_old_table(const common::ObVersion& kept_min_version, - const int64_t multi_version_start, const int64_t backup_snapshot_verison, int64_t& real_kept_major_num, - bool& need_remove) +int ObMultiVersionTableStore::need_remove_old_table(const common::ObVersion &kept_min_version, + const int64_t multi_version_start, int64_t &real_kept_major_num, bool &need_remove) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1007,16 +1006,16 @@ int ObMultiVersionTableStore::need_remove_old_table(const common::ObVersion& kep ret = OB_ERR_SYS; LOG_ERROR("store must not null", K(ret), K(pkey_), K(table_id_)); } else if (OB_FAIL(table_store->need_remove_old_table( - kept_min_version, multi_version_start, backup_snapshot_verison, real_kept_major_num, need_remove))) { + kept_min_version, multi_version_start, real_kept_major_num, need_remove))) { LOG_WARN("fail to check need remove old table", K(ret), K(pkey_), K(table_id_)); } return ret; } -int ObMultiVersionTableStore::set_table_store(const ObTableStore& table_store) +int ObMultiVersionTableStore::set_table_store(const ObTableStore &table_store) { int ret = OB_SUCCESS; - ObTableStore* new_table_store = NULL; + ObTableStore *new_table_store = NULL; const bool need_prewarm = false; if (OB_UNLIKELY(!is_inited_)) { @@ -1042,10 +1041,10 @@ int ObMultiVersionTableStore::set_table_store(const ObTableStore& table_store) } int ObMultiVersionTableStore::check_need_minor_merge( - const bool is_follower_data_rep, const ObMergeType merge_type, bool& need_merge) + const bool is_follower_data_rep, const ObMergeType merge_type, bool &need_merge) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1083,7 +1082,7 @@ void ObMultiVersionTableStore::ObGCSSTableInfo::reset() retired_ts_ = 0; } -int64_t ObMultiVersionTableStore::ObGCSSTableInfo::to_string(char* buf, const int64_t buf_len) const +int64_t ObMultiVersionTableStore::ObGCSSTableInfo::to_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; if (OB_ISNULL(buf) || buf_len <= 0) { @@ -1100,7 +1099,7 @@ int64_t ObMultiVersionTableStore::ObGCSSTableInfo::to_string(char* buf, const in return pos; } -int ObMultiVersionTableStore::record_gc_minor_sstable(ObTableStore& new_table_store) +int ObMultiVersionTableStore::record_gc_minor_sstable(ObTableStore &new_table_store) { int ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; @@ -1124,14 +1123,14 @@ int ObMultiVersionTableStore::record_gc_minor_sstable(ObTableStore& new_table_st if (OB_SUCC(ret) && old_tables_handle.get_count() > 0 && minor_deferred_gc_time > 0) { for (int64_t i = 0; OB_SUCC(ret) && i < new_tables_handle.get_count(); ++i) { - ObITable* table = new_tables_handle.get_table(i); + ObITable *table = new_tables_handle.get_table(i); int64_t table_addr = reinterpret_cast(table); if (OB_FAIL(new_table_set.set_refactored(table_addr))) { LOG_WARN("failed to set table addr", K(ret)); } } for (int64_t i = 0; OB_SUCC(ret) && i < old_tables_handle.get_count(); ++i) { - ObITable* table = old_tables_handle.get_table(i); + ObITable *table = old_tables_handle.get_table(i); int64_t table_addr = reinterpret_cast(table); hash_ret = new_table_set.exist_refactored(table_addr); if (OB_ISNULL(table)) { @@ -1140,7 +1139,7 @@ int ObMultiVersionTableStore::record_gc_minor_sstable(ObTableStore& new_table_st } else if (table->is_mini_minor_sstable() || (table->is_minor_sstable() && 1 == minor_deferred_gc_level)) { if (OB_HASH_NOT_EXIST == hash_ret) { if (OB_FAIL(add_gc_minor_sstable( - cur_time, static_cast(table), MAX_DEFERRED_GC_MINOR_SSTABLE_COUNT))) { + cur_time, static_cast(table), MAX_DEFERRED_GC_MINOR_SSTABLE_COUNT))) { LOG_WARN("failed to add gc minor sstable", K(ret)); } } else if (OB_HASH_EXIST == hash_ret) { @@ -1156,7 +1155,7 @@ int ObMultiVersionTableStore::record_gc_minor_sstable(ObTableStore& new_table_st } int ObMultiVersionTableStore::add_gc_minor_sstable( - const int64_t gc_ts, ObSSTable* table, const int64_t max_deferred_gc_count) + const int64_t gc_ts, ObSSTable *table, const int64_t max_deferred_gc_count) { int ret = OB_SUCCESS; int64_t find_pos = -1; @@ -1179,7 +1178,7 @@ int ObMultiVersionTableStore::add_gc_minor_sstable( if (OB_SUCC(ret)) { if (-1 == find_pos) { // add new if (gc_sstable_count_ == max_deferred_gc_count) { - ObGCSSTableInfo& last_info = gc_sstable_infos_[gc_sstable_count_ - 1]; + ObGCSSTableInfo &last_info = gc_sstable_infos_[gc_sstable_count_ - 1]; last_info.sstable_->dec_ref(); last_info.reset(); --gc_sstable_count_; @@ -1209,7 +1208,7 @@ int ObMultiVersionTableStore::add_gc_minor_sstable( return ret; } -int ObMultiVersionTableStore::get_gc_sstables(ObTablesHandle& handle) +int ObMultiVersionTableStore::get_gc_sstables(ObTablesHandle &handle) { int ret = OB_SUCCESS; @@ -1229,7 +1228,7 @@ int ObMultiVersionTableStore::get_gc_sstables(ObTablesHandle& handle) } int ObMultiVersionTableStore::set_replay_sstables( - const bool is_replay_old, const common::ObIArray& sstables) + const bool is_replay_old, const common::ObIArray &sstables) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1244,10 +1243,10 @@ int ObMultiVersionTableStore::set_replay_sstables( return ret; } -int ObMultiVersionTableStore::get_multi_version_start(int64_t& multi_version_start) +int ObMultiVersionTableStore::get_multi_version_start(int64_t &multi_version_start) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1261,10 +1260,10 @@ int ObMultiVersionTableStore::get_multi_version_start(int64_t& multi_version_sta return ret; } -int ObMultiVersionTableStore::get_max_major_sstable_snapshot(int64_t& max_snapshot_version) +int ObMultiVersionTableStore::get_max_major_sstable_snapshot(int64_t &max_snapshot_version) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; ObTableHandle handle; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1285,10 +1284,10 @@ int ObMultiVersionTableStore::get_max_major_sstable_snapshot(int64_t& max_snapsh return ret; } -int ObMultiVersionTableStore::get_min_max_major_version(int64_t& min_version, int64_t& max_version) +int ObMultiVersionTableStore::get_min_max_major_version(int64_t &min_version, int64_t &max_version) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1302,10 +1301,10 @@ int ObMultiVersionTableStore::get_min_max_major_version(int64_t& min_version, in return ret; } -int ObMultiVersionTableStore::get_latest_minor_sstables(ObTablesHandle& handle) +int ObMultiVersionTableStore::get_latest_minor_sstables(ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = nullptr; + ObTableStore *table_store = nullptr; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -1318,7 +1317,7 @@ int ObMultiVersionTableStore::get_latest_minor_sstables(ObTablesHandle& handle) return ret; } -int ObMultiVersionTableStore::add_complement_minor_sstable_if_needed_(AddTableParam& param, ObTableStore& store) +int ObMultiVersionTableStore::add_complement_minor_sstable_if_needed_(AddTableParam ¶m, ObTableStore &store) { int ret = OB_SUCCESS; if (nullptr == param.complement_minor_sstable_) { @@ -1327,10 +1326,10 @@ int ObMultiVersionTableStore::add_complement_minor_sstable_if_needed_(AddTablePa return ret; } -int ObMultiVersionTableStore::get_latest_continue_tables(ObTablesHandle& handle) +int ObMultiVersionTableStore::get_latest_continue_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* latest_store = NULL; + ObTableStore *latest_store = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -1343,11 +1342,11 @@ int ObMultiVersionTableStore::get_latest_continue_tables(ObTablesHandle& handle) return ret; } -int ObMultiVersionTableStore::get_min_schema_version(int64_t& min_schema_version) +int ObMultiVersionTableStore::get_min_schema_version(int64_t &min_schema_version) { int ret = OB_SUCCESS; min_schema_version = 0; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1361,10 +1360,10 @@ int ObMultiVersionTableStore::get_min_schema_version(int64_t& min_schema_version return ret; } -int ObMultiVersionTableStore::get_flashback_major_tables(const int64_t flashback_scn, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_flashback_major_tables(const int64_t flashback_scn, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1379,10 +1378,10 @@ int ObMultiVersionTableStore::get_flashback_major_tables(const int64_t flashback } int ObMultiVersionTableStore::get_mark_deletion_tables( - const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle& handle) + const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = nullptr; + ObTableStore *table_store = nullptr; if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -1399,7 +1398,7 @@ int ObMultiVersionTableStore::get_mark_deletion_tables( int ObMultiVersionTableStore::clear_complement_minor_sstable() { int ret = OB_SUCCESS; - ObTableStore* table_store = nullptr; + ObTableStore *table_store = nullptr; if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -1413,10 +1412,10 @@ int ObMultiVersionTableStore::clear_complement_minor_sstable() return ret; } -int ObMultiVersionTableStore::get_schema_version(int64_t& schema_version) +int ObMultiVersionTableStore::get_schema_version(int64_t &schema_version) { int ret = OB_SUCCESS; - ObTableStore* table_store = nullptr; + ObTableStore *table_store = nullptr; int64_t table_count = 0; schema_version = INT64_MAX; @@ -1439,10 +1438,10 @@ int ObMultiVersionTableStore::get_schema_version(int64_t& schema_version) } int ObMultiVersionTableStore::get_needed_local_tables_for_migrate( - const ObMigrateRemoteTableInfo& remote_table_info, ObTablesHandle& handle) + const ObMigrateRemoteTableInfo &remote_table_info, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store; + ObTableStore *table_store; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("multi version table store is inited", K(ret)); @@ -1457,10 +1456,10 @@ int ObMultiVersionTableStore::get_needed_local_tables_for_migrate( return ret; } -int ObMultiVersionTableStore::get_migrate_tables(ObTablesHandle& handle, bool& is_ready_for_read) +int ObMultiVersionTableStore::get_migrate_tables(ObTablesHandle &handle, bool &is_ready_for_read) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; is_ready_for_read = false; if (OB_UNLIKELY(!is_inited_)) { @@ -1486,7 +1485,7 @@ int ObMultiVersionTableStore::set_drop_schema_info(const int64_t drop_schema_ver return ret; } -int ObMultiVersionTableStore::get_drop_schema_info(int64_t& drop_schema_version, int64_t& drop_schema_refreshed_ts) +int ObMultiVersionTableStore::get_drop_schema_info(int64_t &drop_schema_version, int64_t &drop_schema_refreshed_ts) { int ret = OB_SUCCESS; drop_schema_version = drop_schema_version_; @@ -1494,10 +1493,10 @@ int ObMultiVersionTableStore::get_drop_schema_info(int64_t& drop_schema_version, return ret; } -int ObMultiVersionTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle& handle) +int ObMultiVersionTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; int64_t multi_version_start = 0; if (OB_UNLIKELY(!is_inited_)) { diff --git a/src/storage/ob_multi_version_table_store.h b/src/storage/ob_multi_version_table_store.h index bb549d76e5a69c8c091bb0db37d878153817b545..78d7a2e1fa5100d41e91eb648160acf6a76c9f6d 100644 --- a/src/storage/ob_multi_version_table_store.h +++ b/src/storage/ob_multi_version_table_store.h @@ -30,75 +30,75 @@ public: ObMultiVersionTableStore(); virtual ~ObMultiVersionTableStore(); - int init(const common::ObPartitionKey& pkey, const uint64_t table_id, ObFreezeInfoSnapshotMgr* freeze_info_mgr, - ObPGMemtableMgr* pg_memtable_mgr, const int64_t schema_version = 0); + int init(const common::ObPartitionKey &pkey, const uint64_t table_id, ObFreezeInfoSnapshotMgr *freeze_info_mgr, + ObPGMemtableMgr *pg_memtable_mgr, const int64_t schema_version = 0); uint64_t get_table_id() const { return table_id_; } int set_reference_tables( - ObTablesHandle& handle, ObTableStore*& new_table_store, const int64_t memtable_base_version, bool& need_update); + ObTablesHandle &handle, ObTableStore *&new_table_store, const int64_t memtable_base_version, bool &need_update); int prepare_update_split_table_store( - const bool is_major_split, ObTablesHandle& handle, bool& need_update, ObTableStore*& new_table_store); - int check_need_split(common::ObVersion& split_version, bool& need_split, bool& need_minor_split); - int check_can_split(bool& can_split); - int check_can_migrate(bool& can_migrate); - int check_complete(bool& is_complete); - int is_physical_split_finished(bool& is_physical_split_finish); - int get_physical_split_info(ObVirtualPartitionSplitInfo& split_info); - int prepare_add_sstable(AddTableParam& param, ObTableStore*& new_table_store, bool& need_update); + const bool is_major_split, ObTablesHandle &handle, bool &need_update, ObTableStore *&new_table_store); + int check_need_split(common::ObVersion &split_version, bool &need_split, bool &need_minor_split); + int check_can_split(bool &can_split); + int check_can_migrate(bool &can_migrate); + int check_complete(bool &is_complete); + int is_physical_split_finished(bool &is_physical_split_finish); + int get_physical_split_info(ObVirtualPartitionSplitInfo &split_info); + int prepare_add_sstable(AddTableParam ¶m, ObTableStore *&new_table_store, bool &need_update); int prepare_remove_sstable( - AddTableParam& param, ObTablesHandle& handle, ObTableStore*& new_table_store, bool& is_equal); - int alloc_table_store(ObTableStore*& new_table_store); - void free_table_store(ObTableStore*& new_table_store); - int enable_table_store(const bool need_prewarm, ObTableStore& new_table_store); + AddTableParam ¶m, ObTablesHandle &handle, ObTableStore *&new_table_store, bool &is_equal); + int alloc_table_store(ObTableStore *&new_table_store); + void free_table_store(ObTableStore *&new_table_store); + int enable_table_store(const bool need_prewarm, ObTableStore &new_table_store); - int get_read_tables(const int64_t snapshot_version, ObTablesHandle& handle, const bool allow_not_ready, + int get_read_tables(const int64_t snapshot_version, ObTablesHandle &handle, const bool allow_not_ready, const bool print_dropped_alert); - int get_reference_tables(ObTablesHandle& handle); - int get_sample_read_tables(const common::SampleInfo& sample_info, ObTablesHandle& handle); - int get_major_sstable(const common::ObVersion& version, ObTablesHandle& handle); - - int get_all_tables(TableSet& table_set, ObTablesHandle& handle); - int check_memtable_merged(const memtable::ObMemtable& memtable, bool& all_merged, bool& can_release); - int get_latest_major_sstable(ObTableHandle& handle); - int get_sstable_schema_version(int64_t& schema_version); + int get_reference_tables(ObTablesHandle &handle); + int get_sample_read_tables(const common::SampleInfo &sample_info, ObTablesHandle &handle); + int get_major_sstable(const common::ObVersion &version, ObTablesHandle &handle); + + int get_all_tables(TableSet &table_set, ObTablesHandle &handle); + int check_memtable_merged(const memtable::ObMemtable &memtable, bool &all_merged, bool &can_release); + int get_latest_major_sstable(ObTableHandle &handle); + int get_sstable_schema_version(int64_t &schema_version); int get_merge_tables( - const ObGetMergeTablesParam& param, const int64_t multi_version_start, ObGetMergeTablesResult& result); + const ObGetMergeTablesParam ¶m, const int64_t multi_version_start, ObGetMergeTablesResult &result); - int get_split_tables(const bool is_major_split, ObTablesHandle& handle); + int get_split_tables(const bool is_major_split, ObTablesHandle &handle); int retire_prewarm_store(const int64_t duration, const int64_t minor_deferred_gc_time); - int get_latest_table_count(int64_t& latest_table_count); - int check_latest_table_count_safe(bool& is_safe); - int latest_has_major_sstable(bool& has_major); - int get_effective_tables(const bool include_active_memtable, ObTablesHandle& handle); + int get_latest_table_count(int64_t &latest_table_count); + int check_latest_table_count_safe(bool &is_safe); + int latest_has_major_sstable(bool &has_major); + int get_effective_tables(const bool include_active_memtable, ObTablesHandle &handle); int finish_replay(const int64_t multi_version_start); - int check_ready_for_read(bool& is_ready); - int need_remove_old_table(const common::ObVersion& kept_min_version, const int64_t multi_version_start, - const int64_t backup_snapshot_verison, int64_t& real_kept_major_num, bool& need_remove); - int set_table_store(const ObTableStore& table_store); - OB_INLINE ObTableStore* get_latest_store(); - int get_replay_tables(ObIArray& replay_tables); - int set_replay_sstables(const bool is_replay_old, const common::ObIArray& sstables); - int check_need_minor_merge(const bool is_follower_data_rep, const ObMergeType merge_type, bool& need_merge); - int get_oldest_read_tables(const int64_t snapshot_version, ObTablesHandle& handle); - int get_gc_sstables(ObTablesHandle& handle); - int get_multi_version_start(int64_t& multi_version_start); - int get_max_major_sstable_snapshot(int64_t& max_snapshot_version); - int get_min_max_major_version(int64_t& min_version, int64_t& max_version); - int get_latest_minor_sstables(ObTablesHandle& handle); - int get_latest_continue_tables(ObTablesHandle& handle); - int get_flashback_major_tables(const int64_t flashback_scn, ObTablesHandle& handle); - int get_mark_deletion_tables(const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle& handle); + int check_ready_for_read(bool &is_ready); + int need_remove_old_table(const common::ObVersion &kept_min_version, const int64_t multi_version_start, + int64_t &real_kept_major_num, bool &need_remove); + int set_table_store(const ObTableStore &table_store); + OB_INLINE ObTableStore *get_latest_store(); + int get_replay_tables(ObIArray &replay_tables); + int set_replay_sstables(const bool is_replay_old, const common::ObIArray &sstables); + int check_need_minor_merge(const bool is_follower_data_rep, const ObMergeType merge_type, bool &need_merge); + int get_oldest_read_tables(const int64_t snapshot_version, ObTablesHandle &handle); + int get_gc_sstables(ObTablesHandle &handle); + int get_multi_version_start(int64_t &multi_version_start); + int get_max_major_sstable_snapshot(int64_t &max_snapshot_version); + int get_min_max_major_version(int64_t &min_version, int64_t &max_version); + int get_latest_minor_sstables(ObTablesHandle &handle); + int get_latest_continue_tables(ObTablesHandle &handle); + int get_flashback_major_tables(const int64_t flashback_scn, ObTablesHandle &handle); + int get_mark_deletion_tables(const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle &handle); int clear_complement_minor_sstable(); bool is_data_table() { return table_id_ == pkey_.get_table_id(); } - int get_min_schema_version(int64_t& min_schema_version); - int get_schema_version(int64_t& schema_version); + int get_min_schema_version(int64_t &min_schema_version); + int get_schema_version(int64_t &schema_version); void set_is_dropped_schema() { is_dropped_schema_ = true; @@ -107,18 +107,21 @@ public: { return is_dropped_schema_; } - int get_migrate_tables(ObTablesHandle& handle, bool& is_ready_for_read); - int get_needed_local_tables_for_migrate(const ObMigrateRemoteTableInfo& remote_table_info, ObTablesHandle& handle); + int get_migrate_tables(ObTablesHandle &handle, bool &is_ready_for_read); + int get_needed_local_tables_for_migrate(const ObMigrateRemoteTableInfo &remote_table_info, ObTablesHandle &handle); 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; } + 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; private: struct ObGCSSTableInfo final { - ObSSTable* sstable_; + ObSSTable *sstable_; int64_t retired_ts_; ObGCSSTableInfo(); @@ -127,24 +130,24 @@ private: DECLARE_TO_STRING; }; OB_INLINE int64_t get_idx(const int64_t pos) const; - OB_INLINE ObTableStore* get_store(const int64_t pos); - OB_INLINE ObTableStore* get_read_store(); + OB_INLINE ObTableStore *get_store(const int64_t pos); + OB_INLINE ObTableStore *get_read_store(); int retire_head_store(); - OB_INLINE ObTableStore* get_oldest_store(); - int record_gc_minor_sstable(ObTableStore& new_table_store); - int add_gc_minor_sstable(const int64_t gc_ts, ObSSTable* table, const int64_t max_deferred_gc_count); - int add_complement_minor_sstable_if_needed_(AddTableParam& param, ObTableStore& store); + OB_INLINE ObTableStore *get_oldest_store(); + int record_gc_minor_sstable(ObTableStore &new_table_store); + int add_gc_minor_sstable(const int64_t gc_ts, ObSSTable *table, const int64_t max_deferred_gc_count); + int add_complement_minor_sstable_if_needed_(AddTableParam ¶m, ObTableStore &store); private: bool is_inited_; common::ObPartitionKey pkey_; uint64_t table_id_; - ObTableStore* table_stores_[MAX_KETP_VERSION_NUM]; + ObTableStore *table_stores_[MAX_KETP_VERSION_NUM]; int64_t head_; int64_t tail_; common::ObRandom rand_; - ObFreezeInfoSnapshotMgr* freeze_info_mgr_; - ObPGMemtableMgr* pg_memtable_mgr_; + ObFreezeInfoSnapshotMgr *freeze_info_mgr_; + ObPGMemtableMgr *pg_memtable_mgr_; // Currently, only mini sstables are recorded, sorted by release time, and those released earlier are later ObGCSSTableInfo gc_sstable_infos_[MAX_DEFERRED_GC_MINOR_SSTABLE_COUNT]; int64_t gc_sstable_count_; @@ -165,20 +168,20 @@ OB_INLINE int64_t ObMultiVersionTableStore::get_idx(const int64_t pos) const return pos & ((1L << MAX_KETP_VERSION_SHIFT_NUM) - 1L); } -OB_INLINE ObTableStore* ObMultiVersionTableStore::get_store(const int64_t pos) +OB_INLINE ObTableStore *ObMultiVersionTableStore::get_store(const int64_t pos) { return table_stores_[get_idx(pos)]; } -OB_INLINE ObTableStore* ObMultiVersionTableStore::get_latest_store() +OB_INLINE ObTableStore *ObMultiVersionTableStore::get_latest_store() { - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (tail_ > head_) { table_store = table_stores_[get_idx(tail_ - 1L)]; } return table_store; } -OB_INLINE ObTableStore* ObMultiVersionTableStore::get_read_store() +OB_INLINE ObTableStore *ObMultiVersionTableStore::get_read_store() { int64_t index = get_idx(head_); const int64_t duration = GCONF.minor_warm_up_duration_time; @@ -203,9 +206,9 @@ OB_INLINE ObTableStore* ObMultiVersionTableStore::get_read_store() return table_stores_[index]; } -OB_INLINE ObTableStore* ObMultiVersionTableStore::get_oldest_store() +OB_INLINE ObTableStore *ObMultiVersionTableStore::get_oldest_store() { - ObTableStore* table_store = NULL; + ObTableStore *table_store = NULL; if (head_ < tail_) { table_store = table_stores_[get_idx(head_)]; } diff --git a/src/storage/ob_partition_backup.cpp b/src/storage/ob_partition_backup.cpp index 48fe6cc4d634681ee80a817a816a48f8a0986afb..dfdb9019bd56fe5acbd1ad64801343e288497a42 100644 --- a/src/storage/ob_partition_backup.cpp +++ b/src/storage/ob_partition_backup.cpp @@ -50,14 +50,14 @@ using namespace transaction; namespace storage { -ObPartGroupBackupTask::ObPartGroupBackupTask() : ObPartGroupTask(), backup_data_type_() +ObPartGroupBackupTask::ObPartGroupBackupTask() : ObPartGroupTask(), backup_data_type_(), data_statics_array_() {} ObPartGroupBackupTask::~ObPartGroupBackupTask() {} -int ObPartGroupBackupTask::init(const ObIArray& task_list, const bool is_batch_mode, - storage::ObPartitionService* partition_service, const share::ObTaskId& task_id) +int ObPartGroupBackupTask::init(const ObIArray &task_list, const bool is_batch_mode, + storage::ObPartitionService *partition_service, const share::ObTaskId &task_id) { int ret = OB_SUCCESS; const int64_t MAX_MAP_BUCKET_NUM = 1280; @@ -84,6 +84,8 @@ int ObPartGroupBackupTask::init(const ObIArray& task_list, const if (OB_FAIL(task_list_.push_back(tmp_task))) { STORAGE_LOG(WARN, "failed to add task list", K(ret)); + } else if (OB_FAIL(data_statics_array_.push_back(tmp_task.ctx_.data_statics_))) { + LOG_WARN("failed to push data statics", K(ret), K(tmp_task)); } if (OB_SUCC(ret)) { @@ -134,17 +136,16 @@ int ObPartGroupBackupTask::check_partition_validation() const bool is_restore_point = false; ObRecoveryPointSchemaFilter backup_filter; const ObPhysicalBackupArg &backup_arg = task_list_[0].arg_.backup_arg_; - if (OB_FAIL(backup_filter.init( - backup_arg.tenant_id_, - is_restore_point, - backup_arg.backup_schema_version_, /*backup_schema_version*/ - backup_arg.backup_schema_version_ /*current_schema_version*/))) { + if (OB_FAIL(backup_filter.init(backup_arg.tenant_id_, + is_restore_point, + backup_arg.backup_schema_version_, /*backup_schema_version*/ + backup_arg.backup_schema_version_ /*current_schema_version*/))) { STORAGE_LOG(WARN, "backup schema filter init fail", K(ret)); } for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& sub_task = task_list_[i]; - ObPartitionKey& pkey = sub_task.arg_.key_; + ObPartMigrationTask &sub_task = task_list_[i]; + ObPartitionKey &pkey = sub_task.arg_.key_; bool in_member_list = false; bool is_working_partition = partition_service_->is_working_partition(pkey); @@ -235,6 +236,8 @@ int ObPartGroupBackupTask::check_before_do_task() STORAGE_LOG(ERROR, "not inited", K(ret)); } else if (OB_FAIL(check_partition_validation())) { STORAGE_LOG(WARN, "failed to check_partition_validation", K(ret)); + } else if (OB_FAIL(check_before_backup())) { + STORAGE_LOG(WARN, "failed to check before backup", K(ret), K(*this)); } if (OB_FAIL(ret)) { @@ -245,7 +248,7 @@ int ObPartGroupBackupTask::check_before_do_task() return ret; } -int ObPartGroupBackupTask::do_backup_task(const ObBackupDataType& backup_data_type) +int ObPartGroupBackupTask::do_backup_task(const ObBackupDataType &backup_data_type) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -308,6 +311,8 @@ int ObPartGroupBackupTask::do_part_group_backup_minor_task() } else if (FALSE_IT(backup_data_type_.set_minor_data_backup())) { } else if (OB_FAIL(do_backup_task(backup_data_type_))) { STORAGE_LOG(WARN, "failed to do backup task", K(ret)); + } else if (OB_FAIL(update_backup_data_statics())) { + STORAGE_LOG(WARN, "failed to update backup data statics", K(ret)); } else { common::SpinRLockGuard guard(lock_); ret = first_error_code_; @@ -327,6 +332,8 @@ int ObPartGroupBackupTask::do_part_group_backup_major_task() } else if (FALSE_IT(backup_data_type_.set_major_data_backup())) { } else if (OB_FAIL(do_backup_task(backup_data_type_))) { STORAGE_LOG(WARN, "failed to do backup task", K(ret)); + } else if (OB_FAIL(update_backup_data_statics())) { + STORAGE_LOG(WARN, "failed to update backup data statics", K(ret)); } else { common::SpinRLockGuard guard(lock_); ret = first_error_code_; @@ -336,7 +343,7 @@ int ObPartGroupBackupTask::do_part_group_backup_major_task() } int ObPartGroupBackupTask::set_task_list_result( - const int32_t first_error_code, const common::ObIArray& task_list) + const int32_t first_error_code, const common::ObIArray &task_list) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -347,8 +354,8 @@ int ObPartGroupBackupTask::set_task_list_result( LOG_WARN("backup task list num is not equal", K(ret), K(task_list_.count()), K(task_list.count())); } else { for (int64_t i = 0; OB_SUCC(ret) && i < task_list.count(); ++i) { - const ObPartMigrationTask& tmp_task = task_list.at(i); - ObPartMigrationTask& task = task_list_.at(i); + const ObPartMigrationTask &tmp_task = task_list.at(i); + ObPartMigrationTask &task = task_list_.at(i); if (tmp_task.arg_.key_ != task.arg_.key_ || tmp_task.arg_.type_ != task.arg_.type_) { ret = OB_ERR_UNEXPECTED; LOG_WARN("backup task is not same", K(ret), K(task), K(tmp_task)); @@ -396,7 +403,8 @@ int ObPartGroupBackupTask::finish_group_backup_task() STORAGE_LOG(WARN, "failed to reserve report list", K(ret)); } for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& sub_task = task_list_[i]; + ObPartMigrationTask &sub_task = task_list_[i]; + ObPartitionMigrationDataStatics &data_statics = data_statics_array_.at(i); if (ObIPartMigrationTask::INIT == sub_task.status_) { sub_task.result_ = first_error_code; } else if (OB_SUCCESS == sub_task.result_ && !backup_data_type_.is_major_backup()) { @@ -406,7 +414,7 @@ int ObPartGroupBackupTask::finish_group_backup_task() tmp_task.status_ = ObIPartMigrationTask::FINISH; tmp_task.result_ = sub_task.result_; tmp_task.need_report_checksum_ = sub_task.ctx_.need_report_checksum_; - tmp_task.data_statics_ = sub_task.ctx_.data_statics_; + tmp_task.data_statics_ = data_statics; tmp_task.ctx_ = &sub_task.ctx_; if (OB_FAIL(report_list_.push_back(tmp_task))) { // report_list is reserved before, should not fail here @@ -426,6 +434,16 @@ int ObPartGroupBackupTask::finish_group_backup_task() } } + if (OB_SUCC(ret)) { + int tmp_ret = OB_SUCCESS; + ObArray report_res_list; + if (OB_SUCCESS != (tmp_ret = ObMigrateUtil::get_report_result(report_list_, report_res_list))) { + LOG_WARN("failed to get report result", K(tmp_ret), K(report_list_)); + } else if (OB_SUCCESS != (tmp_ret = partition_service_->report_pg_backup_task(report_res_list))) { + LOG_WARN("failed to report pg backup task", K(tmp_ret), K(report_res_list)); + } + } + if (OB_SUCC(ret)) { is_finished_ = true; } @@ -451,7 +469,7 @@ int ObPartGroupBackupTask::do_backup_pg_metas() common::SpinRLockGuard guard(lock_); SMART_VAR(ObBackupMetaWriter, meta_writer) { - common::ObInOutBandwidthThrottle* throttle = ObPartitionMigrator::get_instance().get_bandwidth_throttle(); + common::ObInOutBandwidthThrottle *throttle = ObPartitionMigrator::get_instance().get_bandwidth_throttle(); if (OB_ISNULL(throttle)) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "BandwidthThrottle should not be null here", K(ret)); @@ -471,10 +489,16 @@ int ObPartGroupBackupTask::do_backup_pg_metas() } } } + + if (OB_SUCC(ret)) { + if (OB_FAIL(update_backup_data_statics())) { + STORAGE_LOG(WARN, "failed to update backup data statics", K(ret)); + } + } return ret; } -int ObPartGroupBackupTask::try_schedule_new_partition_backup(const ObBackupDataType& backup_data_type) +int ObPartGroupBackupTask::try_schedule_new_partition_backup(const ObBackupDataType &backup_data_type) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -501,11 +525,11 @@ int ObPartGroupBackupTask::try_schedule_new_partition_backup(const ObBackupDataT return ret; } -int ObPartGroupBackupTask::try_schedule_partition_backup(const ObBackupDataType& backup_data_type) +int ObPartGroupBackupTask::try_schedule_partition_backup(const ObBackupDataType &backup_data_type) { int ret = OB_SUCCESS; bool need_schedule = true; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; int64_t data_backup_concurrency = GCONF.backup_concurrency; int32_t up_limit = 0; if (OB_FAIL(ObDagScheduler::get_instance().get_up_limit(ObIDag::DAG_ULT_BACKUP, up_limit))) { @@ -531,7 +555,7 @@ int ObPartGroupBackupTask::try_schedule_partition_backup(const ObBackupDataType& return ret; } -int ObPartGroupBackupTask::inner_schedule_partition(ObPartMigrationTask*& task, bool& need_schedule) +int ObPartGroupBackupTask::inner_schedule_partition(ObPartMigrationTask *&task, bool &need_schedule) { int ret = OB_SUCCESS; need_schedule = false; @@ -568,7 +592,7 @@ int ObPartGroupBackupTask::inner_schedule_partition(ObPartMigrationTask*& task, } // caller must not hold wlock -int ObPartGroupBackupTask::schedule_backup_dag(const ObBackupDataType& backup_data_type, ObMigrateCtx& migrate_ctx) +int ObPartGroupBackupTask::schedule_backup_dag(const ObBackupDataType &backup_data_type, ObMigrateCtx &migrate_ctx) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -599,7 +623,7 @@ int ObPartGroupBackupTask::schedule_backup_dag(const ObBackupDataType& backup_da return ret; } -int ObPartGroupBackupTask::try_finish_group_backup(bool& is_finished) +int ObPartGroupBackupTask::try_finish_group_backup(bool &is_finished) { int ret = OB_SUCCESS; bool is_sub_task_finish = true; @@ -613,7 +637,7 @@ int ObPartGroupBackupTask::try_finish_group_backup(bool& is_finished) common::SpinWLockGuard guard(lock_); for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& task = task_list_.at(i); + ObPartMigrationTask &task = task_list_.at(i); if (ObPartMigrationTask::FINISH != task.status_) { if (OB_SUCCESS != first_error_code_ && ObPartMigrationTask::INIT == task.status_) { task.status_ = ObPartMigrationTask::FINISH; @@ -640,7 +664,7 @@ void ObPartGroupBackupTask::reset_tasks_status() { common::SpinWLockGuard guard(lock_); for (int64_t i = 0; i < task_list_.count(); ++i) { - ObPartMigrationTask& task = task_list_.at(i); + ObPartMigrationTask &task = task_list_.at(i); task.ctx_.rebuild_migrate_ctx(); task.status_ = ObPartMigrationTask::INIT; task.result_ = OB_SUCCESS; @@ -662,8 +686,8 @@ int ObPartGroupBackupTask::check_all_pg_backup_point_created() } else { common::SpinRLockGuard guard(lock_); for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& task = task_list_.at(i); - const ObPartitionKey& pkey = task.arg_.key_; + ObPartMigrationTask &task = task_list_.at(i); + const ObPartitionKey &pkey = task.arg_.key_; const int64_t backup_snapshot_version = task.arg_.backup_arg_.backup_snapshot_version_; if (OB_FAIL(check_pg_backup_point_created(pkey, backup_snapshot_version))) { LOG_WARN("failed to check pg backup point created", K(ret), K(pkey), K(backup_snapshot_version)); @@ -678,11 +702,12 @@ int ObPartGroupBackupTask::check_all_pg_backup_point_created() } int ObPartGroupBackupTask::check_pg_backup_point_created( - const ObPartitionKey& pg_key, const int64_t backup_snapshot_version) + const ObPartitionKey &pg_key, const int64_t backup_snapshot_version) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; bool is_exist = false; + bool is_cancel = false; // TODO() need wakeup minor merge if (!is_inited_) { @@ -701,9 +726,14 @@ int ObPartGroupBackupTask::check_pg_backup_point_created( } else if (OB_FAIL(check_disk_space())) { LOG_WARN("failed to check disk space", K(ret)); break; + } else if (OB_FAIL(SYS_TASK_STATUS_MGR.is_task_cancel(task_id_, is_cancel))) { + STORAGE_LOG(ERROR, "failed to check is task canceled", K(ret), K(*this)); + } else if (is_cancel) { + ret = OB_CANCELED; + STORAGE_LOG(WARN, "task is cancelled", K(ret), K(*this)); } else { ObIPartitionGroupGuard guard; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; if (OB_FAIL(ObPartitionService::get_instance().get_partition(pg_key, guard))) { LOG_WARN("failed to get partition guard", K(ret), K(pg_key)); } else if (OB_ISNULL(partition_group = guard.get_partition_group())) { @@ -714,6 +744,17 @@ int ObPartGroupBackupTask::check_pg_backup_point_created( LOG_WARN("failed to check backup point exist", K(ret), K(pg_key)); } } + +#ifdef ERRSIM + if (OB_SUCC(ret)) { + ret = E(EventTable::EN_BACKUP_CHECK_BACKUP_POINT_EXIST) OB_SUCCESS; + if (OB_SUCCESS != ret) { + is_exist = false; + ret = OB_SUCCESS; + } + } +#endif + if (OB_FAIL(ret)) { } else if (is_exist) { break; @@ -766,6 +807,72 @@ int ObPartGroupBackupTask::check_disk_space() return ret; } +int ObPartGroupBackupTask::check_before_backup() +{ + int ret = OB_SUCCESS; + ObExternBackupInfoMgr extern_backup_info_mgr; + ObClusterBackupDest cluster_backup_dest; + ObBackupDest backup_dest; + ObFakeBackupLeaseService fake_backup_lease_service; + ObExternBackupInfo last_backup_info; + if (!is_inited_) { + ret = OB_NOT_INIT; + STORAGE_LOG(WARN, "not inited", K(ret)); + } else if (BACKUP_REPLICA_OP != type_) { + ret = OB_INVALID_ARGUMENT; + STORAGE_LOG(WARN, "replica op is not backup, no need check", K(ret)); + } else { + const ObPhysicalBackupArg &backup_arg = task_list_[0].arg_.backup_arg_; + const uint64_t tenant_id = task_list_[0].arg_.key_.get_tenant_id(); + if (OB_FAIL(backup_dest.set(backup_arg.uri_header_, backup_arg.storage_info_))) { + STORAGE_LOG(WARN, "failed to set backup dest", K(ret), K(backup_arg)); + } else if (OB_FAIL(cluster_backup_dest.set(backup_dest, backup_arg.incarnation_))) { + STORAGE_LOG(WARN, "failed to set cluster backup dest", K(ret), K(backup_dest)); + } else if (OB_FAIL(extern_backup_info_mgr.init(tenant_id, cluster_backup_dest, fake_backup_lease_service))) { + STORAGE_LOG(WARN, "failed to init extern backup info", K(ret), K(cluster_backup_dest)); + } else if (OB_FAIL(extern_backup_info_mgr.get_last_info(last_backup_info))) { + STORAGE_LOG(WARN, "failed to get last info", K(ret), K(cluster_backup_dest)); + } else if (!last_backup_info.is_valid() || ObExternBackupInfo::DOING != last_backup_info.status_ || + last_backup_info.backup_data_version_ != backup_arg.backup_data_version_ || + last_backup_info.backup_schema_version_ != backup_arg.backup_schema_version_ || + last_backup_info.backup_type_ != backup_arg.backup_type_ || + last_backup_info.inc_backup_set_id_ != backup_arg.backup_set_id_) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("last backup info is unexpected", K(ret), K(last_backup_info), K(backup_arg)); + } + } + return ret; +} + +int ObPartGroupBackupTask::update_backup_data_statics() +{ + int ret = OB_SUCCESS; + common::SpinWLockGuard guard(lock_); + if (data_statics_array_.count() != task_list_.count()) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("data statics array count are not same with task list", + K(ret), + K(data_statics_array_.count()), + K(task_list_.count())); + } else { + for (int64_t i = 0; i < task_list_.count(); ++i) { + const ObPartMigrationTask &task = task_list_.at(i); + ObPartitionMigrationDataStatics &data_statics = data_statics_array_.at(i); + data_statics.buf_minor_count_ += task.ctx_.data_statics_.buf_minor_count_; + data_statics.input_bytes_ += task.ctx_.data_statics_.input_bytes_; + data_statics.major_count_ += task.ctx_.data_statics_.major_count_; + data_statics.mini_minor_count_ += task.ctx_.data_statics_.mini_minor_count_; + data_statics.normal_minor_count_ += task.ctx_.data_statics_.normal_minor_count_; + data_statics.output_bytes_ += task.ctx_.data_statics_.output_bytes_; + data_statics.ready_macro_block_ += task.ctx_.data_statics_.ready_macro_block_; + data_statics.reuse_count_ += task.ctx_.data_statics_.reuse_count_; + data_statics.total_macro_block_ += task.ctx_.data_statics_.total_macro_block_; + data_statics.finish_partition_count_ += task.ctx_.data_statics_.finish_partition_count_; + } + } + return ret; +} + ObBackupPrepareTask::ObBackupPrepareTask() : ObITask(TASK_TYPE_MIGRATE_PREPARE), is_inited_(false), @@ -785,8 +892,8 @@ ObBackupPrepareTask::~ObBackupPrepareTask() } } -int ObBackupPrepareTask::init(ObIPartitionComponentFactory& cp_fty, - common::ObInOutBandwidthThrottle& bandwidth_throttle, ObPartitionService& partition_service) +int ObBackupPrepareTask::init(ObIPartitionComponentFactory &cp_fty, + common::ObInOutBandwidthThrottle &bandwidth_throttle, ObPartitionService &partition_service) { int ret = OB_SUCCESS; @@ -797,7 +904,7 @@ int ObBackupPrepareTask::init(ObIPartitionComponentFactory& cp_fty, ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); is_inited_ = true; bandwidth_throttle_ = &bandwidth_throttle; partition_service_ = &partition_service; @@ -827,7 +934,7 @@ int ObBackupPrepareTask::process() { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; - ObITask* last_task = nullptr; + ObITask *last_task = nullptr; if (NULL != ctx_) { ctx_->action_ = ObMigrateCtx::PREPARE; if (NULL != dag_) { @@ -898,6 +1005,8 @@ int ObBackupPrepareTask::prepare_backup() } else if (OB_FAIL(build_backup_pg_partition_info())) { LOG_WARN("failed to build backup pg partition info", K(ret), K(*ctx_)); } else { + ATOMIC_AAF(&ctx_->data_statics_.partition_count_, ctx_->pg_meta_.partitions_.count() - 1); // skip trans + // partition ctx_->need_rebuild_ = false; ObTaskController::get().allow_next_syslog(); STORAGE_LOG(INFO, "finish prepare backup", "pkey", ctx_->replica_op_arg_.key_, K(*ctx_)); @@ -912,7 +1021,7 @@ int ObBackupPrepareTask::prepare_backup() return ret; } -int ObBackupPrepareTask::add_backup_status(ObMigrateCtx* ctx) +int ObBackupPrepareTask::add_backup_status(ObMigrateCtx *ctx) { int ret = OB_SUCCESS; @@ -933,7 +1042,7 @@ int ObBackupPrepareTask::add_backup_status(ObMigrateCtx* ctx) return ret; } -int ObBackupPrepareTask::add_partition_backup_status(const ObMigrateCtx& ctx) +int ObBackupPrepareTask::add_partition_backup_status(const ObMigrateCtx &ctx) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -976,12 +1085,12 @@ int ObBackupPrepareTask::add_partition_backup_status(const ObMigrateCtx& ctx) int ObBackupPrepareTask::build_backup_prepare_context() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGStorage* pg_storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGStorage *pg_storage = NULL; int64_t trans_table_end_log_ts = 0; int64_t trans_table_timestamp = 0; ObPartitionGroupMeta local_pg_meta; - ObPartGroupMigrationTask* group_task = NULL; + ObPartGroupMigrationTask *group_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1025,7 +1134,7 @@ int ObBackupPrepareTask::build_backup_prepare_context() int ObBackupPrepareTask::build_backup_pg_partition_info() { int ret = OB_SUCCESS; - ObIPGPartitionBaseDataMetaObReader* reader = NULL; + ObIPGPartitionBaseDataMetaObReader *reader = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1042,15 +1151,15 @@ int ObBackupPrepareTask::build_backup_pg_partition_info() return ret; } -int ObBackupPrepareTask::build_backup_partition_info(const ObPGPartitionMetaInfo& partition_meta_info, - const common::ObIArray& table_info_res, - const common::ObIArray& table_id_list, ObPartitionMigrateCtx& part_migrate_ctx) +int ObBackupPrepareTask::build_backup_partition_info(const ObPGPartitionMetaInfo &partition_meta_info, + const common::ObIArray &table_info_res, + const common::ObIArray &table_id_list, ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; ObMigrateTableInfo table_info; int64_t cost_ts = ObTimeUtility::current_time(); - const ObPartitionKey& pkey = partition_meta_info.meta_.pkey_; - ObMigratePartitionInfo& info = part_migrate_ctx.copy_info_; + const ObPartitionKey &pkey = partition_meta_info.meta_.pkey_; + ObMigratePartitionInfo &info = part_migrate_ctx.copy_info_; part_migrate_ctx.ctx_ = ctx_; DEBUG_SYNC(BEFORE_BUILD_MIGRATE_PARTITION_INFO); @@ -1065,7 +1174,7 @@ int ObBackupPrepareTask::build_backup_partition_info(const ObPGPartitionMetaInfo } else { for (int64_t i = 0; OB_SUCC(ret) && i < table_info_res.count(); ++i) { table_info.reuse(); - const obrpc::ObFetchTableInfoResult& table_res = table_info_res.at(i); + const obrpc::ObFetchTableInfoResult &table_res = table_info_res.at(i); const uint64_t table_id = table_id_list.at(i); LOG_INFO("build_backup_partition_info for table", "table_id", table_id); @@ -1092,21 +1201,21 @@ int ObBackupPrepareTask::build_backup_partition_info(const ObPGPartitionMetaInfo return ret; } -int ObBackupPrepareTask::build_backup_table_info(const uint64_t table_id, const ObPartitionKey& pkey, - const obrpc::ObFetchTableInfoResult& result, ObMigrateTableInfo& info) +int ObBackupPrepareTask::build_backup_table_info(const uint64_t table_id, const ObPartitionKey &pkey, + const obrpc::ObFetchTableInfoResult &result, ObMigrateTableInfo &info) { int ret = OB_SUCCESS; - const ObIArray& local_tables_info = result.table_keys_; + const ObIArray &local_tables_info = result.table_keys_; int64_t need_reserve_major_snapshot; info.reuse(); info.table_id_ = table_id; - ObBackupDag* backup_dag = NULL; + ObBackupDag *backup_dag = NULL; ObBackupDataType backup_data_type; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); - } else if (OB_ISNULL(backup_dag = reinterpret_cast(get_dag()))) { + } else if (OB_ISNULL(backup_dag = reinterpret_cast(get_dag()))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("failed to get backup dag", K(ret)); } else if (FALSE_IT(backup_data_type = backup_dag->get_backup_data_type())) { @@ -1137,7 +1246,7 @@ int ObBackupPrepareTask::schedule_backup_tasks() int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; bool need_schedule = false; - ObArray last_task_array; + ObArray last_task_array; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1153,7 +1262,7 @@ int ObBackupPrepareTask::schedule_backup_tasks() } int ObBackupPrepareTask::build_backup_major_sstable( - const ObIArray& local_tables, ObIArray& copy_sstables) + const ObIArray &local_tables, ObIArray ©_sstables) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -1161,7 +1270,7 @@ int ObBackupPrepareTask::build_backup_major_sstable( LOG_WARN("backup prepare task do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < local_tables.count(); ++i) { - const ObITable::TableKey& local_table = local_tables.at(i); + const ObITable::TableKey &local_table = local_tables.at(i); if (local_table.is_major_sstable()) { ObMigrateTableInfo::SSTableInfo info; info.src_table_key_ = local_table; @@ -1181,7 +1290,7 @@ int ObBackupPrepareTask::build_backup_major_sstable( } int ObBackupPrepareTask::build_backup_minor_sstable( - const ObIArray& local_tables, ObIArray& copy_sstables) + const ObIArray &local_tables, ObIArray ©_sstables) { int ret = OB_SUCCESS; ObArray tmp_copy_sstables; @@ -1191,7 +1300,7 @@ int ObBackupPrepareTask::build_backup_minor_sstable( } else { ObMigrateTableInfo::SSTableInfo info; for (int64_t i = 0; OB_SUCC(ret) && i < local_tables.count(); ++i) { - const ObITable::TableKey& local_table = local_tables.at(i); + const ObITable::TableKey &local_table = local_tables.at(i); if (local_table.is_minor_sstable()) { info.reset(); info.src_table_key_ = local_table; @@ -1210,10 +1319,10 @@ int ObBackupPrepareTask::build_backup_minor_sstable( return ret; } -int ObBackupPrepareTask::generate_pg_backup_tasks(ObIArray& last_task_array) +int ObBackupPrepareTask::generate_pg_backup_tasks(ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); @@ -1231,10 +1340,10 @@ int ObBackupPrepareTask::generate_pg_backup_tasks(ObIArray& last_task_ return ret; } -int ObBackupPrepareTask::generate_backup_tasks(ObITask*& last_task) +int ObBackupPrepareTask::generate_backup_tasks(ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_backup_finish_task = NULL; + ObFakeTask *wait_backup_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1254,10 +1363,10 @@ int ObBackupPrepareTask::generate_backup_tasks(ObITask*& last_task) return ret; } -int ObBackupPrepareTask::generate_backup_tasks(ObFakeTask& wait_backup_finish_task) +int ObBackupPrepareTask::generate_backup_tasks(ObFakeTask &wait_backup_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1270,10 +1379,10 @@ int ObBackupPrepareTask::generate_backup_tasks(ObFakeTask& wait_backup_finish_ta return ret; } -int ObBackupPrepareTask::generate_backup_sstable_tasks(share::ObITask*& parent_task) +int ObBackupPrepareTask::generate_backup_sstable_tasks(share::ObITask *&parent_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_finish_task = NULL; + ObFakeTask *wait_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate prepare task do not init", K(ret)); @@ -1293,11 +1402,11 @@ int ObBackupPrepareTask::generate_backup_sstable_tasks(share::ObITask*& parent_t return ret; } -int ObBackupPrepareTask::generate_backup_sstable_copy_task(ObITask* parent_task, ObITask* child_task) +int ObBackupPrepareTask::generate_backup_sstable_copy_task(ObITask *parent_task, ObITask *child_task) { int ret = OB_SUCCESS; - ObBackupCopyPhysicalTask* copy_task = NULL; - ObBackupFinishTask* finish_task = NULL; + ObBackupCopyPhysicalTask *copy_task = NULL; + ObBackupFinishTask *finish_task = NULL; const int64_t task_idx = 0; if (OB_UNLIKELY(!is_inited_)) { @@ -1346,16 +1455,16 @@ int ObBackupPrepareTask::generate_backup_sstable_copy_task(ObITask* parent_task, return ret; } -int ObBackupPrepareTask::build_backup_physical_ctx(ObBackupPhysicalPGCtx& ctx) +int ObBackupPrepareTask::build_backup_physical_ctx(ObBackupPhysicalPGCtx &ctx) { int ret = OB_SUCCESS; ObBackupDataType backup_data_type; - ObBackupDag* backup_dag = NULL; + ObBackupDag *backup_dag = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); - } else if (OB_ISNULL(backup_dag = reinterpret_cast(get_dag()))) { + } else if (OB_ISNULL(backup_dag = reinterpret_cast(get_dag()))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("failed to get backup dag", K(ret)); } else if (FALSE_IT(backup_data_type = backup_dag->get_backup_data_type())) { @@ -1377,7 +1486,7 @@ int ObBackupPrepareTask::build_backup_physical_ctx(ObBackupPhysicalPGCtx& ctx) } int ObBackupPrepareTask::fetch_backup_sstables( - const ObBackupDataType& backup_data_type, ObIArray& table_keys) + const ObBackupDataType &backup_data_type, ObIArray &table_keys) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1400,7 +1509,7 @@ int ObBackupPrepareTask::fetch_backup_sstables( return ret; } -int ObBackupPrepareTask::fetch_backup_major_sstables(ObIArray& table_keys) +int ObBackupPrepareTask::fetch_backup_major_sstables(ObIArray &table_keys) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1409,19 +1518,19 @@ int ObBackupPrepareTask::fetch_backup_major_sstables(ObIArraypart_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_migrate_ctx = ctx_->part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_migrate_ctx = ctx_->part_ctx_array_.at(i); if (OB_LIKELY(!part_migrate_ctx.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("part_migrate_ctx is invalid", K(ret), K(part_migrate_ctx)); } else { // tables - const ObArray& table_infos = part_migrate_ctx.copy_info_.table_infos_; + const ObArray &table_infos = part_migrate_ctx.copy_info_.table_infos_; for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) { - const ObMigrateTableInfo& table_info = table_infos.at(i); + const ObMigrateTableInfo &table_info = table_infos.at(i); // major sstables for (int64_t sstable_idx = 0; OB_SUCC(ret) && sstable_idx < table_info.major_sstables_.count(); ++sstable_idx) { - const ObITable::TableKey& major_table_key = table_info.major_sstables_.at(sstable_idx).src_table_key_; + const ObITable::TableKey &major_table_key = table_info.major_sstables_.at(sstable_idx).src_table_key_; if (OB_UNLIKELY(!major_table_key.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid major table key", K(ret), K(major_table_key)); @@ -1439,7 +1548,7 @@ int ObBackupPrepareTask::fetch_backup_major_sstables(ObIArray& table_keys) +int ObBackupPrepareTask::fetch_backup_minor_sstables(ObIArray &table_keys) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1448,19 +1557,19 @@ int ObBackupPrepareTask::fetch_backup_minor_sstables(ObIArraypart_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_migrate_ctx = ctx_->part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_migrate_ctx = ctx_->part_ctx_array_.at(i); if (OB_LIKELY(!part_migrate_ctx.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("part_migrate_ctx is invalid", K(ret), K(part_migrate_ctx)); } else { // tables - const ObArray& table_infos = part_migrate_ctx.copy_info_.table_infos_; + const ObArray &table_infos = part_migrate_ctx.copy_info_.table_infos_; for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) { - const ObMigrateTableInfo& table_info = table_infos.at(i); + const ObMigrateTableInfo &table_info = table_infos.at(i); // minor sstables for (int64_t sstable_idx = 0; OB_SUCC(ret) && sstable_idx < table_info.minor_sstables_.count(); ++sstable_idx) { - const ObITable::TableKey& minor_table_key = table_info.minor_sstables_.at(sstable_idx).src_table_key_; + const ObITable::TableKey &minor_table_key = table_info.minor_sstables_.at(sstable_idx).src_table_key_; if (OB_UNLIKELY(!minor_table_key.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid major table key", K(ret), K(minor_table_key)); @@ -1478,7 +1587,7 @@ int ObBackupPrepareTask::fetch_backup_minor_sstables(ObIArray BackupTableIndexMap; ObPartGroupBackupTask(); virtual ~ObPartGroupBackupTask(); - int init(const common::ObIArray& task_list, const bool is_batch_mode, - storage::ObPartitionService* partition_service, const share::ObTaskId& task_id); + int init(const common::ObIArray &task_list, const bool is_batch_mode, + storage::ObPartitionService *partition_service, const share::ObTaskId &task_id); int check_before_do_task(); // only invoked before executing, so without concurrency invoke virtual int do_task(); virtual Type get_task_type() const @@ -57,27 +57,30 @@ public: private: int check_partition_validation(); // only invoked before executing, so without concurrency invoke + int check_before_backup(); int do_part_group_backup_minor_task(); int do_part_group_backup_major_task(); int do_backup_pg_metas(); - int do_backup_task(const share::ObBackupDataType& backup_data_type); + int do_backup_task(const share::ObBackupDataType &backup_data_type); - int set_task_list_result(const int32_t first_error_code, const common::ObIArray& task_list); + int set_task_list_result(const int32_t first_error_code, const common::ObIArray &task_list); int finish_group_backup_task(); int init_backup_minor_task( - const bool is_batch_mode, storage::ObPartitionService* partition_service, const share::ObTaskId& task_id); - int try_schedule_new_partition_backup(const share::ObBackupDataType& backup_data_type); - int try_finish_group_backup(bool& is_finished); - int schedule_backup_dag(const share::ObBackupDataType& backup_data_type, ObMigrateCtx& migrate_ctx); - int inner_schedule_partition(ObPartMigrationTask*& task, bool& need_schedule); - int try_schedule_partition_backup(const share::ObBackupDataType& backup_data_type); + const bool is_batch_mode, storage::ObPartitionService *partition_service, const share::ObTaskId &task_id); + int try_schedule_new_partition_backup(const share::ObBackupDataType &backup_data_type); + int try_finish_group_backup(bool &is_finished); + int schedule_backup_dag(const share::ObBackupDataType &backup_data_type, ObMigrateCtx &migrate_ctx); + int inner_schedule_partition(ObPartMigrationTask *&task, bool &need_schedule); + int try_schedule_partition_backup(const share::ObBackupDataType &backup_data_type); void reset_tasks_status(); int check_all_pg_backup_point_created(); - int check_pg_backup_point_created(const ObPartitionKey& pg_key, const int64_t backup_snapshot_version); + int check_pg_backup_point_created(const ObPartitionKey &pg_key, const int64_t backup_snapshot_version); int check_disk_space(); + int update_backup_data_statics(); private: share::ObBackupDataType backup_data_type_; + ObArray data_statics_array_; DISALLOW_COPY_AND_ASSIGN(ObPartGroupBackupTask); }; @@ -86,61 +89,61 @@ public: typedef common::hash::ObHashMap MacroPairMap; ObBackupPrepareTask(); virtual ~ObBackupPrepareTask(); - int init(ObIPartitionComponentFactory& cp_fty, common::ObInOutBandwidthThrottle& bandwidth_throttle, - ObPartitionService& partition_service); + int init(ObIPartitionComponentFactory &cp_fty, common::ObInOutBandwidthThrottle &bandwidth_throttle, + ObPartitionService &partition_service); virtual int process() override; protected: - int add_backup_status(ObMigrateCtx* ctx); - int add_partition_backup_status(const ObMigrateCtx& ctx); + int add_backup_status(ObMigrateCtx *ctx); + int add_partition_backup_status(const ObMigrateCtx &ctx); int prepare_backup(); int build_backup_prepare_context(); int schedule_backup_tasks(); int fetch_partition_group_info( - const ObReplicaOpArg& arg, const ObMigrateSrcInfo& src_info, ObPartitionGroupInfoResult& result); + const ObReplicaOpArg &arg, const ObMigrateSrcInfo &src_info, ObPartitionGroupInfoResult &result); int build_backup_pg_partition_info(); - int build_backup_partition_info(const obrpc::ObPGPartitionMetaInfo& partition_meta_info, - const common::ObIArray& table_info_res, - const common::ObIArray& table_id_list, ObPartitionMigrateCtx& part_migrate_ctx); + int build_backup_partition_info(const obrpc::ObPGPartitionMetaInfo &partition_meta_info, + const common::ObIArray &table_info_res, + const common::ObIArray &table_id_list, ObPartitionMigrateCtx &part_migrate_ctx); - int build_backup_table_info(const uint64_t table_id, const ObPartitionKey& pkey, - const obrpc::ObFetchTableInfoResult& result, ObMigrateTableInfo& info); - int check_remote_sstables(const uint64_t table_id, common::ObIArray& remote_major_sstables, - common::ObIArray& remote_inc_tbales); + int build_backup_table_info(const uint64_t table_id, const ObPartitionKey &pkey, + const obrpc::ObFetchTableInfoResult &result, ObMigrateTableInfo &info); + int check_remote_sstables(const uint64_t table_id, common::ObIArray &remote_major_sstables, + common::ObIArray &remote_inc_tbales); int check_remote_inc_sstables_continuity( - const int64_t last_major_snapshot_version, common::ObIArray& remote_inc_tables); - int build_backup_major_sstable(const common::ObIArray& local_tables, - common::ObIArray& copy_sstables); - int build_backup_minor_sstable(const common::ObIArray& local_tables, - common::ObIArray& copy_sstables); - int generate_wait_backup_finish_task(share::ObFakeTask*& wait_backup_finish_task); - int generate_pg_backup_tasks(common::ObIArray& last_task_array); - int generate_backup_tasks(ObITask*& last_task); - int generate_backup_tasks(share::ObFakeTask& wait_migrate_finish_task); - int generate_backup_sstable_tasks(share::ObITask*& parent_task); - int generate_backup_sstable_copy_task(ObITask* parent_task, ObITask* child_task); - int build_backup_physical_ctx(ObBackupPhysicalPGCtx& ctx); - int fetch_backup_sstables(const share::ObBackupDataType& backup_data_type, ObIArray& table_keys); - int fetch_backup_major_sstables(ObIArray& table_keys); - int fetch_backup_minor_sstables(ObIArray& table_keys); + const int64_t last_major_snapshot_version, common::ObIArray &remote_inc_tables); + int build_backup_major_sstable(const common::ObIArray &local_tables, + common::ObIArray ©_sstables); + int build_backup_minor_sstable(const common::ObIArray &local_tables, + common::ObIArray ©_sstables); + int generate_wait_backup_finish_task(share::ObFakeTask *&wait_backup_finish_task); + int generate_pg_backup_tasks(common::ObIArray &last_task_array); + int generate_backup_tasks(ObITask *&last_task); + int generate_backup_tasks(share::ObFakeTask &wait_migrate_finish_task); + int generate_backup_sstable_tasks(share::ObITask *&parent_task); + int generate_backup_sstable_copy_task(ObITask *parent_task, ObITask *child_task); + int build_backup_physical_ctx(ObBackupPhysicalPGCtx &ctx); + int fetch_backup_sstables(const share::ObBackupDataType &backup_data_type, ObIArray &table_keys); + int fetch_backup_major_sstables(ObIArray &table_keys); + int fetch_backup_minor_sstables(ObIArray &table_keys); - int build_backup_sub_task(ObBackupPhysicalPGCtx& ctx); + int build_backup_sub_task(ObBackupPhysicalPGCtx &ctx); int prepare_backup_reader(); - int build_table_partition_info(const ObReplicaOpArg& arg, ObIPGPartitionBaseDataMetaObReader* reader); - int get_partition_table_info_reader(const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader); + int build_table_partition_info(const ObReplicaOpArg &arg, ObIPGPartitionBaseDataMetaObReader *reader); + int get_partition_table_info_reader(const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader); int inner_get_partition_table_info_reader( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader); + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader); int get_partition_table_info_backup_reader( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader); + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader); int check_backup_data_continues(); protected: bool is_inited_; - ObMigrateCtx* ctx_; - ObIPartitionComponentFactory* cp_fty_; - common::ObInOutBandwidthThrottle* bandwidth_throttle_; - ObPartitionService* partition_service_; - ObPartitionGroupMetaBackupReader* backup_meta_reader_; + ObMigrateCtx *ctx_; + ObIPartitionComponentFactory *cp_fty_; + common::ObInOutBandwidthThrottle *bandwidth_throttle_; + ObPartitionService *partition_service_; + ObPartitionGroupMetaBackupReader *backup_meta_reader_; private: DISALLOW_COPY_AND_ASSIGN(ObBackupPrepareTask); diff --git a/src/storage/ob_partition_base_data_backup.cpp b/src/storage/ob_partition_base_data_backup.cpp index 9075066e25abc2533c14e56a715865be831abf8d..8f8327308d0d7c58793e8469832f428f293e7762 100644 --- a/src/storage/ob_partition_base_data_backup.cpp +++ b/src/storage/ob_partition_base_data_backup.cpp @@ -3822,6 +3822,7 @@ int ObBackupFinishTask::init(ObMigrateCtx& ctx) int ObBackupFinishTask::process() { int ret = OB_SUCCESS; + ObBackupDataType data_type; if (NULL != ctx_) { STORAGE_LOG(INFO, "start ObBackupFinishTask process", "pkey", ctx_->replica_op_arg_.key_); @@ -3829,12 +3830,15 @@ int ObBackupFinishTask::process() if (!is_inited_) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "not inited", K(ret)); + } else if(FALSE_IT(data_type.type_ = ctx_->physical_backup_ctx_.get_backup_data_type())) { } else if (OB_FAIL(ctx_->physical_backup_ctx_.close())) { STORAGE_LOG(WARN, "failed to close physical backup ctx", K(ret), "pkey", ctx_->replica_op_arg_.key_); } else { const int64_t end_macro_index_pos = ctx_->physical_backup_ctx_.macro_index_appender_.get_upload_size(); ctx_->data_statics_.output_bytes_ += end_macro_index_pos; - ctx_->data_statics_.finish_partition_count_ = ctx_->data_statics_.partition_count_; + if (data_type.is_major_backup()) { + ctx_->data_statics_.finish_partition_count_ = ctx_->data_statics_.partition_count_; + } STORAGE_LOG(INFO, "backup task finished", K(ctx_->pg_meta_)); } diff --git a/src/storage/ob_partition_base_data_physical_restore.cpp b/src/storage/ob_partition_base_data_physical_restore.cpp index ed943d42923d3b2ab5f992a04df9d1947df5c66e..ff2c4389297237dd4472290f7732743a55eff4c1 100644 --- a/src/storage/ob_partition_base_data_physical_restore.cpp +++ b/src/storage/ob_partition_base_data_physical_restore.cpp @@ -25,7 +25,7 @@ using namespace blocksstable; /***********************ObPhyRestoreMetaIndexStore***************************/ int ObRestoreFileUtil::read_one_file( - const ObString& path, const ObString& storage_info, ObIAllocator& allocator, char*& buf, int64_t& read_size) + const ObString &path, const ObString &storage_info, ObIAllocator &allocator, char *&buf, int64_t &read_size) { int ret = OB_SUCCESS; ObStorageUtil util(true /*need retry*/); @@ -42,7 +42,7 @@ int ObRestoreFileUtil::read_one_file( STORAGE_LOG(INFO, "current index file is empty", K(path), K(file_len)); } else { buffer_len = file_len + 1; // last for '\0' - if (OB_ISNULL(buf = static_cast(allocator.alloc(buffer_len)))) { + if (OB_ISNULL(buf = static_cast(allocator.alloc(buffer_len)))) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "fail to alloc memory", K(ret), K(file_len), K(buffer_len)); } else if (OB_FAIL(util.read_single_file(path, storage_info, buf, file_len, read_size))) { @@ -58,7 +58,7 @@ int ObRestoreFileUtil::read_one_file( } int ObRestoreFileUtil::pread_file( - const ObString& path, const ObString& storage_info, const int64_t offset, const int64_t read_size, char* buf) + const ObString &path, const ObString &storage_info, const int64_t offset, const int64_t read_size, char *buf) { int ret = OB_SUCCESS; ObStorageUtil util(true /*need retry*/); @@ -78,18 +78,18 @@ int ObRestoreFileUtil::pread_file( return ret; } -int ObRestoreFileUtil::read_partition_group_meta(const ObString& path, const ObString& storage_info, - const ObBackupMetaIndex& meta_index, ObPartitionGroupMeta& pg_meta) +int ObRestoreFileUtil::read_partition_group_meta(const ObString &path, const ObString &storage_info, + const ObBackupMetaIndex &meta_index, ObPartitionGroupMeta &pg_meta) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; if (OB_UNLIKELY(meta_index.meta_type_ != ObBackupMetaType::PARTITION_GROUP_META)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "meta index type not match", K(ret), K(meta_index)); } else if (OB_FAIL(meta_index.check_valid())) { STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -99,7 +99,7 @@ int ObRestoreFileUtil::read_partition_group_meta(const ObString& path, const ObS const int64_t read_size = meta_index.data_length_; int64_t pos = 0; ObBufferReader buffer_reader; - const ObBackupMetaHeader* meta_header = NULL; + const ObBackupMetaHeader *meta_header = NULL; if (OB_FAIL(buffer_reader.deserialize(read_buf, read_size, pos))) { LOG_WARN("failed to deserialize buffer reader", K(ret), K(read_size), K(pos), K(meta_index), K(path)); } else if (OB_FAIL(buffer_reader.get(meta_header))) { @@ -124,19 +124,19 @@ int ObRestoreFileUtil::read_partition_group_meta(const ObString& path, const ObS return ret; } -int ObRestoreFileUtil::read_partition_meta(const ObString& path, const ObString& storage_info, - const ObBackupMetaIndex& meta_index, const int64_t& compatible, storage::ObPGPartitionStoreMeta& partition_meta) +int ObRestoreFileUtil::read_partition_meta(const ObString &path, const ObString &storage_info, + const ObBackupMetaIndex &meta_index, const int64_t &compatible, storage::ObPGPartitionStoreMeta &partition_meta) { { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; if (OB_UNLIKELY(meta_index.meta_type_ != ObBackupMetaType::PARTITION_META)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "meta index type not match", K(ret), K(meta_index)); } else if (OB_FAIL(meta_index.check_valid())) { STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -146,7 +146,7 @@ int ObRestoreFileUtil::read_partition_meta(const ObString& path, const ObString& const int64_t read_size = meta_index.data_length_; int64_t pos = 0; ObBufferReader buffer_reader; - const ObBackupMetaHeader* meta_header = NULL; + const ObBackupMetaHeader *meta_header = NULL; if (OB_FAIL(buffer_reader.deserialize(read_buf, read_size, pos))) { LOG_WARN("failed to deserialize buffer reader", K(ret), K(read_size), K(pos), K(meta_index), K(path)); @@ -189,20 +189,20 @@ int ObRestoreFileUtil::read_partition_meta(const ObString& path, const ObString& } } -int ObRestoreFileUtil::read_sstable_metas(const ObString& path, const ObString& storage_info, - const ObBackupMetaIndex& meta_index, common::ObArenaAllocator& meta_allocator, - common::ObIArray& sstable_info_array) +int ObRestoreFileUtil::read_sstable_metas(const ObString &path, const ObString &storage_info, + const ObBackupMetaIndex &meta_index, common::ObArenaAllocator &meta_allocator, + common::ObIArray &sstable_info_array) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; sstable_info_array.reuse(); if (OB_UNLIKELY(meta_index.meta_type_ != ObBackupMetaType::SSTABLE_METAS)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "meta index type not match", K(ret), K(meta_index)); } else if (OB_FAIL(meta_index.check_valid())) { STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -213,7 +213,7 @@ int ObRestoreFileUtil::read_sstable_metas(const ObString& path, const ObString& int64_t table_count = 0; int64_t pos = 0; ObBufferReader buffer_reader; - const ObBackupMetaHeader* meta_header = NULL; + const ObBackupMetaHeader *meta_header = NULL; if (OB_FAIL(buffer_reader.deserialize(read_buf, read_size, pos))) { LOG_WARN("failed to deserialize buffer reader", K(ret), K(read_size), K(pos), K(meta_index), K(path)); @@ -250,18 +250,18 @@ int ObRestoreFileUtil::read_sstable_metas(const ObString& path, const ObString& return ret; } -int ObRestoreFileUtil::read_table_keys(const ObString& path, const ObString& storage_info, - const ObBackupMetaIndex& meta_index, common::ObIArray& table_keys) +int ObRestoreFileUtil::read_table_keys(const ObString &path, const ObString &storage_info, + const ObBackupMetaIndex &meta_index, common::ObIArray &table_keys) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; if (OB_UNLIKELY(meta_index.meta_type_ != ObBackupMetaType::TABLE_KEYS)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "meta index type not match", K(ret), K(meta_index)); } else if (OB_FAIL(meta_index.check_valid())) { STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -272,7 +272,7 @@ int ObRestoreFileUtil::read_table_keys(const ObString& path, const ObString& sto int64_t table_count = 0; int64_t pos = 0; ObBufferReader buffer_reader; - const ObBackupMetaHeader* meta_header = NULL; + const ObBackupMetaHeader *meta_header = NULL; storage::ObITable::TableKey table_key; if (OB_FAIL(buffer_reader.deserialize(read_buf, read_size, pos))) { @@ -308,19 +308,19 @@ int ObRestoreFileUtil::read_table_keys(const ObString& path, const ObString& sto return ret; } -int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString& storage_info, - const ObBackupMacroIndex& meta_index, common::ObArenaAllocator& allocator, ObMacroBlockSchemaInfo*& new_schema, - ObMacroBlockMetaV2*& new_meta, blocksstable::ObBufferReader& macro_data) +int ObRestoreFileUtil::read_macroblock_data(const ObString &path, const ObString &storage_info, + const ObBackupMacroIndex &meta_index, common::ObArenaAllocator &allocator, ObMacroBlockSchemaInfo *&new_schema, + ObMacroBlockMetaV2 *&new_meta, blocksstable::ObBufferReader ¯o_data) { int ret = OB_SUCCESS; - char* read_buf = NULL; + char *read_buf = NULL; int64_t buf_size = meta_index.data_length_ + DIO_READ_ALIGN_SIZE; new_schema = nullptr; new_meta = nullptr; if (OB_FAIL(meta_index.check_valid())) { STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(buf_size)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(buf_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -328,15 +328,15 @@ int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString STORAGE_LOG(WARN, "fail to pread macro data buffer", K(ret), K(path), K(meta_index)); } else { ObBufferReader buffer_reader(read_buf, meta_index.data_length_); - const ObBackupCommonHeader* common_header = NULL; + const ObBackupCommonHeader *common_header = NULL; blocksstable::ObBufferReader tmp_macro_meta_reader; blocksstable::ObBufferReader tmp_macro_data; ObBackupMacroData backup_macro_data(tmp_macro_meta_reader, tmp_macro_data); - common::ObObj* endkey = NULL; + common::ObObj *endkey = NULL; ObMacroBlockMetaV2 tmp_meta; ObMacroBlockSchemaInfo tmp_schema; ObFullMacroBlockMetaEntry marco_block_meta_entry(tmp_meta, tmp_schema); - if (OB_ISNULL(endkey = reinterpret_cast(allocator.alloc(sizeof(ObObj) * common::OB_MAX_COLUMN_NUMBER)))) { + if (OB_ISNULL(endkey = reinterpret_cast(allocator.alloc(sizeof(ObObj) * common::OB_MAX_COLUMN_NUMBER)))) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "fail to alloc memory for macro block end key", K(ret)); } else if (OB_ISNULL(tmp_meta.endkey_ = new (endkey) ObObj[common::OB_MAX_COLUMN_NUMBER])) { @@ -384,12 +384,12 @@ int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString return ret; } -int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString& storage_info, - const ObBackupTableMacroIndex& meta_index, common::ObArenaAllocator& allocator, ObMacroBlockSchemaInfo*& new_schema, - ObMacroBlockMetaV2*& new_meta, blocksstable::ObBufferReader& macro_data) +int ObRestoreFileUtil::read_macroblock_data(const ObString &path, const ObString &storage_info, + const ObBackupTableMacroIndex &meta_index, common::ObArenaAllocator &allocator, ObMacroBlockSchemaInfo *&new_schema, + ObMacroBlockMetaV2 *&new_meta, blocksstable::ObBufferReader ¯o_data) { int ret = OB_SUCCESS; - char* read_buf = NULL; + char *read_buf = NULL; int64_t buf_size = meta_index.data_length_ + DIO_READ_ALIGN_SIZE; new_schema = nullptr; new_meta = nullptr; @@ -397,7 +397,7 @@ int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString if (!meta_index.is_valid()) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(buf_size)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(buf_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -405,15 +405,15 @@ int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString STORAGE_LOG(WARN, "fail to pread macro data buffer", K(ret), K(path), K(meta_index)); } else { ObBufferReader buffer_reader(read_buf, meta_index.data_length_); - const ObBackupCommonHeader* common_header = NULL; + const ObBackupCommonHeader *common_header = NULL; blocksstable::ObBufferReader tmp_macro_meta_reader; blocksstable::ObBufferReader tmp_macro_data; ObBackupMacroData backup_macro_data(tmp_macro_meta_reader, tmp_macro_data); - common::ObObj* endkey = NULL; + common::ObObj *endkey = NULL; ObMacroBlockMetaV2 tmp_meta; ObMacroBlockSchemaInfo tmp_schema; ObFullMacroBlockMetaEntry marco_block_meta_entry(tmp_meta, tmp_schema); - if (OB_ISNULL(endkey = reinterpret_cast(allocator.alloc(sizeof(ObObj) * common::OB_MAX_COLUMN_NUMBER)))) { + if (OB_ISNULL(endkey = reinterpret_cast(allocator.alloc(sizeof(ObObj) * common::OB_MAX_COLUMN_NUMBER)))) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "fail to alloc memory for macro block end key", K(ret)); } else if (OB_ISNULL(tmp_meta.endkey_ = new (endkey) ObObj[common::OB_MAX_COLUMN_NUMBER])) { @@ -441,6 +441,12 @@ int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString K(backup_macro_data), K(meta_index), K(buffer_reader)); + } else if (is_sys_table(tmp_meta.table_id_)) { + tmp_meta.schema_version_ = 0; + tmp_schema.schema_version_ = 0; + } + + if (OB_FAIL(ret)) { } else if (OB_FAIL(tmp_meta.deep_copy(new_meta, allocator))) { LOG_WARN("failed to copy macro meta", K(ret), K(path), K(meta_index), K(buffer_reader)); } else if (OB_FAIL(tmp_schema.deep_copy(new_schema, allocator))) { @@ -453,8 +459,8 @@ int ObRestoreFileUtil::read_macroblock_data(const ObString& path, const ObString return ret; } -int ObRestoreFileUtil::fetch_max_backup_file_id(const ObString& path, const ObString& storage_info, - const int64_t& backup_set_id, int64_t& max_index_id, int64_t& max_data_id) +int ObRestoreFileUtil::fetch_max_backup_file_id(const ObString &path, const ObString &storage_info, + const int64_t &backup_set_id, int64_t &max_index_id, int64_t &max_data_id) { int ret = OB_SUCCESS; ObStorageUtil util(true /*need retry*/); @@ -480,7 +486,7 @@ int ObRestoreFileUtil::fetch_max_backup_file_id(const ObString& path, const ObSt ret = common::OB_BUF_NOT_ENOUGH; } for (int i = 0; OB_SUCC(ret) && i < file_names.count(); ++i) { - ObString& file_name = file_names.at(i); + ObString &file_name = file_names.at(i); int64_t file_id = -1; if (file_name.prefix_match(index_prefix)) { if (0 == file_name.compare(index_prefix)) { @@ -517,7 +523,7 @@ int ObRestoreFileUtil::fetch_max_backup_file_id(const ObString& path, const ObSt return ret; } -int ObRestoreFileUtil::get_file_id(const ObString& file_name, int64_t& file_id) +int ObRestoreFileUtil::get_file_id(const ObString &file_name, int64_t &file_id) { int ret = OB_SUCCESS; ObString id_str = file_name.after('.').trim(); @@ -534,7 +540,7 @@ int ObRestoreFileUtil::get_file_id(const ObString& file_name, int64_t& file_id) } int ObRestoreFileUtil::limit_bandwidth_and_sleep( - ObInOutBandwidthThrottle& throttle, const int64_t cur_data_size, int64_t& last_read_size) + ObInOutBandwidthThrottle &throttle, const int64_t cur_data_size, int64_t &last_read_size) { int ret = OB_SUCCESS; const int64_t last_active_time = ObTimeUtility::current_time(); @@ -547,18 +553,18 @@ int ObRestoreFileUtil::limit_bandwidth_and_sleep( return ret; } -int ObRestoreFileUtil::read_backup_pg_meta_info(const ObString& path, const ObString& storage_info, - const ObBackupMetaIndex& meta_index, ObBackupPGMetaInfo& backup_pg_meta_info) +int ObRestoreFileUtil::read_backup_pg_meta_info(const ObString &path, const ObString &storage_info, + const ObBackupMetaIndex &meta_index, ObBackupPGMetaInfo &backup_pg_meta_info) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; if (OB_UNLIKELY(ObBackupMetaType::PARTITION_GROUP_META_INFO != meta_index.meta_type_)) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "meta index type not match", K(ret), K(meta_index)); } else if (OB_FAIL(meta_index.check_valid())) { STORAGE_LOG(WARN, "invalid meta index", K(ret), K(meta_index)); - } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { + } else if (OB_ISNULL(read_buf = reinterpret_cast(allocator.alloc(meta_index.data_length_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc read buf", K(ret), K(meta_index)); } else if (OB_FAIL(ObRestoreFileUtil::pread_file( @@ -568,7 +574,7 @@ int ObRestoreFileUtil::read_backup_pg_meta_info(const ObString& path, const ObSt const int64_t read_size = meta_index.data_length_; int64_t pos = 0; ObBufferReader buffer_reader; - const ObBackupMetaHeader* meta_header = NULL; + const ObBackupMetaHeader *meta_header = NULL; if (OB_FAIL(buffer_reader.deserialize(read_buf, read_size, pos))) { LOG_WARN("failed to deserialize buffer reader", K(ret), K(read_size), K(pos), K(meta_index), K(path)); } else if (OB_FAIL(buffer_reader.get(meta_header))) { @@ -608,7 +614,7 @@ void ObPhyRestoreMetaIndexStore::reset() index_map_.clear(); } -int ObPhyRestoreMetaIndexStore::init(const ObBackupBaseDataPathInfo& path_info, const int64_t compatible, +int ObPhyRestoreMetaIndexStore::init(const ObBackupBaseDataPathInfo &path_info, const int64_t compatible, const bool need_check_all_meta_files, const bool need_check_compeleted) { int ret = OB_SUCCESS; @@ -621,7 +627,7 @@ int ObPhyRestoreMetaIndexStore::init(const ObBackupBaseDataPathInfo& path_info, return ret; } -int ObPhyRestoreMetaIndexStore::init(const share::ObSimpleBackupSetPath& simple_path, const int64_t compatible, +int ObPhyRestoreMetaIndexStore::init(const share::ObSimpleBackupSetPath &simple_path, const int64_t compatible, const bool need_check_all_meta_files, const bool need_check_completed) { int ret = OB_SUCCESS; @@ -647,7 +653,7 @@ int ObPhyRestoreMetaIndexStore::init(const share::ObSimpleBackupSetPath& simple_ STORAGE_LOG(WARN, "list files fail", K(ret), K(path)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < all_files_name.count(); ++i) { - ObString& file_name = all_files_name.at(i); + ObString &file_name = all_files_name.at(i); bool is_tmp_file = false; if (OB_FAIL(ObBackupUtils::check_is_tmp_file(file_name, is_tmp_file))) { STORAGE_LOG(WARN, "failed to check is tmp file", K(ret), K(file_name)); @@ -677,7 +683,7 @@ int ObPhyRestoreMetaIndexStore::init(const share::ObSimpleBackupSetPath& simple_ ObBackupPath index_path; for (int i = 0; OB_SUCC(ret) && i < need_index_file.count(); ++i) { index_path.reset(); - ObString& file_name = need_index_file.at(i); + ObString &file_name = need_index_file.at(i); if (OB_FAIL(index_path.init(path.get_obstr()))) { STORAGE_LOG(WARN, "fail to init index base path", K(ret), K(path)); } else if (OB_FAIL(index_path.join(file_name))) { @@ -720,11 +726,11 @@ int ObPhyRestoreMetaIndexStore::init(const share::ObSimpleBackupSetPath& simple_ } int ObPhyRestoreMetaIndexStore::init_one_file( - const ObString& path, const ObString& storage_info, int64_t& file_length, int64_t& total_length) + const ObString &path, const ObString &storage_info, int64_t &file_length, int64_t &total_length) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; file_length = 0; total_length = 0; if (OB_FAIL(ObRestoreFileUtil::read_one_file(path, storage_info, allocator, read_buf, file_length))) { @@ -733,7 +739,7 @@ int ObPhyRestoreMetaIndexStore::init_one_file( STORAGE_LOG(INFO, "may be empty meta index file", K(ret), K(path), K(file_length)); } else { ObBufferReader buffer_reader(read_buf, file_length, 0); - const ObBackupCommonHeader* common_header = NULL; + const ObBackupCommonHeader *common_header = NULL; ObBackupMetaIndex meta_index; while (OB_SUCC(ret) && buffer_reader.remain() > 0) { common_header = NULL; @@ -783,7 +789,7 @@ bool ObPhyRestoreMetaIndexStore::is_inited() const } int ObPhyRestoreMetaIndexStore::get_meta_index( - const ObPartitionKey& part_key, const ObBackupMetaType& type, ObBackupMetaIndex& meta_index) const + const ObPartitionKey &part_key, const ObBackupMetaType &type, ObBackupMetaIndex &meta_index) const { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -802,7 +808,7 @@ int ObPhyRestoreMetaIndexStore::get_meta_index( } int ObPhyRestoreMetaIndexStore::check_meta_index_completed( - const int64_t compatible, const share::ObSimpleBackupSetPath& simple_path) + const int64_t compatible, const share::ObSimpleBackupSetPath &simple_path) { int ret = OB_SUCCESS; ObExternPGListMgr pg_list_mgr; @@ -830,7 +836,7 @@ int ObPhyRestoreMetaIndexStore::check_meta_index_completed( STORAGE_LOG(WARN, "failed to get normal pg list", K(ret), K(simple_path)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pg_key_list.count(); ++i) { - const ObPGKey& pg_key = pg_key_list.at(i); + const ObPGKey &pg_key = pg_key_list.at(i); const share::ObMetaIndexKey key(pg_key.get_table_id(), pg_key.get_partition_id(), type); if (OB_FAIL(index_map_.get_refactored(key, meta_index))) { STORAGE_LOG(WARN, "fail to get meta index", K(ret), K(key)); @@ -840,7 +846,7 @@ int ObPhyRestoreMetaIndexStore::check_meta_index_completed( return ret; } -int ObPhyRestoreMetaIndexStore::get_meta_indexs(ObIArray& backup_meta_indexs) +int ObPhyRestoreMetaIndexStore::get_meta_indexs(ObIArray &backup_meta_indexs) { int ret = OB_SUCCESS; backup_meta_indexs.reset(); @@ -849,7 +855,7 @@ int ObPhyRestoreMetaIndexStore::get_meta_indexs(ObIArray& bac STORAGE_LOG(WARN, "physial restore meta index store do not init", K(ret)); } else { for (MetaIndexMap::const_iterator iter = index_map_.begin(); OB_SUCC(ret) && iter != index_map_.end(); ++iter) { - const ObBackupMetaIndex& meta_index = iter->second; + const ObBackupMetaIndex &meta_index = iter->second; if (OB_FAIL(backup_meta_indexs.push_back(meta_index))) { STORAGE_LOG(WARN, "failed to push meta index into array", K(ret), K(meta_index)); } @@ -858,7 +864,7 @@ int ObPhyRestoreMetaIndexStore::get_meta_indexs(ObIArray& bac return ret; } -int ObPhyRestoreMetaIndexStore::check_meta_exist(const ObBackupMetaIndex& backup_meta_index, bool& is_exist) +int ObPhyRestoreMetaIndexStore::check_meta_exist(const ObBackupMetaIndex &backup_meta_index, bool &is_exist) { int ret = OB_SUCCESS; is_exist = false; @@ -902,7 +908,7 @@ bool ObPhyRestoreMacroIndexStore::is_inited() const return is_inited_; } -int ObPhyRestoreMacroIndexStore::init(const share::ObBackupBackupsetArg& arg) +int ObPhyRestoreMacroIndexStore::init(const share::ObBackupBackupsetArg &arg) { int ret = OB_SUCCESS; bool last_file_complete = false; @@ -927,7 +933,7 @@ int ObPhyRestoreMacroIndexStore::init(const share::ObBackupBackupsetArg& arg) return ret; } -int ObPhyRestoreMacroIndexStore::init(const share::ObBackupBaseDataPathInfo& path_info, const common::ObPGKey& pg_key) +int ObPhyRestoreMacroIndexStore::init(const share::ObBackupBaseDataPathInfo &path_info, const common::ObPGKey &pg_key) { int ret = OB_SUCCESS; bool last_file_complete = false; @@ -949,7 +955,7 @@ int ObPhyRestoreMacroIndexStore::init(const share::ObBackupBaseDataPathInfo& pat } int ObPhyRestoreMacroIndexStore::init( - const share::ObPhysicalRestoreArg& arg, const ObReplicaRestoreStatus& restore_status) + const share::ObPhysicalRestoreArg &arg, const ObReplicaRestoreStatus &restore_status) { int ret = OB_SUCCESS; bool last_file_complete = false; @@ -1000,7 +1006,7 @@ int ObPhyRestoreMacroIndexStore::init( return ret; } -int ObPhyRestoreMacroIndexStore::init(const common::ObPartitionKey& pkey, const share::ObPhysicalBackupArg& arg) +int ObPhyRestoreMacroIndexStore::init(const common::ObPartitionKey &pkey, const share::ObPhysicalBackupArg &arg) { int ret = OB_SUCCESS; bool last_file_complete = false; @@ -1022,8 +1028,8 @@ int ObPhyRestoreMacroIndexStore::init(const common::ObPartitionKey& pkey, const return ret; } -int ObPhyRestoreMacroIndexStore::inner_init(const share::ObBackupBaseDataPathInfo& path_info, const char* mod_id, - const common::ObPGKey& pg_key, bool& last_file_complete) +int ObPhyRestoreMacroIndexStore::inner_init(const share::ObBackupBaseDataPathInfo &path_info, const char *mod_id, + const common::ObPGKey &pg_key, bool &last_file_complete) { int ret = OB_SUCCESS; ObSimpleBackupSetPath simple_path; @@ -1035,8 +1041,8 @@ int ObPhyRestoreMacroIndexStore::inner_init(const share::ObBackupBaseDataPathInf return ret; } -int ObPhyRestoreMacroIndexStore::inner_init(const share::ObSimpleBackupSetPath& simple_path, const char* mod_id, - const common::ObPGKey& pg_key, bool& last_file_complete) +int ObPhyRestoreMacroIndexStore::inner_init(const share::ObSimpleBackupSetPath &simple_path, const char *mod_id, + const common::ObPGKey &pg_key, bool &last_file_complete) { int ret = OB_SUCCESS; last_file_complete = false; @@ -1078,11 +1084,11 @@ int ObPhyRestoreMacroIndexStore::inner_init(const share::ObSimpleBackupSetPath& } int ObPhyRestoreMacroIndexStore::init_one_file( - const ObString& path, const ObString& storage_info, int64_t& file_length, int64_t& total_length) + const ObString &path, const ObString &storage_info, int64_t &file_length, int64_t &total_length) { int ret = OB_SUCCESS; common::ObArenaAllocator allocator(ObModIds::RESTORE); - char* read_buf = NULL; + char *read_buf = NULL; file_length = 0; total_length = 0; if (OB_FAIL(ObRestoreFileUtil::read_one_file(path, storage_info, allocator, read_buf, file_length))) { @@ -1091,7 +1097,7 @@ int ObPhyRestoreMacroIndexStore::init_one_file( STORAGE_LOG(INFO, "may be empty block index file", K(ret), K(path)); } else { ObBufferReader buffer_reader(read_buf, file_length, 0); - const ObBackupCommonHeader* common_header = NULL; + const ObBackupCommonHeader *common_header = NULL; ObBackupMacroIndex macro_index; ObArray index_list; uint64_t cur_index_id = 0; @@ -1167,11 +1173,11 @@ int ObPhyRestoreMacroIndexStore::init_one_file( } int ObPhyRestoreMacroIndexStore::add_sstable_index( - const uint64_t index_id, const common::ObIArray& index_list) + const uint64_t index_id, const common::ObIArray &index_list) { int ret = OB_SUCCESS; - void* buf = NULL; - ObArray* new_block_list = NULL; + void *buf = NULL; + ObArray *new_block_list = NULL; int64_t block_count = index_list.count(); if (0 == block_count) { @@ -1198,7 +1204,7 @@ int ObPhyRestoreMacroIndexStore::add_sstable_index( } for (int i = 0; OB_SUCC(ret) && i < index_list.count(); ++i) { - const ObBackupMacroIndex& index = index_list.at(i); // check + const ObBackupMacroIndex &index = index_list.at(i); // check if (OB_ISNULL(new_block_list)) { // cannot reach here, just for coverage false alarm ret = OB_ERR_UNEXPECTED; @@ -1224,11 +1230,11 @@ int ObPhyRestoreMacroIndexStore::add_sstable_index( } int ObPhyRestoreMacroIndexStore::get_macro_index_array( - const uint64_t index_id, const common::ObArray*& index_list) const + const uint64_t index_id, const common::ObArray *&index_list) const { int ret = OB_SUCCESS; index_list = NULL; - common::ObArray* tmp_list = NULL; + common::ObArray *tmp_list = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "macro index store do not init", K(ret)); @@ -1241,10 +1247,10 @@ int ObPhyRestoreMacroIndexStore::get_macro_index_array( } int ObPhyRestoreMacroIndexStore::get_macro_index( - const uint64_t index_id, const int64_t sstable_macro_idx, ObBackupMacroIndex& macro_index) const + const uint64_t index_id, const int64_t sstable_macro_idx, ObBackupMacroIndex ¯o_index) const { int ret = OB_SUCCESS; - common::ObArray* index_list = NULL; + common::ObArray *index_list = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "macro index store do not init", K(ret)); @@ -1271,10 +1277,10 @@ int ObPhyRestoreMacroIndexStore::get_macro_index( } int ObPhyRestoreMacroIndexStore::get_sstable_pair_list( - const uint64_t index_id, common::ObIArray& pair_list) const + const uint64_t index_id, common::ObIArray &pair_list) const { int ret = OB_SUCCESS; - common::ObArray* index_list = NULL; + common::ObArray *index_list = NULL; pair_list.reuse(); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1344,9 +1350,9 @@ void ObPartitionMetaPhysicalReader::reset() pkey_.reset(); } -int ObPartitionMetaPhysicalReader::init(const ObPhysicalRestoreArg& arg, - const share::ObSimpleBackupSetPath& simple_path, const ObPhyRestoreMetaIndexStore& meta_indexs, - const ObPhyRestoreMacroIndexStore& macro_indexs, const ObPartitionKey& pkey) +int ObPartitionMetaPhysicalReader::init(const ObPhysicalRestoreArg &arg, + const share::ObSimpleBackupSetPath &simple_path, const ObPhyRestoreMetaIndexStore &meta_indexs, + const ObPhyRestoreMacroIndexStore ¯o_indexs, const ObPartitionKey &pkey) { int ret = OB_SUCCESS; @@ -1376,9 +1382,9 @@ int ObPartitionMetaPhysicalReader::init(const ObPhysicalRestoreArg& arg, return ret; } -int ObPartitionMetaPhysicalReader::init(const ObPhysicalRestoreArg& arg, const ObBackupBaseDataPathInfo& path_info, - const ObPhyRestoreMetaIndexStore& meta_indexes, const ObPhyRestoreMacroIndexStore& macro_indexs, - const ObPartitionKey& pkey) +int ObPartitionMetaPhysicalReader::init(const ObPhysicalRestoreArg &arg, const ObBackupBaseDataPathInfo &path_info, + const ObPhyRestoreMetaIndexStore &meta_indexes, const ObPhyRestoreMacroIndexStore ¯o_indexs, + const ObPartitionKey &pkey) { int ret = OB_SUCCESS; ObSimpleBackupSetPath simple_path; @@ -1428,7 +1434,7 @@ int ObPartitionMetaPhysicalReader::read_all_sstable_meta() return ret; } -int ObPartitionMetaPhysicalReader::read_partition_meta(ObPGPartitionStoreMeta& partition_store_meta) +int ObPartitionMetaPhysicalReader::read_partition_meta(ObPGPartitionStoreMeta &partition_store_meta) { int ret = OB_SUCCESS; @@ -1454,7 +1460,7 @@ int ObPartitionMetaPhysicalReader::read_partition_meta(ObPGPartitionStoreMeta& p return ret; } -int ObPartitionMetaPhysicalReader::read_sstable_meta(const uint64_t backup_index_id, ObSSTableBaseMeta& meta) +int ObPartitionMetaPhysicalReader::read_sstable_meta(const uint64_t backup_index_id, ObSSTableBaseMeta &meta) { int ret = OB_SUCCESS; @@ -1486,7 +1492,7 @@ int ObPartitionMetaPhysicalReader::read_sstable_meta(const uint64_t backup_index return ret; } -int ObPartitionMetaPhysicalReader::read_sstable_pair_list(const uint64_t index_tid, ObIArray& part_list) +int ObPartitionMetaPhysicalReader::read_sstable_pair_list(const uint64_t index_tid, ObIArray &part_list) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1519,7 +1525,7 @@ int ObPartitionMetaPhysicalReader::read_table_keys() return ret; } -int ObPartitionMetaPhysicalReader::read_table_ids(ObIArray& table_id_array) +int ObPartitionMetaPhysicalReader::read_table_ids(ObIArray &table_id_array) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1539,7 +1545,7 @@ int ObPartitionMetaPhysicalReader::read_table_ids(ObIArray& table_id_a } int ObPartitionMetaPhysicalReader::read_table_keys_by_table_id( - const uint64_t table_id, ObIArray& table_keys_array) + const uint64_t table_id, ObIArray &table_keys_array) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1565,7 +1571,7 @@ int ObPartitionMetaPhysicalReader::read_table_keys_by_table_id( } int ObPartitionMetaPhysicalReader::get_tenant_data_meta_file_path_( - const share::ObBackupMetaIndex& meta_index, share::ObBackupPath& path) + const share::ObBackupMetaIndex &meta_index, share::ObBackupPath &path) { int ret = OB_SUCCESS; if (OB_FAIL(ObBackupPathUtil::get_tenant_data_meta_file_path(simple_path_, meta_index.task_id_, path))) { @@ -1591,7 +1597,7 @@ void ObPGMetaPhysicalReader::reset() is_inited_ = false; } -int ObPGMetaPhysicalReader::init(const share::ObPhysicalRestoreArg& arg, const ObPhyRestoreMetaIndexStore& meta_indexs) +int ObPGMetaPhysicalReader::init(const share::ObPhysicalRestoreArg &arg, const ObPhyRestoreMetaIndexStore &meta_indexs) { int ret = OB_SUCCESS; const bool is_compat_backup_path = !arg.restore_info_.is_compat_backup_path(); @@ -1619,8 +1625,8 @@ int ObPGMetaPhysicalReader::init(const share::ObPhysicalRestoreArg& arg, const O return ret; } -int ObPGMetaPhysicalReader::init(const share::ObBackupBaseDataPathInfo& path_info, const common::ObPGKey& pg_key, - const ObPhyRestoreMetaIndexStore& meta_indexs) +int ObPGMetaPhysicalReader::init(const share::ObBackupBaseDataPathInfo &path_info, const common::ObPGKey &pg_key, + const ObPhyRestoreMetaIndexStore &meta_indexs) { int ret = OB_SUCCESS; @@ -1640,7 +1646,7 @@ int ObPGMetaPhysicalReader::init(const share::ObBackupBaseDataPathInfo& path_inf return ret; } -int ObPGMetaPhysicalReader::read_partition_group_meta(ObPartitionGroupMeta& pg_meta) +int ObPGMetaPhysicalReader::read_partition_group_meta(ObPartitionGroupMeta &pg_meta) { int ret = OB_SUCCESS; ObBackupPath path; @@ -1662,7 +1668,7 @@ int ObPGMetaPhysicalReader::read_partition_group_meta(ObPartitionGroupMeta& pg_m return ret; } -int ObPGMetaPhysicalReader::read_backup_pg_meta_info(ObBackupPGMetaInfo& backup_pg_meta_info) +int ObPGMetaPhysicalReader::read_backup_pg_meta_info(ObBackupPGMetaInfo &backup_pg_meta_info) { int ret = OB_SUCCESS; ObBackupPath path; @@ -1739,9 +1745,9 @@ void ObPartitionBaseDataMetaRestoreReaderV1::reset() data_version_ = 0; } -int ObPartitionBaseDataMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - const common::ObPartitionKey& pkey, const ObPhysicalRestoreArg& restore_info, - const ObPhyRestoreMetaIndexStore& meta_indexs, const ObPhyRestoreMacroIndexStore& macro_indexs) +int ObPartitionBaseDataMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + const common::ObPartitionKey &pkey, const ObPhysicalRestoreArg &restore_info, + const ObPhyRestoreMetaIndexStore &meta_indexs, const ObPhyRestoreMacroIndexStore ¯o_indexs) { int ret = OB_SUCCESS; ObPartitionKey src_pkey; @@ -1787,7 +1793,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottl return ret; } -int ObPartitionBaseDataMetaRestoreReaderV1::fetch_partition_meta(ObPGPartitionStoreMeta& partition_store_meta) +int ObPartitionBaseDataMetaRestoreReaderV1::fetch_partition_meta(ObPGPartitionStoreMeta &partition_store_meta) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1823,7 +1829,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::fetch_partition_meta(ObPGPartitionSt } int ObPartitionBaseDataMetaRestoreReaderV1::fetch_sstable_meta( - const uint64_t index_id, blocksstable::ObSSTableBaseMeta& sstable_meta) + const uint64_t index_id, blocksstable::ObSSTableBaseMeta &sstable_meta) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1863,7 +1869,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::fetch_sstable_meta( } int ObPartitionBaseDataMetaRestoreReaderV1::fetch_sstable_pair_list( - const uint64_t index_id, common::ObIArray& pair_list) + const uint64_t index_id, common::ObIArray &pair_list) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1902,12 +1908,12 @@ int ObPartitionBaseDataMetaRestoreReaderV1::fetch_sstable_pair_list( return ret; } -int ObPartitionBaseDataMetaRestoreReaderV1::prepare(const common::ObPartitionKey& pkey) +int ObPartitionBaseDataMetaRestoreReaderV1::prepare(const common::ObPartitionKey &pkey) { int ret = OB_SUCCESS; ObIPartitionGroupGuard guard; ObPGPartitionGuard pg_partition_guard; - ObPartitionStorage* partition_storage = NULL; + ObPartitionStorage *partition_storage = NULL; if (OB_UNLIKELY(!reader_.is_inited())) { ret = OB_NOT_INIT; @@ -1922,7 +1928,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::prepare(const common::ObPartitionKey } else if (OB_ISNULL(pg_partition_guard.get_pg_partition())) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "pg_partition is null ", K(ret), K(pkey)); - } else if (OB_ISNULL(partition_storage = reinterpret_cast( + } else if (OB_ISNULL(partition_storage = reinterpret_cast( pg_partition_guard.get_pg_partition()->get_storage()))) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "Unexpected error, the partition storage is NULL", K(ret), K(pkey)); @@ -1933,7 +1939,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::prepare(const common::ObPartitionKey return ret; } -int ObPartitionBaseDataMetaRestoreReaderV1::fetch_all_table_ids(common::ObIArray& table_id_array) +int ObPartitionBaseDataMetaRestoreReaderV1::fetch_all_table_ids(common::ObIArray &table_id_array) { int ret = OB_SUCCESS; common::ObArray backup_table_id_array; @@ -1960,7 +1966,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::fetch_all_table_ids(common::ObIArray } int ObPartitionBaseDataMetaRestoreReaderV1::fetch_table_keys( - const uint64_t index_id, obrpc::ObFetchTableInfoResult& table_res) + const uint64_t index_id, obrpc::ObFetchTableInfoResult &table_res) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1974,7 +1980,7 @@ int ObPartitionBaseDataMetaRestoreReaderV1::fetch_table_keys( STORAGE_LOG(WARN, "fail to get table keys", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < table_res.table_keys_.count(); ++i) { - ObITable::TableKey& table_key = table_res.table_keys_.at(i); + ObITable::TableKey &table_key = table_res.table_keys_.at(i); if (!table_key.is_major_sstable() || 0 != table_key.trans_version_range_.base_version_) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "table key has wrong table type", K(ret), K(table_key)); @@ -2008,9 +2014,9 @@ ObPhysicalBaseMetaRestoreReaderV1::ObPhysicalBaseMetaRestoreReaderV1() {} -int ObPhysicalBaseMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - const ObPhysicalRestoreArg& restore_info, const ObITable::TableKey& table_key, - ObIPartitionGroupMetaRestoreReader& reader) +int ObPhysicalBaseMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + const ObPhysicalRestoreArg &restore_info, const ObITable::TableKey &table_key, + ObIPartitionGroupMetaRestoreReader &reader) { int ret = OB_SUCCESS; @@ -2030,7 +2036,7 @@ int ObPhysicalBaseMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle& ba return ret; } -int ObPhysicalBaseMetaRestoreReaderV1::fetch_sstable_meta(ObSSTableBaseMeta& sstable_meta) +int ObPhysicalBaseMetaRestoreReaderV1::fetch_sstable_meta(ObSSTableBaseMeta &sstable_meta) { int ret = OB_SUCCESS; @@ -2046,7 +2052,7 @@ int ObPhysicalBaseMetaRestoreReaderV1::fetch_sstable_meta(ObSSTableBaseMeta& sst return ret; } -int ObPhysicalBaseMetaRestoreReaderV1::fetch_macro_block_list(ObIArray& macro_block_list) +int ObPhysicalBaseMetaRestoreReaderV1::fetch_macro_block_list(ObIArray ¯o_block_list) { int ret = OB_SUCCESS; @@ -2080,9 +2086,9 @@ ObPartitionMacroBlockRestoreReaderV1::ObPartitionMacroBlockRestoreReaderV1() ObPartitionMacroBlockRestoreReaderV1::~ObPartitionMacroBlockRestoreReaderV1() {} -int ObPartitionMacroBlockRestoreReaderV1::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - common::ObIArray& list, const ObPhysicalRestoreArg& restore_info, - const ObPhyRestoreMacroIndexStore& macro_indexs, const ObITable::TableKey& table_key) +int ObPartitionMacroBlockRestoreReaderV1::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + common::ObIArray &list, const ObPhysicalRestoreArg &restore_info, + const ObPhyRestoreMacroIndexStore ¯o_indexs, const ObITable::TableKey &table_key) { int ret = OB_SUCCESS; @@ -2130,14 +2136,14 @@ int ObPartitionMacroBlockRestoreReaderV1::init(common::ObInOutBandwidthThrottle& return ret; } -int ObPartitionMacroBlockRestoreReaderV1::get_next_macro_block(blocksstable::ObFullMacroBlockMeta& meta, - blocksstable::ObBufferReader& data, blocksstable::MacroBlockId& src_macro_id) +int ObPartitionMacroBlockRestoreReaderV1::get_next_macro_block(blocksstable::ObFullMacroBlockMeta &meta, + blocksstable::ObBufferReader &data, blocksstable::MacroBlockId &src_macro_id) { int ret = OB_SUCCESS; ObBackupPath path; ObBackupMacroIndex macro_index; - ObMacroBlockSchemaInfo* new_schema = nullptr; - ObMacroBlockMetaV2* new_meta = nullptr; + ObMacroBlockSchemaInfo *new_schema = nullptr; + ObMacroBlockMetaV2 *new_meta = nullptr; allocator_.reuse(); src_macro_id.reset(); // src_macro_id only used for fast migrator on ofs @@ -2173,8 +2179,8 @@ int ObPartitionMacroBlockRestoreReaderV1::get_next_macro_block(blocksstable::ObF } // used to read macro block before 2.2.77 -int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v1_(const ObBackupMacroIndex& macro_index, - ObMacroBlockSchemaInfo*& new_schema, ObMacroBlockMetaV2*& new_meta, blocksstable::ObBufferReader& data) +int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v1_(const ObBackupMacroIndex ¯o_index, + ObMacroBlockSchemaInfo *&new_schema, ObMacroBlockMetaV2 *&new_meta, blocksstable::ObBufferReader &data) { int ret = OB_SUCCESS; ObBackupPath path; @@ -2209,8 +2215,8 @@ int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v1_(const ObBackupMac } // used to read macro block sine 2.2.77 -int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v2_(const ObBackupMacroIndex& macro_index, - ObMacroBlockSchemaInfo*& new_schema, ObMacroBlockMetaV2*& new_meta, blocksstable::ObBufferReader& data) +int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v2_(const ObBackupMacroIndex ¯o_index, + ObMacroBlockSchemaInfo *&new_schema, ObMacroBlockMetaV2 *&new_meta, blocksstable::ObBufferReader &data) { int ret = OB_SUCCESS; ObBackupSetPath backup_path; @@ -2230,7 +2236,7 @@ int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v2_(const ObBackupMac } for (int64_t i = 0; OB_SUCC(ret) && i < path_list.count(); ++i) { - const ObSimpleBackupSetPath& path = path_list.at(i); + const ObSimpleBackupSetPath &path = path_list.at(i); if (backup_set_id == path.backup_set_id_) { if (OB_FAIL(backup_path.assign(path.backup_dest_))) { STORAGE_LOG(WARN, "failed to assign", K(ret), K(path)); @@ -2267,7 +2273,7 @@ int ObPartitionMacroBlockRestoreReaderV1::read_macro_block_v2_(const ObBackupMac } int ObPartitionMacroBlockRestoreReaderV1::trans_macro_block( - const uint64_t table_id, blocksstable::ObMacroBlockMetaV2& meta, blocksstable::ObBufferReader& data) + const uint64_t table_id, blocksstable::ObMacroBlockMetaV2 &meta, blocksstable::ObBufferReader &data) { int ret = OB_SUCCESS; ObMacroBlockCommonHeader common_header; @@ -2300,8 +2306,8 @@ int ObPartitionMacroBlockRestoreReaderV1::trans_macro_block( "need_size", sizeof(ObSSTableMacroBlockHeader)); } else { - ObSSTableMacroBlockHeader* sstable_macro_block_header = - reinterpret_cast(data.data() + pos); + ObSSTableMacroBlockHeader *sstable_macro_block_header = + reinterpret_cast(data.data() + pos); meta.table_id_ = table_id; sstable_macro_block_header->table_id_ = meta.table_id_; sstable_macro_block_header->data_version_ = meta.data_version_; @@ -2339,7 +2345,7 @@ void ObPartitionGroupMetaRestoreReaderV1::reset() bandwidth_throttle_ = NULL; last_read_size_ = 0; for (MetaReaderMap::iterator iter = partition_reader_map_.begin(); iter != partition_reader_map_.end(); ++iter) { - ObPartitionBaseDataMetaRestoreReaderV1* meta_reader = iter->second; + ObPartitionBaseDataMetaRestoreReaderV1 *meta_reader = iter->second; if (NULL != meta_reader) { meta_reader->~ObPartitionBaseDataMetaRestoreReaderV1(); } @@ -2348,9 +2354,9 @@ void ObPartitionGroupMetaRestoreReaderV1::reset() allocator_.reset(); } -int ObPartitionGroupMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle& bandwidth_throttle, - const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMetaIndexStore& meta_indexs, - const ObPhyRestoreMacroIndexStore& macro_indexs) +int ObPartitionGroupMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle &bandwidth_throttle, + const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMetaIndexStore &meta_indexs, + const ObPhyRestoreMacroIndexStore ¯o_indexs) { int ret = OB_SUCCESS; @@ -2380,7 +2386,7 @@ int ObPartitionGroupMetaRestoreReaderV1::init(common::ObInOutBandwidthThrottle& return ret; } -int ObPartitionGroupMetaRestoreReaderV1::fetch_partition_group_meta(ObPartitionGroupMeta& pg_meta) +int ObPartitionGroupMetaRestoreReaderV1::fetch_partition_group_meta(ObPartitionGroupMeta &pg_meta) { int ret = OB_SUCCESS; @@ -2397,23 +2403,23 @@ int ObPartitionGroupMetaRestoreReaderV1::fetch_partition_group_meta(ObPartitionG return ret; } -int ObPartitionGroupMetaRestoreReaderV1::trans_backup_pgmeta(ObPartitionGroupMeta& backup_pg_meta) +int ObPartitionGroupMetaRestoreReaderV1::trans_backup_pgmeta(ObPartitionGroupMeta &backup_pg_meta) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!pg_meta_.is_valid() || !backup_pg_meta.is_valid())) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "invalid argument", K(ret), K(pg_meta_), K(backup_pg_meta)); } else { - const ObSavedStorageInfoV2& cur_info = pg_meta_.storage_info_; + const ObSavedStorageInfoV2 &cur_info = pg_meta_.storage_info_; const int64_t cur_schema_version = cur_info.get_data_info().get_schema_version(); - ObSavedStorageInfoV2& backup_info = backup_pg_meta.storage_info_; + ObSavedStorageInfoV2 &backup_info = backup_pg_meta.storage_info_; backup_info.get_data_info().set_schema_version(cur_schema_version); } return ret; } int ObPartitionGroupMetaRestoreReaderV1::read_partition_meta( - const ObPartitionKey& pkey, const ObPhysicalRestoreArg& restore_info, ObPGPartitionStoreMeta& partition_store_meta) + const ObPartitionKey &pkey, const ObPhysicalRestoreArg &restore_info, ObPGPartitionStoreMeta &partition_store_meta) { int ret = OB_SUCCESS; @@ -2455,12 +2461,12 @@ int ObPartitionGroupMetaRestoreReaderV1::read_partition_meta( } int ObPartitionGroupMetaRestoreReaderV1::create_pg_partition_if_need( - const ObPhysicalRestoreArg& restore_info, const ObPartitionGroupMeta& backup_pg_meta) + const ObPhysicalRestoreArg &restore_info, const ObPartitionGroupMeta &backup_pg_meta) { int ret = OB_SUCCESS; ObIPartitionGroupGuard pg_guard; - ObIPartitionGroup* pg = NULL; - const ObPartitionKey& pg_key = restore_info.pg_key_; + ObIPartitionGroup *pg = NULL; + const ObPartitionKey &pg_key = restore_info.pg_key_; if (OB_UNLIKELY(!restore_info.is_valid() || !backup_pg_meta.is_valid())) { ret = OB_INVALID_ARGUMENT; @@ -2471,11 +2477,11 @@ int ObPartitionGroupMetaRestoreReaderV1::create_pg_partition_if_need( ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "partition group should not be null", K(ret), K(pg_key)); } else { - const ObSavedStorageInfoV2& storage_info = backup_pg_meta.storage_info_; + const ObSavedStorageInfoV2 &storage_info = backup_pg_meta.storage_info_; ObPGPartitionStoreMeta partition_meta; bool succ_create_partition = false; for (int64_t i = 0; OB_SUCC(ret) && i < backup_pg_meta.partitions_.count(); ++i) { - const ObPartitionKey& src_pkey = backup_pg_meta.partitions_.at(i); + const ObPartitionKey &src_pkey = backup_pg_meta.partitions_.at(i); ObPartitionKey dst_pkey; ObIPartitionGroupGuard guard; int tmp_ret = OB_SUCCESS; @@ -2530,14 +2536,14 @@ int ObPartitionGroupMetaRestoreReaderV1::create_pg_partition_if_need( } int ObPartitionGroupMetaRestoreReaderV1::prepare_pg_meta( - common::ObInOutBandwidthThrottle& bandwidth_throttle, const ObPhysicalRestoreArg& restore_info) + common::ObInOutBandwidthThrottle &bandwidth_throttle, const ObPhysicalRestoreArg &restore_info) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; ObIPartitionGroupGuard pg_guard; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; ObPartitionGroupMeta backup_pg_meta; - const ObPartitionKey& pg_key = restore_info.pg_key_; + const ObPartitionKey &pg_key = restore_info.pg_key_; if (OB_FAIL(ObPartitionService::get_instance().get_partition(pg_key, pg_guard))) { STORAGE_LOG(WARN, "fail to get pg guard", K(ret), K(pg_key)); } else if (OB_ISNULL(partition_group = pg_guard.get_partition_group())) { @@ -2576,9 +2582,9 @@ int ObPartitionGroupMetaRestoreReaderV1::prepare_pg_meta( return ret; } -int ObPartitionGroupMetaRestoreReaderV1::prepare(common::ObInOutBandwidthThrottle& bandwidth_throttle, - const ObPhysicalRestoreArg& restore_info, const ObPhyRestoreMetaIndexStore& meta_indexs, - const ObPhyRestoreMacroIndexStore& macro_indexs) +int ObPartitionGroupMetaRestoreReaderV1::prepare(common::ObInOutBandwidthThrottle &bandwidth_throttle, + const ObPhysicalRestoreArg &restore_info, const ObPhyRestoreMetaIndexStore &meta_indexs, + const ObPhyRestoreMacroIndexStore ¯o_indexs) { int ret = OB_SUCCESS; @@ -2588,16 +2594,16 @@ int ObPartitionGroupMetaRestoreReaderV1::prepare(common::ObInOutBandwidthThrottl } else if (OB_FAIL(prepare_pg_meta(bandwidth_throttle, restore_info))) { STORAGE_LOG(WARN, "prepare pg meta fail", K(ret)); } else { - const ObPartitionArray& partitions = pg_meta_.partitions_; + const ObPartitionArray &partitions = pg_meta_.partitions_; if (0 == partitions.count()) { STORAGE_LOG(INFO, "empty pg, no partitions"); } else if (OB_FAIL(partition_reader_map_.create(partitions.count(), ObModIds::RESTORE))) { STORAGE_LOG(WARN, "failed to create partition reader map", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < partitions.count(); ++i) { - const ObPartitionKey& pkey = partitions.at(i); - ObPartitionBaseDataMetaRestoreReaderV1* reader = NULL; - void* buf = NULL; + const ObPartitionKey &pkey = partitions.at(i); + ObPartitionBaseDataMetaRestoreReaderV1 *reader = NULL; + void *buf = NULL; if (OB_ISNULL(buf = allocator_.alloc(sizeof(ObPartitionBaseDataMetaRestoreReaderV1)))) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "failed to alloc buf", K(ret)); @@ -2622,7 +2628,7 @@ int ObPartitionGroupMetaRestoreReaderV1::prepare(common::ObInOutBandwidthThrottl } int ObPartitionGroupMetaRestoreReaderV1::get_partition_readers( - const ObPartitionArray& partitions, ObIArray& partition_reader_array) + const ObPartitionArray &partitions, ObIArray &partition_reader_array) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -2630,8 +2636,8 @@ int ObPartitionGroupMetaRestoreReaderV1::get_partition_readers( STORAGE_LOG(WARN, "partition group meta restore reader do not init", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < partitions.count(); ++i) { - const ObPartitionKey& pkey = partitions.at(i); - ObPartitionBaseDataMetaRestoreReaderV1* reader = NULL; + const ObPartitionKey &pkey = partitions.at(i); + ObPartitionBaseDataMetaRestoreReaderV1 *reader = NULL; if (OB_FAIL(partition_reader_map_.get_refactored(pkey, reader))) { STORAGE_LOG(WARN, "failed to get partition base data meta restore reader", K(ret), K(pkey)); } else if (OB_ISNULL(reader)) { @@ -2646,10 +2652,10 @@ int ObPartitionGroupMetaRestoreReaderV1::get_partition_readers( } int ObPartitionGroupMetaRestoreReaderV1::fetch_sstable_meta( - const ObITable::TableKey& table_key, blocksstable::ObSSTableBaseMeta& sstable_meta) + const ObITable::TableKey &table_key, blocksstable::ObSSTableBaseMeta &sstable_meta) { int ret = OB_SUCCESS; - ObPartitionBaseDataMetaRestoreReaderV1* reader = NULL; + ObPartitionBaseDataMetaRestoreReaderV1 *reader = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -2669,11 +2675,11 @@ int ObPartitionGroupMetaRestoreReaderV1::fetch_sstable_meta( } int ObPartitionGroupMetaRestoreReaderV1::fetch_sstable_pair_list( - const ObITable::TableKey& table_key, common::ObIArray& pair_list) + const ObITable::TableKey &table_key, common::ObIArray &pair_list) { int ret = OB_SUCCESS; ObArray backup_pair_list; - ObPartitionBaseDataMetaRestoreReaderV1* reader = NULL; + ObPartitionBaseDataMetaRestoreReaderV1 *reader = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -2693,12 +2699,12 @@ int ObPartitionGroupMetaRestoreReaderV1::fetch_sstable_pair_list( } int ObPartitionGroupMetaRestoreReaderV1::check_backup_partitions_in_pg( - const ObPhysicalRestoreArg& restore_info, ObPartitionGroupMeta& backup_pg_meta) + const ObPhysicalRestoreArg &restore_info, ObPartitionGroupMeta &backup_pg_meta) { int ret = OB_SUCCESS; ObHashSet restore_table_ids_set; ObSchemaGetterGuard schema_guard; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); const uint64_t tenant_id = restore_info.pg_key_.get_tenant_id(); const uint64_t tablegroup_id = restore_info.pg_key_.get_tablegroup_id(); ObArray table_ids; @@ -2744,7 +2750,7 @@ int ObPartitionGroupMetaRestoreReaderV1::check_backup_partitions_in_pg( if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) { const uint64_t table_id = table_ids.at(i); - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; int hash_ret = OB_SUCCESS; if (OB_FAIL(schema_guard.get_table_schema(table_id, table_schema))) { STORAGE_LOG(WARN, "failed to get table schema", K(ret), K(table_id)); @@ -2780,7 +2786,7 @@ int ObPartitionGroupMetaRestoreReaderV1::check_backup_partitions_in_pg( return ret; } -int ObPartitionGroupMetaRestoreReaderV1::get_restore_tenant_id(uint64_t& tenant_id) +int ObPartitionGroupMetaRestoreReaderV1::get_restore_tenant_id(uint64_t &tenant_id) { int ret = OB_SUCCESS; tenant_id = OB_INVALID_ID; @@ -2794,7 +2800,7 @@ int ObPartitionGroupMetaRestoreReaderV1::get_restore_tenant_id(uint64_t& tenant_ } int ObPartitionGroupMetaRestoreReaderV1::get_tenant_data_meta_file_path_( - const share::ObBackupMetaIndex& meta_index, share::ObBackupPath& path) + const share::ObBackupMetaIndex &meta_index, share::ObBackupPath &path) { int ret = OB_SUCCESS; const bool is_compat_backup_path = !restore_info_->restore_info_.is_compat_backup_path(); @@ -2835,7 +2841,7 @@ void ObPGPartitionBaseDataMetaRestoreReaderV1::reset() } int ObPGPartitionBaseDataMetaRestoreReaderV1::init( - const ObPartitionArray& partitions, ObPartitionGroupMetaRestoreReaderV1* reader) + const ObPartitionArray &partitions, ObPartitionGroupMetaRestoreReaderV1 *reader) { int ret = OB_SUCCESS; uint64_t tenant_id = 0; @@ -2863,7 +2869,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::init( } int ObPGPartitionBaseDataMetaRestoreReaderV1::fetch_pg_partition_meta_info( - obrpc::ObPGPartitionMetaInfo& partition_meta_info) + obrpc::ObPGPartitionMetaInfo &partition_meta_info) { int ret = OB_SUCCESS; partition_meta_info.reset(); @@ -2874,7 +2880,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::fetch_pg_partition_meta_info( } else if (reader_index_ == partition_reader_array_.count()) { ret = OB_ITER_END; } else { - ObPartitionBaseDataMetaRestoreReaderV1* reader = partition_reader_array_.at(reader_index_); + ObPartitionBaseDataMetaRestoreReaderV1 *reader = partition_reader_array_.at(reader_index_); if (OB_ISNULL(reader)) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "partition base data meta restore reader is NULL", K(ret), KP(reader), K(reader_index_)); @@ -2905,7 +2911,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::fetch_pg_partition_meta_info( } int ObPGPartitionBaseDataMetaRestoreReaderV1::check_sstable_table_ids_in_table( - const ObPartitionKey& pkey, const common::ObIArray& table_ids) + const ObPartitionKey &pkey, const common::ObIArray &table_ids) { int ret = OB_SUCCESS; ObHashSet table_ids_set; @@ -2913,7 +2919,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::check_sstable_table_ids_in_table( const uint64_t tenant_id = pkey.get_tenant_id(); ObArray index_stats; ObSchemaGetterGuard schema_guard; - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -2948,7 +2954,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::check_sstable_table_ids_in_table( // local index table if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < index_stats.count(); ++i) { - const ObIndexTableStat& index_stat = index_stats.at(i); + const ObIndexTableStat &index_stat = index_stats.at(i); const uint64_t index_table_id = index_stat.index_id_; if (OB_FAIL(check_sstable_ids_contain_schema_table_id(table_ids_set, index_table_id, schema_guard))) { STORAGE_LOG(WARN, "failed to check sstable ids contain schema table id", K(ret), K(index_table_id)); @@ -2960,8 +2966,8 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::check_sstable_table_ids_in_table( } int ObPGPartitionBaseDataMetaRestoreReaderV1::check_sstable_ids_contain_schema_table_id( - const hash::ObHashSet& table_ids_set, const uint64_t schema_table_id, - schema::ObSchemaGetterGuard& schema_guard) + const hash::ObHashSet &table_ids_set, const uint64_t schema_table_id, + schema::ObSchemaGetterGuard &schema_guard) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -2972,7 +2978,7 @@ int ObPGPartitionBaseDataMetaRestoreReaderV1::check_sstable_ids_contain_schema_t int hash_ret = table_ids_set.exist_refactored(schema_table_id); if (OB_HASH_EXIST == hash_ret) { } else if (OB_HASH_NOT_EXIST == hash_ret) { - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; if (OB_FAIL(schema_guard.get_table_schema(schema_table_id, table_schema))) { STORAGE_LOG(WARN, "failed to get table schema", K(ret), K(schema_table_id)); } else if (OB_ISNULL(table_schema)) { diff --git a/src/storage/ob_partition_migrator.cpp b/src/storage/ob_partition_migrator.cpp index 993d1e02129dacaec365a95636b4cf130e36ad2a..04162881c1be5b32eee2996786806b3508ee64a7 100644 --- a/src/storage/ob_partition_migrator.cpp +++ b/src/storage/ob_partition_migrator.cpp @@ -62,9 +62,9 @@ using namespace transaction; namespace storage { #define MIGRATOR (::oceanbase::storage::ObPartitionMigrator::get_instance()) -typedef common::hash::ObHashMap SSTableMap; +typedef common::hash::ObHashMap SSTableMap; -int ObPartMigrationTask::assign(const ObPartMigrationTask& task) +int ObPartMigrationTask::assign(const ObPartMigrationTask &task) { int ret = common::OB_SUCCESS; @@ -91,12 +91,12 @@ ObMacroBlockReuseMgr::~ObMacroBlockReuseMgr() // TODO(): split reuse macro block not support yet int ObMacroBlockReuseMgr::build_reuse_macro_map( - ObMigrateCtx& ctx, const ObITable::TableKey& table_key, const common::ObIArray& macro_block_list) + ObMigrateCtx &ctx, const ObITable::TableKey &table_key, const common::ObIArray ¯o_block_list) { int ret = OB_SUCCESS; ObTablesHandle tables_handle; ObDataMacroIdIterator data_macro_iter; - ObIPartitionGroup* pg = ctx.get_partition(); + ObIPartitionGroup *pg = ctx.get_partition(); if (OB_ISNULL(pg)) { ret = OB_ERR_SYS; LOG_WARN("error sys, pg must not be null", K(ret)); @@ -112,7 +112,7 @@ int ObMacroBlockReuseMgr::build_reuse_macro_map( } else { ObMacroBlockInfoPair info; ObTenantFileKey file_key; - const ObMacroBlockMetaV2* meta = nullptr; + const ObMacroBlockMetaV2 *meta = nullptr; while (OB_SUCC(ret)) { if (OB_FAIL(data_macro_iter.get_next_macro_info(info, file_key))) { if (OB_ITER_END == ret) { @@ -133,8 +133,8 @@ int ObMacroBlockReuseMgr::build_reuse_macro_map( } for (int64_t i = 0; OB_SUCC(ret) && i < macro_block_list.count(); ++i) { - ObMacroBlockMetaV2* dst_meta = nullptr; - ObMacroBlockSchemaInfo* dst_schema = nullptr; + ObMacroBlockMetaV2 *dst_meta = nullptr; + ObMacroBlockSchemaInfo *dst_schema = nullptr; ObMacroBlockInfoPair info; ObMajorMacroBlockKey key; key.table_id_ = table_key.table_id_; @@ -190,7 +190,7 @@ void ObMacroBlockReuseMgr::reset() } bool ObMacroBlockReuseMgr::RemoveFunctor::operator()( - const blocksstable::ObMajorMacroBlockKey& block_key, blocksstable::ObMacroBlockInfoPair& info) + const blocksstable::ObMajorMacroBlockKey &block_key, blocksstable::ObMacroBlockInfoPair &info) { UNUSED(block_key); if (nullptr != info.meta_.meta_) { @@ -203,7 +203,7 @@ bool ObMacroBlockReuseMgr::RemoveFunctor::operator()( } int ObMacroBlockReuseMgr::get_reuse_macro_meta( - const blocksstable::ObMajorMacroBlockKey& block_key, blocksstable::ObMacroBlockInfoPair& info) + const blocksstable::ObMajorMacroBlockKey &block_key, blocksstable::ObMacroBlockInfoPair &info) { int ret = OB_SUCCESS; if (OB_FAIL(reuse_map_.get(block_key, info))) { @@ -223,7 +223,7 @@ void ObPartitionGroupInfoResult::reset() choose_src_info_.reset(); } -int ObPartitionGroupInfoResult::assign(const ObPartitionGroupInfoResult& result) +int ObPartitionGroupInfoResult::assign(const ObPartitionGroupInfoResult &result) { int ret = OB_SUCCESS; reset(); @@ -374,7 +374,7 @@ void ObMigrateCtx::set_result_code(const int32_t result) } } -ObMigrateCtxGuard::ObMigrateCtxGuard(const bool is_write_lock, ObMigrateCtx& ctx) : ctx_(ctx) +ObMigrateCtxGuard::ObMigrateCtxGuard(const bool is_write_lock, ObMigrateCtx &ctx) : ctx_(ctx) { int tmp_ret = OB_SUCCESS; @@ -397,14 +397,14 @@ ObMigrateCtxGuard::~ObMigrateCtxGuard() int ObMigrateCtx::update_partition_migration_status() const { int ret = OB_SUCCESS; - const ObMigrateCtx& ctx = *this; + const ObMigrateCtx &ctx = *this; if (!ctx.is_valid()) { ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "invalid args", K(ret), K(ctx)); } else { ObPartitionMigrationStatusGuard status_guard; - ObPartitionMigrationStatus* status = NULL; + ObPartitionMigrationStatus *status = NULL; if (OB_FAIL(ObPartitionMigrationStatusMgr::get_instance().get_status(ctx.task_id_, status_guard))) { STORAGE_LOG(WARN, "failed to get partition status", K(ret), K(ctx)); } else if (NULL == (status = status_guard.getStatus())) { @@ -456,7 +456,7 @@ bool ObMigrateCtx::is_copy_index() const return COPY_GLOBAL_INDEX_OP == replica_op_arg_.type_ || COPY_LOCAL_INDEX_OP == replica_op_arg_.type_; } -int ObMigrateCtx::add_major_block_id(const MacroBlockId& macro_block_id) +int ObMigrateCtx::add_major_block_id(const MacroBlockId ¯o_block_id) { int ret = OB_SUCCESS; if (OB_ISNULL(major_block_id_array_ptr_)) { @@ -528,8 +528,8 @@ void ObMigrateCtx::rebuild_migrate_ctx() int ObMigrateCtx::generate_and_schedule_migrate_dag() { int ret = OB_SUCCESS; - ObBaseMigrateDag* dag = NULL; - ObMigrateTaskSchedulerTask* scheduler_task = NULL; + ObBaseMigrateDag *dag = NULL; + ObMigrateTaskSchedulerTask *scheduler_task = NULL; if (BACKUP_REPLICA_OP == replica_op_arg_.type_) { ret = OB_ERR_UNEXPECTED; LOG_WARN("generate and schedule migrate dag get unexpected replica op", K(ret), K(*this)); @@ -566,11 +566,11 @@ int ObMigrateCtx::generate_and_schedule_migrate_dag() return ret; } -int ObMigrateCtx::generate_and_schedule_backup_dag(const ObBackupDataType& backup_data_type) +int ObMigrateCtx::generate_and_schedule_backup_dag(const ObBackupDataType &backup_data_type) { int ret = OB_SUCCESS; - ObBackupDag* backup_dag = NULL; - ObBackupPrepareTask* prepare_task = NULL; + ObBackupDag *backup_dag = NULL; + ObBackupPrepareTask *prepare_task = NULL; if (!backup_data_type.is_valid()) { ret = OB_INVALID_ARGUMENT; @@ -627,7 +627,7 @@ bool ObMigrateCtx::is_need_retry(const int result) const } // if local has partition full data, no need copy, return true -int ObMigrateCtx::change_replica_with_data(bool& is_replica_with_data) +int ObMigrateCtx::change_replica_with_data(bool &is_replica_with_data) { int ret = OB_SUCCESS; is_replica_with_data = false; @@ -639,14 +639,14 @@ int ObMigrateCtx::change_replica_with_data(bool& is_replica_with_data) ret = OB_INVALID_ARGUMENT; LOG_WARN("partition should not be NULL", K(ret)); } else { - const ObReplicaType& replica_type = partition_guard_.get_partition_group()->get_replica_type(); + const ObReplicaType &replica_type = partition_guard_.get_partition_group()->get_replica_type(); is_replica_with_data = ObReplicaTypeCheck::is_replica_with_ssstore(replica_type); LOG_INFO("get local replica type", K(is_replica_with_data), K(replica_type)); } return ret; } -int ObMigrateCtx::get_restore_clog_info(uint64_t& log_id, int64_t& acc_checksum) const +int ObMigrateCtx::get_restore_clog_info(uint64_t &log_id, int64_t &acc_checksum) const { int ret = OB_SUCCESS; @@ -707,7 +707,7 @@ int ObMigrateCtx::set_is_restore_for_add_replica(const int16_t src_is_restore) return ret; } -int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag*& base_migrate_dag) +int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag *&base_migrate_dag) { int ret = OB_SUCCESS; base_migrate_dag = NULL; @@ -715,7 +715,7 @@ int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag*& base_migrate_dag) ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "replica op arg is invlaid", K(ret), K(*this)); } else if (VALIDATE_BACKUP_OP == replica_op_arg_.type_) { - ObValidateDag* dag = NULL; + ObValidateDag *dag = NULL; if (OB_FAIL(ObDagScheduler::get_instance().alloc_dag(dag))) { LOG_WARN("failed to alloc validate dag", K(ret)); } else if (FALSE_IT(base_migrate_dag = dag)) { @@ -723,7 +723,7 @@ int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag*& base_migrate_dag) LOG_WARN("failed to init validate dag", K(ret)); } } else if (BACKUP_BACKUPSET_OP == replica_op_arg_.type_) { - ObBackupBackupsetDag* dag = NULL; + ObBackupBackupsetDag *dag = NULL; if (OB_FAIL(ObDagScheduler::get_instance().alloc_dag(dag))) { LOG_WARN("failed to alloc backup backupset dag", K(ret)); } else if (FALSE_IT(base_migrate_dag = dag)) { @@ -731,7 +731,7 @@ int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag*& base_migrate_dag) LOG_WARN("failed to init validate dag", K(ret)); } } else if (BACKUP_ARCHIVELOG_OP == replica_op_arg_.type_) { - ObBackupArchiveLogDag* dag = NULL; + ObBackupArchiveLogDag *dag = NULL; if (OB_FAIL(ObDagScheduler::get_instance().alloc_dag(dag))) { LOG_WARN("failed to alloc backup archivelog dag", K(ret)); } else if (FALSE_IT(base_migrate_dag = dag)) { @@ -739,7 +739,7 @@ int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag*& base_migrate_dag) LOG_WARN("failed to init validate dag", K(ret)); } } else { - ObMigrateDag* dag = NULL; + ObMigrateDag *dag = NULL; if (OB_FAIL(ObDagScheduler::get_instance().alloc_dag(dag))) { LOG_WARN("failed to alloc migrate dag", K(ret)); } else if (FALSE_IT(base_migrate_dag = dag)) { @@ -759,7 +759,12 @@ int ObMigrateCtx::alloc_migrate_dag(ObBaseMigrateDag*& base_migrate_dag) } ObPartitionMigrateCtx::ObPartitionMigrateCtx() - : ObIPartitionMigrateCtx(), copy_info_(), handle_(), is_partition_exist_(true), lock_(), need_reuse_local_minor_(true) + : ObIPartitionMigrateCtx(), + copy_info_(), + handle_(), + is_partition_exist_(true), + lock_(), + need_reuse_local_minor_(true) {} bool ObPartitionMigrateCtx::is_valid() const @@ -782,7 +787,7 @@ void ObPartitionMigrateCtx::reset() need_reuse_local_minor_ = true; } -int ObPartitionMigrateCtx::assign(const ObPartitionMigrateCtx& part_migrate_ctx) +int ObPartitionMigrateCtx::assign(const ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; if (!part_migrate_ctx.is_valid()) { @@ -800,10 +805,10 @@ int ObPartitionMigrateCtx::assign(const ObPartitionMigrateCtx& part_migrate_ctx) return ret; } -int ObPartitionMigrateCtx::add_sstable(ObSSTable& sstable) +int ObPartitionMigrateCtx::add_sstable(ObSSTable &sstable) { int ret = OB_SUCCESS; - ObIPartitionGroup* pg = NULL; + ObIPartitionGroup *pg = NULL; const int64_t max_kept_major_version_number = 0; const bool in_slog_trans = false; @@ -840,7 +845,7 @@ ObMigrateRecoveryPointCtx::~ObMigrateRecoveryPointCtx() reset(); } -int ObMigrateRecoveryPointCtx::init(ObMigrateCtx& migrate_ctx) +int ObMigrateRecoveryPointCtx::init(ObMigrateCtx &migrate_ctx) { int ret = OB_SUCCESS; if (is_valid()) { @@ -873,7 +878,7 @@ bool ObMigrateRecoveryPointCtx::is_valid() const return tables_handle_map_.created() && recovery_point_index_ >= 0 && recovery_point_key_array_.count() >= 0; } -int ObMigrateRecoveryPointCtx::add_sstable(ObSSTable& sstable) +int ObMigrateRecoveryPointCtx::add_sstable(ObSSTable &sstable) { int ret = OB_SUCCESS; ObTableHandle table_handle; @@ -893,7 +898,7 @@ int ObMigrateRecoveryPointCtx::add_sstable(ObSSTable& sstable) } int ObMigrateRecoveryPointCtx::get_recovery_point_info( - const int64_t recovery_point_index, ObRecoveryPointKey& recovery_point_key) + const int64_t recovery_point_index, ObRecoveryPointKey &recovery_point_key) { int ret = OB_SUCCESS; recovery_point_key.reset(); @@ -910,7 +915,7 @@ int ObMigrateRecoveryPointCtx::get_recovery_point_info( return ret; } -int ObMigrateRecoveryPointCtx::get_current_recovery_point_info(ObRecoveryPointKey& recovery_point_key) +int ObMigrateRecoveryPointCtx::get_current_recovery_point_info(ObRecoveryPointKey &recovery_point_key) { int ret = OB_SUCCESS; recovery_point_key.reset(); @@ -926,10 +931,10 @@ int ObMigrateRecoveryPointCtx::get_current_recovery_point_info(ObRecoveryPointKe return ret; } -int ObMigrateRecoveryPointCtx::add_sstable(ObTableHandle& table_handle) +int ObMigrateRecoveryPointCtx::add_sstable(ObTableHandle &table_handle) { int ret = OB_SUCCESS; - ObITable* table = NULL; + ObITable *table = NULL; if (!is_valid()) { ret = OB_NOT_INIT; @@ -960,7 +965,7 @@ bool ObMigrateRecoveryPointCtx::is_recovery_point_index_valid() const return recovery_point_index_ >= 0 && recovery_point_index_ <= recovery_point_key_array_.count(); } -int ObMigrateRecoveryPointCtx::get_sstable(const ObITable::TableKey& table_key, ObTableHandle& table_handle) +int ObMigrateRecoveryPointCtx::get_sstable(const ObITable::TableKey &table_key, ObTableHandle &table_handle) { int ret = OB_SUCCESS; table_handle.reset(); @@ -984,7 +989,7 @@ bool ObMigrateRecoveryPointCtx::is_tables_handle_empty() const return 0 == tables_handle_map_.size(); } -int ObMigrateRecoveryPointCtx::get_all_recovery_point_key(ObIArray& recovery_point_key_array) +int ObMigrateRecoveryPointCtx::get_all_recovery_point_key(ObIArray &recovery_point_key_array) { int ret = OB_SUCCESS; if (!is_valid()) { @@ -996,7 +1001,7 @@ int ObMigrateRecoveryPointCtx::get_all_recovery_point_key(ObIArray& table_key_set) +int ObMigrateRecoveryPointCtx::remove_unneed_table_handle(const ObHashSet &table_key_set) { int ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; @@ -1009,7 +1014,7 @@ int ObMigrateRecoveryPointCtx::remove_unneed_table_handle(const ObHashSetfirst; + const ObITable::TableKey &table_key = iter->first; hash_ret = table_key_set.exist_refactored(table_key); if (OB_HASH_EXIST == hash_ret) { } else if (OB_HASH_NOT_EXIST == hash_ret) { @@ -1022,7 +1027,7 @@ int ObMigrateRecoveryPointCtx::remove_unneed_table_handle(const ObHashSetis_restore_; ObTablesHandle sstables_handle; // empty ctx_->pg_meta_.storage_info_.set_pg_file_id(OB_INVALID_DATA_FILE_ID); // for create a new pg_file in ofs mode - const ObSavedStorageInfoV2& saved_storage_info = ctx_->pg_meta_.storage_info_; - const ObPartitionSplitInfo& split_info = ctx_->pg_meta_.split_info_; + const ObSavedStorageInfoV2 &saved_storage_info = ctx_->pg_meta_.storage_info_; + const ObPartitionSplitInfo &split_info = ctx_->pg_meta_.split_info_; int64_t split_state = ctx_->pg_meta_.saved_split_state_; // 221 and 222 observer may set split_state = -1, upgrade to 224 may has problem, now set split_state = 1 directly if (-1 == split_state) { split_state = 1; LOG_WARN("split state was -1, should be rewritten to 1", "pkey", ctx_->pg_meta_.pg_key_); } - const ObBaseStorageInfo& clog_info = saved_storage_info.get_clog_info(); + const ObBaseStorageInfo &clog_info = saved_storage_info.get_clog_info(); common::ObReplicaType replica_type = replica_op_arg.dst_.get_replica_type(); const int64_t memstore_percent = replica_op_arg.dst_.get_memstore_percent(); ObCreatePGParam param; @@ -1207,14 +1212,14 @@ int ObMigratePrepareTask::create_new_partition(const ObAddr& src_server, ObRepli partition->get_pg_storage().is_restoring_standby()))) { } else if (need_create_memtable && OB_FAIL(partition->create_memtable(in_slog_trans))) { STORAGE_LOG(WARN, "fail to create memtable", K(ret)); - // pause it to make sure the sstable upper trans version is update after migration finished. + // pause it to make sure the sstable upper trans version is update after migration finished. } else if (need_create_memtable && OB_FALSE_IT(partition->get_pg_storage().pause())) { } else { file_handle.reset(); // create new partition need set schema_version in pg meta in order to prevent gc for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - const ObMigratePartitionInfo& copy_info = ctx_->part_ctx_array_.at(i).copy_info_; - const ObPGPartitionStoreMeta& meta = copy_info.meta_; + const ObMigratePartitionInfo ©_info = ctx_->part_ctx_array_.at(i).copy_info_; + const ObPGPartitionStoreMeta &meta = copy_info.meta_; if (!meta.pkey_.is_trans_table() && OB_FAIL(create_pg_partition(meta, partition, in_slog_trans))) { LOG_WARN("failed to create pg partition", K(ret), K(meta)); } @@ -1286,7 +1291,7 @@ void ObPartitionMigrator::wait() STORAGE_LOG(INFO, "ObPartitionMigrator stopped"); } -int ObMigrateTaskSchedulerTask::add_migrate_status(ObMigrateCtx* ctx) +int ObMigrateTaskSchedulerTask::add_migrate_status(ObMigrateCtx *ctx) { int ret = OB_SUCCESS; @@ -1307,7 +1312,7 @@ int ObMigrateTaskSchedulerTask::add_migrate_status(ObMigrateCtx* ctx) return ret; } -int ObMigratePrepareTask::add_partition_migration_status(const ObMigrateCtx& ctx) +int ObMigratePrepareTask::add_partition_migration_status(const ObMigrateCtx &ctx) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -1347,7 +1352,7 @@ int ObMigratePrepareTask::add_partition_migration_status(const ObMigrateCtx& ctx return ret; } -int ObMigrateCtx::fill_comment(char* buf, const int64_t buf_len) const +int ObMigrateCtx::fill_comment(char *buf, const int64_t buf_len) const { // static function, no need check is_inited_ int ret = OB_SUCCESS; @@ -1376,16 +1381,16 @@ int ObMigrateCtx::fill_comment(char* buf, const int64_t buf_len) const return ret; } -ObPartitionMigrator& ObPartitionMigrator::get_instance() +ObPartitionMigrator &ObPartitionMigrator::get_instance() { static ObPartitionMigrator migrator_instance_; return migrator_instance_; } -int ObPartitionMigrator::init(obrpc::ObPartitionServiceRpcProxy& srv_rpc_proxy, ObPartitionServiceRpc& pts_rpc, - ObIPartitionComponentFactory* cp_fty, ObPartitionService* partition_service, - common::ObInOutBandwidthThrottle& bandwidth_throttle, share::ObIPartitionLocationCache* location_cache, - share::schema::ObMultiVersionSchemaService* schema_service) +int ObPartitionMigrator::init(obrpc::ObPartitionServiceRpcProxy &srv_rpc_proxy, ObPartitionServiceRpc &pts_rpc, + ObIPartitionComponentFactory *cp_fty, ObPartitionService *partition_service, + common::ObInOutBandwidthThrottle &bandwidth_throttle, share::ObIPartitionLocationCache *location_cache, + share::schema::ObMultiVersionSchemaService *schema_service) { int ret = OB_SUCCESS; common::SpinWLockGuard guard(lock_); @@ -1420,9 +1425,9 @@ int ObPartitionMigrator::init(obrpc::ObPartitionServiceRpcProxy& srv_rpc_proxy, return ret; } -const char* ObMigrateCtx::trans_action_to_str(const MigrateAction& action) +const char *ObMigrateCtx::trans_action_to_str(const MigrateAction &action) { - const char* str = "UNKNOWN"; + const char *str = "UNKNOWN"; switch (action) { case INIT: @@ -1515,13 +1520,13 @@ bool ObPartGroupMigrator::is_stop() const return is_stop_; } -ObPartGroupMigrator& ObPartGroupMigrator::get_instance() +ObPartGroupMigrator &ObPartGroupMigrator::get_instance() { static ObPartGroupMigrator group_migrator; return group_migrator; } -int ObPartGroupMigrator::init(storage::ObPartitionService* partition_service, ObIPartitionComponentFactory* cp_fty) +int ObPartGroupMigrator::init(storage::ObPartitionService *partition_service, ObIPartitionComponentFactory *cp_fty) { int ret = OB_SUCCESS; @@ -1539,12 +1544,12 @@ int ObPartGroupMigrator::init(storage::ObPartitionService* partition_service, Ob return ret; } -int ObPartGroupMigrator::schedule(const ObReplicaOpArg& arg, const share::ObTaskId& task_id) +int ObPartGroupMigrator::schedule(const ObReplicaOpArg &arg, const share::ObTaskId &task_id) { int ret = OB_SUCCESS; // task will be executed directly when it is scheduled and will be release when it execute over, // so this task point address will not keep effective - ObPartGroupTask* group_task = NULL; + ObPartGroupTask *group_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1566,13 +1571,13 @@ int ObPartGroupMigrator::schedule(const ObReplicaOpArg& arg, const share::ObTask return ret; } -int ObPartGroupMigrator::schedule(const ObIArray& arg_list, const share::ObTaskId& task_id) +int ObPartGroupMigrator::schedule(const ObIArray &arg_list, const share::ObTaskId &task_id) { int ret = OB_SUCCESS; const bool is_batch_mode = true; // task will be executed directly when it is scheduled and will be release when it execute over, // so this task point address will not keep effective - ObPartGroupTask* group_task = NULL; + ObPartGroupTask *group_task = NULL; bool is_normal_migrate = true; if (!is_inited_) { @@ -1587,7 +1592,7 @@ int ObPartGroupMigrator::schedule(const ObIArray& arg_list, cons return ret; } -int ObPartGroupMigrator::mark(const ObReplicaOpArg& arg, const share::ObTaskId& task_id, ObPartGroupTask*& group_task) +int ObPartGroupMigrator::mark(const ObReplicaOpArg &arg, const share::ObTaskId &task_id, ObPartGroupTask *&group_task) { // only remove replica task finsih is control outside, so allo outside call group_task to finish int ret = OB_SUCCESS; @@ -1617,7 +1622,7 @@ int ObPartGroupMigrator::mark(const ObReplicaOpArg& arg, const share::ObTaskId& return ret; } -int ObPartGroupMigrator::get_not_finish_task_count(DoingTaskStat& stat) +int ObPartGroupMigrator::get_not_finish_task_count(DoingTaskStat &stat) { // caller must hold lock int ret = OB_SUCCESS; @@ -1648,11 +1653,11 @@ int ObPartGroupMigrator::get_not_finish_task_count(DoingTaskStat& stat) return ret; } -static inline bool task_need_data_copy(const ObIArray& task_list) +static inline bool task_need_data_copy(const ObIArray &task_list) { bool bool_ret = false; for (int64_t i = 0; i < task_list.count() && !bool_ret; ++i) { - const ObReplicaOpArg& task = task_list.at(i); + const ObReplicaOpArg &task = task_list.at(i); if (REMOVE_REPLICA_OP != task.type_) { bool_ret = true; } @@ -1660,7 +1665,7 @@ static inline bool task_need_data_copy(const ObIArray& task_list return bool_ret; } -int ObPartGroupMigrator::has_task(const ObPartitionKey& pkey, bool& has_task) +int ObPartGroupMigrator::has_task(const ObPartitionKey &pkey, bool &has_task) { int ret = OB_SUCCESS; ObArray pkey_list; @@ -1683,7 +1688,7 @@ int ObPartGroupMigrator::has_task(const ObPartitionKey& pkey, bool& has_task) return ret; } -int ObPartGroupMigrator::task_exist(const share::ObTaskId& task_id, bool& exist) +int ObPartGroupMigrator::task_exist(const share::ObTaskId &task_id, bool &exist) { int ret = OB_SUCCESS; exist = false; @@ -1702,7 +1707,7 @@ int ObPartGroupMigrator::task_exist(const share::ObTaskId& task_id, bool& exist) return ret; } -int ObPartGroupMigrator::check_copy_limit_(const ObIArray& arg_list) +int ObPartGroupMigrator::check_copy_limit_(const ObIArray &arg_list) { int ret = OB_SUCCESS; int64_t data_copy_in_limit = GCONF.server_data_copy_in_concurrency; @@ -1764,12 +1769,12 @@ int ObPartGroupMigrator::check_copy_limit_(const ObIArray& arg_l return ret; } -int ObPartGroupMigrator::inner_schedule(const ObIArray& arg_list, const bool is_batch_mode, - const share::ObTaskId& in_task_id, const bool is_normal_migrate, ObPartGroupTask*& out_group_task) +int ObPartGroupMigrator::inner_schedule(const ObIArray &arg_list, const bool is_batch_mode, + const share::ObTaskId &in_task_id, const bool is_normal_migrate, ObPartGroupTask *&out_group_task) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; - ObPartGroupTask* group_task = NULL; + ObPartGroupTask *group_task = NULL; share::ObTaskId task_id = in_task_id; // copy it DEBUG_SYNC(BEFORE_OBSERVER_SCHEDULE_MIGRATE); @@ -1778,6 +1783,9 @@ int ObPartGroupMigrator::inner_schedule(const ObIArray& arg_list if (!is_inited_) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "not inited", K(ret)); + } else if (is_stop()) { + ret = OB_SERVER_IS_STOPPING; + STORAGE_LOG(WARN, "observer is stopping", K(ret)); } else if (OB_FAIL(check_arg_list(arg_list))) { STORAGE_LOG(WARN, "arg_list is empty", K(ret), K(arg_list)); } else if (OB_FAIL(check_copy_limit_(arg_list))) { @@ -1812,7 +1820,7 @@ int ObPartGroupMigrator::inner_schedule(const ObIArray& arg_list } // static func -int ObPartGroupMigrator::check_arg_list(const ObIArray& arg_list) +int ObPartGroupMigrator::check_arg_list(const ObIArray &arg_list) { int ret = OB_SUCCESS; ObReplicaOpType type = UNKNOWN_REPLICA_OP; @@ -1840,7 +1848,7 @@ int ObPartGroupMigrator::check_arg_list(const ObIArray& arg_list return ret; } -int ObPartGroupMigrator::check_dup_task(const ObPartGroupTask& task) +int ObPartGroupMigrator::check_dup_task(const ObPartGroupTask &task) { // caller must hold update_task_list_lock_ int ret = OB_SUCCESS; @@ -1862,7 +1870,7 @@ int ObPartGroupMigrator::check_dup_task(const ObPartGroupTask& task) return ret; } -int ObPartGroupMigrator::check_dup_task(const ObIArray& pkey_list) +int ObPartGroupMigrator::check_dup_task(const ObIArray &pkey_list) { // caller must hold update_task_list_lock_ int ret = OB_SUCCESS; @@ -1881,11 +1889,11 @@ int ObPartGroupMigrator::check_dup_task(const ObIArray& pkey_lis return ret; } -int ObPartGroupMigrator::schedule_group_migrate_dag(ObPartGroupTask*& group_task) +int ObPartGroupMigrator::schedule_group_migrate_dag(ObPartGroupTask *&group_task) { int ret = OB_SUCCESS; - ObGroupMigrateDag* dag = NULL; - ObGroupMigrateExecuteTask* task = NULL; + ObGroupMigrateDag *dag = NULL; + ObGroupMigrateExecuteTask *task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -1919,7 +1927,7 @@ int ObPartGroupMigrator::schedule_group_migrate_dag(ObPartGroupTask*& group_task return ret; } -int ObPartGroupMigrator::remove_finish_task(ObPartGroupTask* group_task) +int ObPartGroupMigrator::remove_finish_task(ObPartGroupTask *group_task) { int ret = OB_SUCCESS; bool found = false; @@ -1934,7 +1942,7 @@ int ObPartGroupMigrator::remove_finish_task(ObPartGroupTask* group_task) { common::SpinWLockGuard guard(update_task_list_lock_); for (int64_t i = task_list_.count() - 1; OB_SUCC(ret) && !found && i >= 0; --i) { - ObPartGroupTask* task = task_list_[i]; + ObPartGroupTask *task = task_list_[i]; ; if (task == group_task) { found = true; @@ -1963,15 +1971,15 @@ void ObPartGroupMigrator::wakeup() { common::SpinRLockGuard guard(update_task_list_lock_); for (int64_t i = 0; i < task_list_.count(); ++i) { - ObPartGroupTask* task = task_list_[i]; + ObPartGroupTask *task = task_list_[i]; if (NULL != task) { task->wakeup(); } } } -int ObPartGroupMigrator::get_group_task(const ObIArray& arg_list, const bool is_batch_mode, - const share::ObTaskId& in_task_id, ObPartGroupTask*& group_task) +int ObPartGroupMigrator::get_group_task(const ObIArray &arg_list, const bool is_batch_mode, + const share::ObTaskId &in_task_id, ObPartGroupTask *&group_task) { int ret = OB_SUCCESS; group_task = NULL; @@ -1985,7 +1993,7 @@ int ObPartGroupMigrator::get_group_task(const ObIArray& arg_list } else { const ObReplicaOpType type = arg_list.at(0).type_; if (BACKUP_REPLICA_OP == type) { - ObPartGroupBackupTask* backup_group_task = NULL; + ObPartGroupBackupTask *backup_group_task = NULL; if (NULL == (backup_group_task = cp_fty_->get_part_group_backup_task())) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "failed to alloc group task", K(ret)); @@ -1994,7 +2002,7 @@ int ObPartGroupMigrator::get_group_task(const ObIArray& arg_list STORAGE_LOG(WARN, "failed to init group task", K(ret)); } } else { - ObPartGroupMigrationTask* migration_group_task = NULL; + ObPartGroupMigrationTask *migration_group_task = NULL; if (NULL == (migration_group_task = cp_fty_->get_part_group_migration_task())) { ret = OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "failed to alloc group task", K(ret)); @@ -2034,7 +2042,7 @@ bool ObPartGroupTask::is_finish() const return is_finished_; } -int ObPartGroupTask::get_pkey_list(ObIArray& pkey_list) const +int ObPartGroupTask::get_pkey_list(ObIArray &pkey_list) const { int ret = OB_SUCCESS; @@ -2054,7 +2062,7 @@ int ObPartGroupTask::get_pkey_list(ObIArray& pkey_list) const return ret; } -int ObPartGroupTask::check_dup_task(const ObIArray& pkey_list) const +int ObPartGroupTask::check_dup_task(const ObIArray &pkey_list) const { // Check duplicate task just use pkey, so it do not has concurrency. No need lock int ret = OB_SUCCESS; @@ -2142,10 +2150,10 @@ int ObPartGroupTask::check_self_dup_task() const return ret; } -int ObPartGroupTask::set_part_task_start(const ObPartitionKey& pkey, const int64_t backup_set_id) +int ObPartGroupTask::set_part_task_start(const ObPartitionKey &pkey, const int64_t backup_set_id) { int ret = OB_SUCCESS; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; { common::SpinWLockGuard guard(lock_); @@ -2184,11 +2192,11 @@ int ObPartGroupTask::set_part_task_start(const ObPartitionKey& pkey, const int64 return ret; } -int ObPartGroupTask::set_part_task_finish(const ObPartitionKey& pkey, const int32_t result, - const share::ObTaskId& part_task_id, const bool during_migrating, const int64_t backup_set_id) +int ObPartGroupTask::set_part_task_finish(const ObPartitionKey &pkey, const int32_t result, + const share::ObTaskId &part_task_id, const bool during_migrating, const int64_t backup_set_id) { int ret = OB_SUCCESS; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; { common::SpinWLockGuard guard(lock_); @@ -2254,7 +2262,7 @@ int ObPartGroupTask::set_part_task_finish(const ObPartitionKey& pkey, const int3 return ret; } -int ObPartGroupTask::build_migrate_ctx(const ObReplicaOpArg& arg, ObMigrateCtx& migrate_ctx) +int ObPartGroupTask::build_migrate_ctx(const ObReplicaOpArg &arg, ObMigrateCtx &migrate_ctx) { int ret = OB_SUCCESS; @@ -2303,7 +2311,7 @@ void ObPartGroupTask::dump_task_status() STORAGE_LOG(ERROR, "not inited", K(tmp_ret)); } else { for (int64_t i = 0; OB_SUCCESS == tmp_ret && i < task_list_.count(); ++i) { - ObPartMigrationTask& task = task_list_[i]; + ObPartMigrationTask &task = task_list_[i]; if (task.status_ < 0 || task.status_ >= ObPartMigrationTask::MAX) { tmp_ret = OB_ERR_SYS; STORAGE_LOG(ERROR, "invalid task stauts", K(tmp_ret), K(i), K(task)); @@ -2370,7 +2378,7 @@ int ObPartGroupTask::check_is_task_cancel() return ret; } -int ObPartGroupTask::check_partition_checksum(const common::ObPartitionKey& pkey) +int ObPartGroupTask::check_partition_checksum(const common::ObPartitionKey &pkey) { int ret = OB_SUCCESS; ModulePageAllocator allocator(ObNewModIds::OB_PARTITION_MIGRATE); @@ -2390,7 +2398,7 @@ int ObPartGroupTask::check_partition_checksum(const common::ObPartitionKey& pkey (ret = united_operator.united_get(pkey.get_table_id(), pkey.get_partition_id(), partition_info))) { STORAGE_LOG(WARN, "fail to get partition info.", K(ret), K(pkey)); } else if (partition_info.replica_count() > 1) { - const common::ObIArray& replicas = partition_info.get_replicas_v2(); + const common::ObIArray &replicas = partition_info.get_replicas_v2(); int64_t lastIdx = -1; for (int64_t i = 0; OB_SUCC(ret) && i < replicas.count(); ++i) { if (replicas.at(i).replica_type_ == REPLICA_TYPE_LOGONLY || replicas.at(i).is_restore_ != 0 || @@ -2422,11 +2430,11 @@ int ObPartGroupTask::check_partition_checksum(const common::ObPartitionKey& pkey return ret; } -int ObPartGroupTask::check_is_tenant_exist(bool& is_exist) +int ObPartGroupTask::check_is_tenant_exist(bool &is_exist) { int ret = OB_SUCCESS; share::schema::ObSchemaGetterGuard schema_guard; - share::schema::ObMultiVersionSchemaService& schema_service = + share::schema::ObMultiVersionSchemaService &schema_service = share::schema::ObMultiVersionSchemaService::get_instance(); is_exist = true; @@ -2442,11 +2450,11 @@ int ObPartGroupTask::check_is_tenant_exist(bool& is_exist) return ret; } -int ObPartGroupTask::check_is_partition_exist(const common::ObPartitionKey& pkey, bool& is_exist) +int ObPartGroupTask::check_is_partition_exist(const common::ObPartitionKey &pkey, bool &is_exist) { int ret = OB_SUCCESS; share::schema::ObSchemaGetterGuard schema_guard; - share::schema::ObMultiVersionSchemaService& schema_service = + share::schema::ObMultiVersionSchemaService &schema_service = share::schema::ObMultiVersionSchemaService::get_instance(); const uint64_t fetch_tenant_id = is_inner_table(pkey.get_table_id()) ? OB_SYS_TENANT_ID : pkey.get_tenant_id(); bool check_dropped_partition = true; @@ -2466,7 +2474,7 @@ int ObPartGroupTask::check_is_partition_exist(const common::ObPartitionKey& pkey } int ObPartGroupTask::check_can_as_data_source( - const ObReplicaOpType& op, const ObReplicaType& src_type, const ObReplicaType& dst_type, bool& as_data_source) + const ObReplicaOpType &op, const ObReplicaType &src_type, const ObReplicaType &dst_type, bool &as_data_source) { int ret = OB_SUCCESS; as_data_source = false; @@ -2485,7 +2493,7 @@ int ObPartGroupTask::check_can_as_data_source( } int ObPartGroupTask::build_failed_report_list( - const int32_t first_fail_code, ObIArray& report_list) + const int32_t first_fail_code, ObIArray &report_list) { // static func int ret = OB_SUCCESS; @@ -2502,7 +2510,7 @@ int ObPartGroupTask::build_failed_report_list( } int ObPartGroupTask::set_report_list_result( - ObIArray& report_list, const ObPartitionKey& pkey, const int32_t result) + ObIArray &report_list, const ObPartitionKey &pkey, const int32_t result) { int ret = OB_SUCCESS; @@ -2526,7 +2534,7 @@ int ObPartGroupTask::set_report_list_result( return ret; } -int ObPartGroupTask::fill_report_list(bool& is_batch_mode, ObIArray& report_list) +int ObPartGroupTask::fill_report_list(bool &is_batch_mode, ObIArray &report_list) { int ret = OB_SUCCESS; common::SpinRLockGuard guard(lock_); @@ -2587,8 +2595,8 @@ ObPartGroupMigrationTask::~ObPartGroupMigrationTask() if (task_list_[i].need_reset_migrate_status_) { DEBUG_SYNC(BEFORE_CLEAR_MIGRATE_STATUS); bool need_retry = false; - ObIPartitionGroup* partition = NULL; - ObPGStorage* pg_storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGStorage *pg_storage = NULL; ObMigrateStatus cur_migrate_status = OB_MIGRATE_STATUS_NONE; ObMigrateStatus new_migrate_status = OB_MIGRATE_STATUS_NONE; @@ -2662,8 +2670,8 @@ ObPartGroupMigrationTask::~ObPartGroupMigrationTask() } } -int ObPartGroupMigrationTask::init(const ObIArray& task_list, const bool is_batch_mode, - storage::ObPartitionService* partition_service, const share::ObTaskId& task_id) +int ObPartGroupMigrationTask::init(const ObIArray &task_list, const bool is_batch_mode, + storage::ObPartitionService *partition_service, const share::ObTaskId &task_id) { int ret = OB_SUCCESS; SMART_VAR(ObPartMigrationTask, tmp_task) @@ -2764,13 +2772,13 @@ int ObPartGroupMigrationTask::do_task() ret = OB_ERR_UNEXPECTED; LOG_WARN("restore task_list_ is empty", K(ret), K(type_), K(task_list_.count())); } else if (task_list_[0].arg_.is_physical_restore_leader()) { - const share::ObPhysicalRestoreArg& restore_arg = task_list_[0].arg_.phy_restore_arg_; + const share::ObPhysicalRestoreArg &restore_arg = task_list_[0].arg_.phy_restore_arg_; if (OB_FAIL(init_restore_meta_index_(restore_arg))) { LOG_WARN("failed to init meta index", K(ret), K(restore_arg)); } } } else if (VALIDATE_BACKUP_OP == type_) { - const share::ObPhysicalValidateArg& validate_arg = task_list_[0].arg_.validate_arg_; + const share::ObPhysicalValidateArg &validate_arg = task_list_[0].arg_.validate_arg_; ObBackupBaseDataPathInfo path_info; if (!validate_arg.is_valid()) { ret = OB_INVALID_ARGUMENT; @@ -2849,7 +2857,7 @@ int ObPartGroupMigrationTask::remove_member_list_if_need() SMART_VAR(ObReportPartMigrationTask, tmp_task) { for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& sub_task = task_list_[i]; + ObPartMigrationTask &sub_task = task_list_[i]; tmp_task.arg_ = sub_task.arg_; tmp_task.status_ = sub_task.status_; tmp_task.result_ = sub_task.result_; @@ -2875,7 +2883,7 @@ int ObPartGroupMigrationTask::remove_member_list_if_need() K(task_list_.count())); } else { for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { - ObPartMigrationTask& sub_task = task_list_[i]; + ObPartMigrationTask &sub_task = task_list_[i]; sub_task.result_ = report_list.at(i).result_; } } @@ -2892,7 +2900,7 @@ int ObPartGroupMigrationTask::remove_member_list_if_need() return ret; } -int ObPartGroupMigrationTask::check_need_batch_remove_member(ObAddr& leader_addr, bool& need_remove, bool& need_batch) +int ObPartGroupMigrationTask::check_need_batch_remove_member(ObAddr &leader_addr, bool &need_remove, bool &need_batch) { int ret = OB_SUCCESS; ObMigrateSrcInfo tmp_src_info; @@ -2913,13 +2921,13 @@ int ObPartGroupMigrationTask::check_need_batch_remove_member(ObAddr& leader_addr } else { ObReplicaType src_type = task_list_.at(0).arg_.src_.get_replica_type(); ObReplicaType dest_type = task_list_.at(0).arg_.dst_.get_replica_type(); - const ObAddr& self_addr = partition_service_->get_self_addr(); + const ObAddr &self_addr = partition_service_->get_self_addr(); // For batch operations of this type, rs guarantees src_type and dest_type must be consistent with the local, // or an error will be report directly for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { ObIPartitionGroupGuard guard; - ObPartMigrationTask& task = task_list_.at(i); + ObPartMigrationTask &task = task_list_.at(i); if (OB_FAIL(ObPartitionService::get_instance().get_partition(task.arg_.key_, guard))) { LOG_WARN("failed to get partition guard", K(ret), "arg", task.arg_); } else if (OB_ISNULL(guard.get_partition_group())) { @@ -2952,7 +2960,7 @@ int ObPartGroupMigrationTask::check_need_batch_remove_member(ObAddr& leader_addr LOG_INFO("need remove member list first"); need_remove = true; for (int64_t i = 0; OB_SUCC(ret) && need_batch && i < task_list_.count(); ++i) { - const ObReplicaOpArg& arg = task_list_.at(i).arg_; + const ObReplicaOpArg &arg = task_list_.at(i).arg_; if (OB_FAIL(ObMigrateGetLeaderUtil::get_leader(arg.key_, tmp_src_info, true /*force_update*/))) { STORAGE_LOG(WARN, "failed to get leader address", K(ret), K(arg.key_)); } else if (!tmp_src_info.is_valid()) { @@ -3007,7 +3015,7 @@ int ObPartGroupMigrationTask::try_single_remove_member() } else { dummy_id.init(partition_service_->get_self_addr()); for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - const ObReplicaOpArg& arg = task_list_.at(i).arg_; + const ObReplicaOpArg &arg = task_list_.at(i).arg_; int64_t dummy_orig_quorum = OB_INVALID_COUNT; // only used in ObPartitionService::batch_remove_replica_mc obrpc::ObMemberChangeArg remove_arg = { arg.key_, arg.src_, false, arg.quorum_, dummy_orig_quorum, WITHOUT_MODIFY_QUORUM, dummy_id}; // mock task id @@ -3025,10 +3033,10 @@ int ObPartGroupMigrationTask::try_single_remove_member() return ret; } -int ObPartGroupMigrationTask::set_create_new_pg(const ObPartitionKey& pg_key) +int ObPartGroupMigrationTask::set_create_new_pg(const ObPartitionKey &pg_key) { int ret = OB_SUCCESS; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; common::SpinWLockGuard guard(lock_); if (!is_inited_) { ret = OB_NOT_INIT; @@ -3049,11 +3057,11 @@ int ObPartGroupMigrationTask::set_create_new_pg(const ObPartitionKey& pg_key) return ret; } -int ObPartGroupMigrationTask::set_migrate_in(ObPGStorage& pg_storage) +int ObPartGroupMigrationTask::set_migrate_in(ObPGStorage &pg_storage) { int ret = OB_SUCCESS; - ObPartMigrationTask* task = NULL; - const ObPartitionKey& pkey = pg_storage.get_partition_key(); // TODO () change it to pg key + ObPartMigrationTask *task = NULL; + const ObPartitionKey &pkey = pg_storage.get_partition_key(); // TODO () change it to pg key int64_t current_ts = ObTimeUtility::current_time(); ObMigrateStatus old_status = OB_MIGRATE_STATUS_MAX; ObMigrateStatus new_status = OB_MIGRATE_STATUS_MAX; @@ -3152,8 +3160,8 @@ int ObPartGroupMigrationTask::check_partition_validation() STORAGE_LOG(ERROR, "not inited", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& sub_task = task_list_[i]; - ObPartitionKey& pkey = sub_task.arg_.key_; + ObPartMigrationTask &sub_task = task_list_[i]; + ObPartitionKey &pkey = sub_task.arg_.key_; bool in_member_list = false; bool is_working_partition = partition_service_->is_working_partition(pkey); @@ -3219,7 +3227,7 @@ int ObPartGroupMigrationTask::check_disk_space() STORAGE_LOG(INFO, "only migrate or add replica task need check disk space, others skip it", K(type_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartitionKey& pkey = task_list_[i].arg_.key_; + ObPartitionKey &pkey = task_list_[i].arg_.key_; if (ObPartGroupMigrator::get_instance().is_stop()) { ret = OB_SERVER_IS_STOPPING; STORAGE_LOG(WARN, "server is stopping", K(ret)); @@ -3261,7 +3269,7 @@ int ObPartGroupMigrationTask::check_before_backup() ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "replica op is not backup, no need check", K(ret)); } else { - const ObPhysicalBackupArg& backup_arg = task_list_[0].arg_.backup_arg_; + const ObPhysicalBackupArg &backup_arg = task_list_[0].arg_.backup_arg_; const uint64_t tenant_id = task_list_[0].arg_.key_.get_tenant_id(); if (OB_FAIL(backup_dest.set(backup_arg.uri_header_, backup_arg.storage_info_))) { STORAGE_LOG(WARN, "failed to set backup dest", K(ret), K(backup_arg)); @@ -3283,11 +3291,11 @@ int ObPartGroupMigrationTask::check_before_backup() return ret; } -int ObPartGroupMigrationTask::get_partition_required_size(const common::ObPartitionKey& pkey, int64_t& required_size) +int ObPartGroupMigrationTask::get_partition_required_size(const common::ObPartitionKey &pkey, int64_t &required_size) { // statuc func int ret = OB_SUCCESS; - share::ObPartitionTableOperator* pt_operator = NULL; + share::ObPartitionTableOperator *pt_operator = NULL; ModulePageAllocator allocator(ObNewModIds::OB_PARTITION_MIGRATE); share::ObPartitionInfo partition_info; partition_info.set_allocator(&allocator); @@ -3299,7 +3307,7 @@ int ObPartGroupMigrationTask::get_partition_required_size(const common::ObPartit } else if (OB_SUCCESS != (ret = pt_operator->get(pkey.get_table_id(), pkey.get_partition_id(), partition_info))) { STORAGE_LOG(WARN, "fail to get partition info.", K(ret), K(pkey)); } else { - const common::ObIArray& replicas = partition_info.get_replicas_v2(); + const common::ObIArray &replicas = partition_info.get_replicas_v2(); for (int64_t i = 0; OB_SUCC(ret) && i < replicas.count(); ++i) { if (replicas.at(i).required_size_ > required_size) { required_size = replicas.at(i).required_size_; @@ -3348,7 +3356,7 @@ int ObPartGroupMigrationTask::try_schedule_new_partition_migration() } // caller must not hold wlock -int ObPartGroupMigrationTask::schedule_migrate_dag(ObMigrateCtx& migrate_ctx) +int ObPartGroupMigrationTask::schedule_migrate_dag(ObMigrateCtx &migrate_ctx) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3396,7 +3404,7 @@ int ObPartGroupMigrationTask::try_finish_group_migration() common::SpinWLockGuard guard(lock_); for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& task = task_list_[i]; + ObPartMigrationTask &task = task_list_[i]; if (ObPartMigrationTask::FINISH != task.status_) { if (OB_SUCCESS != first_error_code_ && ObPartMigrationTask::INIT == task.status_) { task.status_ = ObPartMigrationTask::FINISH; @@ -3422,7 +3430,7 @@ int ObPartGroupMigrationTask::try_finish_group_migration() STORAGE_LOG(WARN, "failed to reserve report list", K(ret)); } for (int64_t i = 0; OB_SUCC(ret) && i < task_list_.count(); ++i) { - ObPartMigrationTask& sub_task = task_list_[i]; + ObPartMigrationTask &sub_task = task_list_[i]; tmp_task.arg_ = sub_task.arg_; tmp_task.status_ = ObIPartMigrationTask::FINISH; tmp_task.result_ = sub_task.result_; @@ -3449,7 +3457,7 @@ int ObPartGroupMigrationTask::try_finish_group_migration() return ret; } -int ObPartGroupMigrationTask::finish_group_migration(ObIArray& report_list) +int ObPartGroupMigrationTask::finish_group_migration(ObIArray &report_list) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3531,7 +3539,7 @@ int ObPartGroupMigrationTask::finish_group_migration(ObIArrayreport_migrate_in_indexes(pkey))) { STORAGE_LOG(WARN, "failed to handle_report_meta_table_callback", K(tmp_ret), K(i), K(report_list.at(i))); } @@ -3545,7 +3553,7 @@ int ObPartGroupMigrationTask::finish_group_migration(ObIArrayget_rebuild_replica_service().get_scheduler(); if (OB_SUCC(ret) && REBUILD_REPLICA_OP == type_) { ObRebuildReplicaResult results; @@ -3589,7 +3597,7 @@ int ObPartGroupMigrationTask::report_restore_fatal_error_() } int ObPartGroupMigrationTask::try_change_member_list( - ObIArray& report_list, bool& is_all_finish) + ObIArray &report_list, bool &is_all_finish) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3665,7 +3673,7 @@ int ObPartGroupMigrationTask::try_change_member_list( } int ObPartGroupMigrationTask::check_need_batch_change_member_list( - const ObAddr& leader_addr, ObIArray& report_list, bool& need_batch) + const ObAddr &leader_addr, ObIArray &report_list, bool &need_batch) { int ret = OB_SUCCESS; ObMigrateSrcInfo tmp_leader_info; @@ -3681,7 +3689,7 @@ int ObPartGroupMigrationTask::check_need_batch_change_member_list( } else { need_batch = true; for (int64_t i = 0; OB_SUCC(ret) && need_batch && i < report_list.count(); ++i) { - const ObReplicaOpArg& arg = report_list.at(i).arg_; + const ObReplicaOpArg &arg = report_list.at(i).arg_; if (MIGRATE_REPLICA_OP == arg.type_ || FAST_MIGRATE_REPLICA_OP == arg.type_) { if (!ObReplicaTypeCheck::is_paxos_replica(arg.dst_.get_replica_type())) { need_batch = false; @@ -3738,7 +3746,7 @@ int ObPartGroupMigrationTask::check_need_batch_change_member_list( } int ObPartGroupMigrationTask::fast_migrate_add_member_list_one_by_one( - common::ObIArray& report_list, bool& is_all_finish) + common::ObIArray &report_list, bool &is_all_finish) { int ret = OB_SUCCESS; int64_t start_ts = ObTimeUtility::current_time(); @@ -3755,10 +3763,10 @@ int ObPartGroupMigrationTask::fast_migrate_add_member_list_one_by_one( } int64_t switch_epoch = GCTX.get_switch_epoch2(); for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { - ObReportPartMigrationTask& cur_task = report_list.at(i); - const ObPGKey& pg_key = cur_task.arg_.key_; - ObMigrateCtx* cur_ctx = cur_task.ctx_; - ObIPartitionGroup* pg = nullptr; + ObReportPartMigrationTask &cur_task = report_list.at(i); + const ObPGKey &pg_key = cur_task.arg_.key_; + ObMigrateCtx *cur_ctx = cur_task.ctx_; + ObIPartitionGroup *pg = nullptr; int64_t quorum = 0; ObMigrateSrcInfo leader_info; ObMember new_member(GCTX.self_addr_, ObTimeUtility::current_time()); @@ -3795,7 +3803,7 @@ int ObPartGroupMigrationTask::fast_migrate_add_member_list_one_by_one( } int ObPartGroupMigrationTask::try_batch_change_member_list( - ObIArray& report_list, const ObAddr& leader_addr, bool& is_all_finish) + ObIArray &report_list, const ObAddr &leader_addr, bool &is_all_finish) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3837,7 +3845,7 @@ int ObPartGroupMigrationTask::try_batch_change_member_list( K(report_list)); } else if (FAST_MIGRATE_REPLICA_OP == type_) { for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { - ObReportPartMigrationTask& report_task = report_list.at(i); + ObReportPartMigrationTask &report_task = report_list.at(i); if (OB_NOT_NULL(report_task.ctx_) && OB_HASH_EXIST == added_pkeys.exist_refactored(report_task.arg_.key_)) { report_task.ctx_->is_member_change_finished_ = true; LOG_INFO("fast_migrate: succ to change member list", K(report_task.arg_.key_)); @@ -3869,8 +3877,8 @@ int ObPartGroupMigrationTask::try_batch_change_member_list( return ret; } -int ObPartGroupMigrationTask::try_batch_remove_member(ObIArray& report_list, - const ObAddr& leader_addr, hash::ObHashSet& removed_pkeys) +int ObPartGroupMigrationTask::try_batch_remove_member(ObIArray &report_list, + const ObAddr &leader_addr, hash::ObHashSet &removed_pkeys) { int ret = OB_SUCCESS; ObChangeMemberArgs args; @@ -3889,7 +3897,7 @@ int ObPartGroupMigrationTask::try_batch_remove_member(ObIArrayget_pts_rpc(); + ObIPartitionServiceRpc &rpc = partition_service_->get_pts_rpc(); for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { single_arg.partition_key_ = report_list.at(i).arg_.key_; single_arg.member_ = report_list.at(i).arg_.src_; @@ -3927,7 +3935,7 @@ int ObPartGroupMigrationTask::try_batch_remove_member(ObIArray& report_list, - const hash::ObHashSet& removed_pkeys, const ObAddr& leader_addr, - hash::ObHashSet& added_keys, bool& is_all_finish) +int ObPartGroupMigrationTask::try_batch_add_member(ObIArray &report_list, + const hash::ObHashSet &removed_pkeys, const ObAddr &leader_addr, + hash::ObHashSet &added_keys, bool &is_all_finish) { int ret = OB_SUCCESS; #ifdef ERRSIM @@ -3985,7 +3993,7 @@ int ObPartGroupMigrationTask::try_batch_add_member(ObIArrayget_pts_rpc(); + ObIPartitionServiceRpc &rpc = partition_service_->get_pts_rpc(); if (OB_SUCC(ret)) { if (OB_FAIL(rpc.batch_post_add_replica_mc_msg(leader_addr, args, add_member_info))) { @@ -4014,7 +4022,7 @@ int ObPartGroupMigrationTask::try_batch_add_member(ObIArray& report_list, const ObAddr& leader_addr, bool& is_all_finish) + ObIArray &report_list, const ObAddr &leader_addr, bool &is_all_finish) { int ret = OB_SUCCESS; hash::ObHashSet removed_pkeys; @@ -4082,7 +4090,7 @@ int ObPartGroupMigrationTask::try_batch_add_member( LOG_WARN("failed to try_batch_add_member", K(ret)); } else if (CHANGE_REPLICA_OP == type_) { for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { - ObReportPartMigrationTask& report_task = report_list.at(i); + ObReportPartMigrationTask &report_task = report_list.at(i); if (OB_NOT_NULL(report_task.ctx_) && OB_HASH_EXIST == added_keys.exist_refactored(report_task.arg_.key_)) { report_task.ctx_->is_member_change_finished_ = true; LOG_INFO("change replica: succ to add member list", K(report_task.arg_.key_)); @@ -4104,8 +4112,8 @@ int ObPartGroupMigrationTask::try_batch_add_member( return ret; } -int ObPartGroupMigrationTask::build_add_member_ctx(const ObIArray& report_list, - const hash::ObHashSet& removed_pkeys, ObChangeMemberArgs& ctx) +int ObPartGroupMigrationTask::build_add_member_ctx(const ObIArray &report_list, + const hash::ObHashSet &removed_pkeys, ObChangeMemberArgs &ctx) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -4119,7 +4127,7 @@ int ObPartGroupMigrationTask::build_add_member_ctx(const ObIArray& report_list) +int ObPartGroupMigrationTask::remove_src_replica(const ObIArray &report_list) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -4149,7 +4157,7 @@ int ObPartGroupMigrationTask::remove_src_replica(const ObIArray& report_list) +int ObPartGroupMigrationTask::batch_remove_src_replica(const ObIArray &report_list) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; share::ObTaskId dummy_id; dummy_id.init(OBSERVER.get_self()); ObArenaAllocator allocator; - typedef hash::ObHashMap JoinMap; + typedef hash::ObHashMap JoinMap; JoinMap join_map; // Map aggregated by serve if (!is_inited_) { ret = OB_NOT_INIT; @@ -4181,10 +4189,10 @@ int ObPartGroupMigrationTask::batch_remove_src_replica(const ObIArray& report_list) +int ObPartGroupMigrationTask::check_member_major_sstable_enough(ObIArray &report_list) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -4278,13 +4286,13 @@ int ObPartGroupMigrationTask::check_member_major_sstable_enough(ObIArray table_ids; if (OB_UNLIKELY(!is_inited_)) { @@ -4311,7 +4319,7 @@ int ObPartGroupMigrationTask::check_member_pg_major_sstable_enough(ObReportPartM STORAGE_LOG(WARN, "failed to get last all major sstable", K(ret), K(task)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tables_handle.get_count(); ++i) { - ObITable* table = tables_handle.get_tables().at(i); + ObITable *table = tables_handle.get_tables().at(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; STORAGE_LOG(WARN, "error sys, table must not be NULL", K(ret)); @@ -4346,7 +4354,7 @@ int ObPartGroupMigrationTask::check_member_pg_major_sstable_enough(ObReportPartM } int ObPartGroupMigrationTask::report_meta_table( - const ObIArray& report_list, const hash::ObHashSet& member_removed_pkeys) + const ObIArray &report_list, const hash::ObHashSet &member_removed_pkeys) { int ret = OB_SUCCESS; const int64_t ONE_ROUND_WAIT_TIMEOUT = 60 * 1000 * 1000; // 1m @@ -4365,7 +4373,7 @@ int ObPartGroupMigrationTask::report_meta_table( STORAGE_LOG(WARN, "fail to reserve check result", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { - const ObReportPartMigrationTask& report_task = report_list.at(i); + const ObReportPartMigrationTask &report_task = report_list.at(i); if (OB_FAIL(partition_service_->handle_report_meta_table_callback( report_task.arg_.key_, report_task.result_, report_task.need_report_checksum_))) { STORAGE_LOG(WARN, "fail to report meta table", K(ret)); @@ -4373,7 +4381,7 @@ int ObPartGroupMigrationTask::report_meta_table( } if (OB_SUCC(ret) && !has_error()) { for (int64_t i = 0; OB_SUCC(ret) && i < report_list.count(); ++i) { - const ObReportPartMigrationTask& report_task = report_list.at(i); + const ObReportPartMigrationTask &report_task = report_list.at(i); bool need_check = ObReplicaTypeCheck::is_replica_with_ssstore(report_task.arg_.dst_.get_replica_type()); if (FAST_MIGRATE_REPLICA_OP == type_) { int exist_ret = member_removed_pkeys.exist_refactored(report_list.at(i).arg_.key_); @@ -4423,10 +4431,10 @@ int ObPartGroupMigrationTask::report_meta_table( } int ObPartGroupMigrationTask::check_report_done( - const ObIArray& report_list, ObIArray& result) + const ObIArray &report_list, ObIArray &result) { int ret = OB_SUCCESS; - share::ObPartitionTableOperator* pt_operator = NULL; + share::ObPartitionTableOperator *pt_operator = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "ObPartGroupMigrationTask has not been inited", K(ret)); @@ -4442,7 +4450,7 @@ int ObPartGroupMigrationTask::check_report_done( ObArenaAllocator allocator(ObModIds::OB_PARTITION_MIGRATOR); partition_info.set_allocator(&allocator); for (int64_t i = 0; OB_SUCC(ret) && i < result.count(); ++i) { - const ObPartitionReplica* replica = NULL; + const ObPartitionReplica *replica = NULL; partition_info.reuse(); if (OB_FAIL(partition_service_->get_replica_status(report_list.at(i).arg_.key_, replica_status))) { STORAGE_LOG(WARN, "fail to get replica status", K(ret)); @@ -4475,7 +4483,7 @@ int ObPartGroupMigrationTask::check_report_done( } int ObPartGroupMigrationTask::wait_batch_member_change_done( - const ObAddr& leader_addr, ObChangeMemberCtxs& change_member_info) + const ObAddr &leader_addr, ObChangeMemberCtxs &change_member_info) { int ret = OB_SUCCESS; int64_t max_wait_batch_member_change_done_us = 300 * 1000 * 1000; // 5m @@ -4545,7 +4553,7 @@ int ObPartGroupMigrationTask::wait_batch_member_change_done( } int ObPartGroupMigrationTask::try_not_batch_change_member_list( - ObIArray& report_list, bool& is_all_finish) + ObIArray &report_list, bool &is_all_finish) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -4562,7 +4570,7 @@ int ObPartGroupMigrationTask::try_not_batch_change_member_list( ret = OB_ERR_SYS; STORAGE_LOG(ERROR, "task list is empty", K(ret)); } else { - ObReportPartMigrationTask& first_task = report_list.at(0); + ObReportPartMigrationTask &first_task = report_list.at(0); if (OB_SUCCESS != (tmp_ret = partition_service_->handle_member_change_callback( first_task.arg_, first_task.result_, could_retry))) { @@ -4584,7 +4592,7 @@ int ObPartGroupMigrationTask::try_not_batch_change_member_list( is_all_finish = true; for (int64_t i = 1; OB_SUCC(ret) && i < report_list.count(); ++i) { - ObReportPartMigrationTask& sub_task = report_list.at(i); + ObReportPartMigrationTask &sub_task = report_list.at(i); if (OB_SUCCESS != (tmp_ret = partition_service_->handle_member_change_callback( sub_task.arg_, sub_task.result_, could_retry))) { sub_task.result_ = tmp_ret; @@ -4654,7 +4662,7 @@ bool ObPartGroupMigrationTask::need_retry_change_member_list(const int32_t resul return need_retry; } -int ObPartGroupMigrationTask::inner_schedule_partition(ObPartMigrationTask*& task, bool& need_schedule) +int ObPartGroupMigrationTask::inner_schedule_partition(ObPartMigrationTask *&task, bool &need_schedule) { int ret = OB_SUCCESS; need_schedule = false; @@ -4693,7 +4701,7 @@ int ObPartGroupMigrationTask::try_schedule_partition_migration() { int ret = OB_SUCCESS; bool need_schedule = true; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; const int64_t data_copy_in_concurrency = GCONF.server_data_copy_in_concurrency; while (OB_SUCC(ret) && need_schedule && @@ -4716,7 +4724,7 @@ int ObPartGroupMigrationTask::try_schedule_partition_validate() { int ret = OB_SUCCESS; bool need_schedule = true; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; int64_t data_validate_concurrency = GCONF.backup_concurrency; int32_t up_limit = 0; if (OB_FAIL(ObDagScheduler::get_instance().get_up_limit(ObIDag::DAG_ULT_BACKUP, up_limit))) { @@ -4746,7 +4754,7 @@ int ObPartGroupMigrationTask::try_schedule_partition_backup_backupset() { int ret = OB_SUCCESS; bool need_schedule = true; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; int64_t data_backup_concurrency = GCONF.backup_concurrency; int32_t up_limit = 0; if (OB_FAIL(ObDagScheduler::get_instance().get_up_limit(ObIDag::DAG_ULT_BACKUP, up_limit))) { @@ -4776,7 +4784,7 @@ int ObPartGroupMigrationTask::try_schedule_partition_backup_archivelog() { int ret = OB_SUCCESS; bool need_schedule = true; - ObPartMigrationTask* task = NULL; + ObPartMigrationTask *task = NULL; int64_t data_backup_concurrency = GCONF.backup_concurrency; int32_t up_limit = 0; if (OB_FAIL(ObDagScheduler::get_instance().get_up_limit(ObIDag::DAG_ULT_BACKUP, up_limit))) { @@ -4803,7 +4811,7 @@ int ObPartGroupMigrationTask::try_schedule_partition_backup_archivelog() } // caller hold task_list_ lock -int ObPartGroupMigrationTask::get_migrate_task(const ObPartitionKey& pg_key, ObPartMigrationTask*& task) +int ObPartGroupMigrationTask::get_migrate_task(const ObPartitionKey &pg_key, ObPartMigrationTask *&task) { int ret = OB_SUCCESS; task = NULL; @@ -4852,7 +4860,7 @@ int ObPartGroupMigrationTask::get_migrate_task(const ObPartitionKey& pg_key, ObP // return ret; //} -int ObPartGroupMigrationTask::init_restore_meta_index_(const share::ObPhysicalRestoreArg& restore_arg) +int ObPartGroupMigrationTask::init_restore_meta_index_(const share::ObPhysicalRestoreArg &restore_arg) { int ret = OB_SUCCESS; const bool is_compat_backup_path = !restore_arg.restore_info_.is_compat_backup_path(); @@ -4891,7 +4899,7 @@ int ObPartGroupMigrationTask::init_restore_meta_index_(const share::ObPhysicalRe // caller hold task_list_ lock int ObPartGroupMigrationTask::set_migrate_task_flags_( - const ObMigrateStatus& status, const bool is_restore, ObPartMigrationTask& task) + const ObMigrateStatus &status, const bool is_restore, ObPartMigrationTask &task) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -4910,7 +4918,7 @@ int ObPartGroupMigrationTask::set_migrate_task_flags_( return ret; } -int ObGroupMigrateDag::report_result(const bool is_batch_mode, const ObIArray& report_list) +int ObGroupMigrateDag::report_result(const bool is_batch_mode, const ObIArray &report_list) { int ret = OB_SUCCESS; @@ -4929,7 +4937,7 @@ int ObGroupMigrateDag::report_result(const bool is_batch_mode, const ObIArray& report_list) +int ObGroupMigrateDag::single_report_result(const ObIArray &report_list) { int ret = OB_SUCCESS; @@ -4940,7 +4948,7 @@ int ObGroupMigrateDag::single_report_result(const ObIArrayretry_post_operate_replica_res(task.arg_, task.result_))) { STORAGE_LOG(WARN, "failed to retry_post_operate_replica_res", K(ret), K(task)); } @@ -4948,7 +4956,7 @@ int ObGroupMigrateDag::single_report_result(const ObIArray& report_list) +int ObGroupMigrateDag::batch_report_result(const ObIArray &report_list) { int ret = OB_SUCCESS; ObArray report_res_list; @@ -4970,12 +4978,12 @@ int ObGroupMigrateDag::batch_report_result(const ObIArray& table_ids) +int ObPartGroupMigrationTask::get_tables_with_major_sstable(const ObPartitionKey &pkey, ObIArray &table_ids) { int ret = OB_SUCCESS; ObIPartitionGroupGuard part_guard; - ObIPartitionGroup* partition = NULL; - ObPartitionStorage* storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPartitionStorage *storage = NULL; ObPGPartitionGuard pg_partition_guard; ObTablesHandle tables_handle; table_ids.reset(); @@ -4996,14 +5004,14 @@ int ObPartGroupMigrationTask::get_tables_with_major_sstable(const ObPartitionKey ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "get pg partition error", K(ret), KP(pg_partition_guard.get_pg_partition())); } else if (OB_ISNULL( - storage = static_cast(pg_partition_guard.get_pg_partition()->get_storage()))) { + storage = static_cast(pg_partition_guard.get_pg_partition()->get_storage()))) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "partition storage must not be NULL", K(ret)); } else if (OB_FAIL(storage->get_partition_store().get_last_all_major_sstable(tables_handle))) { STORAGE_LOG(WARN, "fail to get last all major sstables", K(ret), K(pkey)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tables_handle.get_count(); ++i) { - ObITable* table = tables_handle.get_tables().at(i); + ObITable *table = tables_handle.get_tables().at(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; STORAGE_LOG(WARN, "error sys, table must not be NULL", K(ret)); @@ -5026,7 +5034,7 @@ ObFastMigrateDag::~ObFastMigrateDag() group_task_ = nullptr; } -bool ObFastMigrateDag::operator==(const ObIDag& other) const +bool ObFastMigrateDag::operator==(const ObIDag &other) const { bool is_same = true; if (this == &other) { @@ -5034,7 +5042,7 @@ bool ObFastMigrateDag::operator==(const ObIDag& other) const } else if (get_type() != other.get_type()) { is_same = false; } else { - const ObFastMigrateDag& other_dag = static_cast(other); + const ObFastMigrateDag &other_dag = static_cast(other); is_same = (group_task_ == other_dag.group_task_ && sub_type_ == other_dag.sub_type_); } return is_same; @@ -5061,15 +5069,15 @@ int64_t ObFastMigrateDag::get_tenant_id() const return tenant_id; } -int ObFastMigrateDag::fill_comment(char* buf, const int64_t buf_len) const +int ObFastMigrateDag::fill_comment(char *buf, const int64_t buf_len) const { int ret = OB_SUCCESS; if (NULL == buf || buf_len <= 0) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid args", K(ret), KP(buf), K(buf_len)); } else { - const char* type_str = "UNKOWN"; - static const char* TYPE_STRING[] = { + const char *type_str = "UNKOWN"; + static const char *TYPE_STRING[] = { "INVALID", "SUSPEND_SRC", "HANDOVER_PG", @@ -5108,7 +5116,7 @@ bool ObFastMigrateDag::is_valid_task_type(TaskType type) return type > TaskType::INVALID && type < TaskType::MAX_TYPE; } -int ObFastMigrateDag::init(ObPartGroupMigrationTask* group_task, TaskType sub_type) +int ObFastMigrateDag::init(ObPartGroupMigrationTask *group_task, TaskType sub_type) { int ret = OB_SUCCESS; if (OB_NOT_NULL(group_task_)) { @@ -5131,7 +5139,7 @@ ObBaseMigrateDag::ObBaseMigrateDag(const ObIDagType type, const ObIDagPriority p ObBaseMigrateDag::~ObBaseMigrateDag() {} -bool ObBaseMigrateDag::operator==(const ObIDag& other) const +bool ObBaseMigrateDag::operator==(const ObIDag &other) const { bool is_same = true; if (this == &other) { @@ -5139,7 +5147,7 @@ bool ObBaseMigrateDag::operator==(const ObIDag& other) const } else if (get_type() != other.get_type()) { is_same = false; } else { - const ObMigrateDag& other_dag = static_cast(other); + const ObMigrateDag &other_dag = static_cast(other); if (NULL != ctx_ && NULL != other_dag.ctx_) { if (ctx_->replica_op_arg_.key_ != other_dag.ctx_->replica_op_arg_.key_) { is_same = false; @@ -5166,7 +5174,7 @@ void ObBaseMigrateDag::clear() tenant_id_ = 0; } -int ObBaseMigrateDag::fill_comment(char* buf, const int64_t buf_len) const +int ObBaseMigrateDag::fill_comment(char *buf, const int64_t buf_len) const { int ret = OB_SUCCESS; @@ -5185,14 +5193,14 @@ ObMigrateDag::ObMigrateDag() : ObBaseMigrateDag(ObIDag::DAG_TYPE_MIGRATE, ObIDag ObMigrateDag::~ObMigrateDag() { int tmp_ret = OB_SUCCESS; - ObPartitionService* partition_service = MIGRATOR.get_partition_service(); + ObPartitionService *partition_service = MIGRATOR.get_partition_service(); ObMigrateStatus migrate_status = OB_MIGRATE_STATUS_NONE; bool need_offline_partition = false; if (NULL != ctx_) { ctx_->calc_need_retry(); ObReplicaOpArg tmp_relica_op_arg = ctx_->replica_op_arg_; - ObIPartitionGroup* partition = ctx_->get_partition(); + ObIPartitionGroup *partition = ctx_->get_partition(); if (OB_SUCCESS == ctx_->result_ && OB_SUCCESS != this->get_dag_ret()) { ctx_->result_ = this->get_dag_ret(); LOG_WARN("migrate dag is failed", "result", this->get_dag_ret(), K(*ctx_)); @@ -5318,7 +5326,7 @@ ObMigrateDag::~ObMigrateDag() } // ctx != NULL } -int ObMigrateDag::init(ObMigrateCtx& ctx) +int ObMigrateDag::init(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; @@ -5372,13 +5380,13 @@ int ObMigrateDag::init(ObMigrateCtx& ctx) return ret; } -int ObMigrateDag::init_for_restore_(ObMigrateCtx& ctx) +int ObMigrateDag::init_for_restore_(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; ObReplicaRestoreStatus restore_status = ObReplicaRestoreStatus::REPLICA_NOT_RESTORE; ObIPartitionGroupGuard guard; - ObIPartitionGroup* partition = NULL; - ObPartGroupMigrationTask* group_task = NULL; + ObIPartitionGroup *partition = NULL; + ObPartGroupMigrationTask *group_task = NULL; ObPGKey backup_pg_key; ObBackupMetaIndex meta_index; const int64_t compatible = ctx.replica_op_arg_.phy_restore_arg_.restore_info_.compatible_; @@ -5397,11 +5405,11 @@ int ObMigrateDag::init_for_restore_(ObMigrateCtx& ctx) ctx.replica_op_arg_.key_); } else if (OB_FAIL(ctx.replica_op_arg_.phy_restore_arg_.get_backup_pgkey(backup_pg_key))) { STORAGE_LOG(WARN, "failed to get backup pgkey", K(ret), K(ctx.replica_op_arg_.phy_restore_arg_)); - } else if (FALSE_IT(group_task = reinterpret_cast(ctx.group_task_))) { + } else if (FALSE_IT(group_task = reinterpret_cast(ctx.group_task_))) { } else if (OB_ISNULL(ctx.macro_indexs_)) { if (OB_BACKUP_COMPATIBLE_VERSION_V3 == compatible) { const ObBackupMetaType meta_type = ObBackupMetaType::PARTITION_GROUP_META_INFO; - ObPhyRestoreMacroIndexStoreV2* phy_restore_macro_index_v2 = NULL; + ObPhyRestoreMacroIndexStoreV2 *phy_restore_macro_index_v2 = NULL; if (OB_ISNULL(phy_restore_macro_index_v2 = MIGRATOR.get_cp_fty()->get_phy_restore_macro_index_v2())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("phy restore macro index should not be NULL", K(ret), KP(phy_restore_macro_index_v2)); @@ -5419,7 +5427,7 @@ int ObMigrateDag::init_for_restore_(ObMigrateCtx& ctx) ctx.macro_indexs_ = NULL; } } else if (OB_BACKUP_COMPATIBLE_VERSION_V1 == compatible || OB_BACKUP_COMPATIBLE_VERSION_V2 == compatible) { - ObPhyRestoreMacroIndexStore* phy_restore_macro_index = NULL; + ObPhyRestoreMacroIndexStore *phy_restore_macro_index = NULL; if (OB_ISNULL(phy_restore_macro_index = MIGRATOR.get_cp_fty()->get_phy_restore_macro_index())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("phy restore macro index should not be NULL", K(ret), KP(phy_restore_macro_index)); @@ -5448,7 +5456,7 @@ int ObMigrateDag::init_for_restore_(ObMigrateCtx& ctx) int ObMigrateDag::update_partition_meta_for_restore() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; bool need_set_restore = true; // If it is a phsical restore, is_restore will set REPLICA_RESTORE_LOG, if not, directly chagne to // REPLICA_NOT_RESTORE. @@ -5464,7 +5472,7 @@ int ObMigrateDag::update_partition_meta_for_restore() RESTORE_FOLLOWER_REPLICA_OP == ctx_->replica_op_arg_.type_ || RESTORE_STANDBY_OP == ctx_->replica_op_arg_.type_) && OB_SUCC(ctx_->result_)) { - const ObPartitionKey& pgkey = ctx_->replica_op_arg_.key_; + const ObPartitionKey &pgkey = ctx_->replica_op_arg_.key_; if (ctx_->replica_op_arg_.is_physical_restore() || ctx_->replica_op_arg_.is_standby_restore()) { is_restore = ctx_->replica_op_arg_.is_physical_restore() ? ObReplicaRestoreStatus::REPLICA_RESTORE_LOG : ObReplicaRestoreStatus::REPLICA_NOT_RESTORE; @@ -5605,10 +5613,10 @@ int ObMigrateDag::online_for_rebuild() int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; ObSavedStorageInfoV2 info; - ObBaseStorageInfo& clog_info = info.get_clog_info(); - ObDataStorageInfo& data_info = info.get_data_info(); + ObBaseStorageInfo &clog_info = info.get_clog_info(); + ObDataStorageInfo &data_info = info.get_data_info(); if (NULL != ctx_ && ctx_->need_online_for_rebuild_) { - ObIPartitionGroup* partition = ctx_->get_partition(); + ObIPartitionGroup *partition = ctx_->get_partition(); int64_t restore_snapshot_version = OB_INVALID_TIMESTAMP; uint64_t last_restore_log_id = OB_INVALID_ID; int64_t last_restore_log_ts = OB_INVALID_TIMESTAMP; @@ -5662,7 +5670,7 @@ int ObMigrateDag::online_for_restore() bool is_offline = true; ObSavedStorageInfoV2 info; ObBaseStorageInfo clog_info; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; if (OB_ISNULL(ctx_)) { // do nothing } else if (RESTORE_STANDBY_OP != ctx_->replica_op_arg_.type_ && RESTORE_REPLICA_OP != ctx_->replica_op_arg_.type_ && @@ -5704,7 +5712,7 @@ ObBackupDag::~ObBackupDag() if (NULL != ctx_) { ctx_->calc_need_retry(); ObReplicaOpArg tmp_relica_op_arg = ctx_->replica_op_arg_; - ObIPartitionGroup* partition = ctx_->get_partition(); + ObIPartitionGroup *partition = ctx_->get_partition(); if (OB_SUCCESS == ctx_->result_ && OB_SUCCESS != this->get_dag_ret()) { ctx_->result_ = this->get_dag_ret(); LOG_WARN("migrate dag is failed", "result", this->get_dag_ret(), K(*ctx_)); @@ -5758,7 +5766,7 @@ ObBackupDag::~ObBackupDag() } // ctx != NULL } -int ObBackupDag::init(const ObBackupDataType& backup_data_type, ObMigrateCtx& ctx) +int ObBackupDag::init(const ObBackupDataType &backup_data_type, ObMigrateCtx &ctx) { int ret = OB_SUCCESS; @@ -5778,7 +5786,7 @@ int ObBackupDag::init(const ObBackupDataType& backup_data_type, ObMigrateCtx& ct ctx.replica_op_arg_.key_))) { LOG_WARN("failed to init physical backup ctx", K(ret), K(ctx.replica_op_arg_.backup_arg_)); } else if (ctx.replica_op_arg_.backup_arg_.is_incremental_backup() && OB_ISNULL(ctx.macro_indexs_)) { - ObPhyRestoreMacroIndexStoreV2* phy_restore_macro_index_v2 = NULL; + ObPhyRestoreMacroIndexStoreV2 *phy_restore_macro_index_v2 = NULL; if (OB_ISNULL(phy_restore_macro_index_v2 = MIGRATOR.get_cp_fty()->get_phy_restore_macro_index_v2())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("phy restore macro index should not be NULL", K(ret), KP(phy_restore_macro_index_v2)); @@ -5846,7 +5854,7 @@ ObValidateDag::~ObValidateDag() } // ctx != NULL } -bool ObValidateDag::operator==(const ObIDag& other) const +bool ObValidateDag::operator==(const ObIDag &other) const { bool is_same = true; if (this == &other) { @@ -5854,10 +5862,10 @@ bool ObValidateDag::operator==(const ObIDag& other) const } else if (get_type() != other.get_type()) { is_same = false; } else { - const ObValidateDag& other_dag = static_cast(other); + const ObValidateDag &other_dag = static_cast(other); if (NULL != ctx_ && NULL != other_dag.ctx_) { - const ObPhysicalValidateArg& other_arg = other_dag.ctx_->replica_op_arg_.validate_arg_; - const ObPhysicalValidateArg& arg = ctx_->replica_op_arg_.validate_arg_; + const ObPhysicalValidateArg &other_arg = other_dag.ctx_->replica_op_arg_.validate_arg_; + const ObPhysicalValidateArg &arg = ctx_->replica_op_arg_.validate_arg_; is_same = arg.backup_set_id_ == other_arg.backup_set_id_ && arg.pg_key_ == other_arg.pg_key_; } else { is_same = false; @@ -5870,14 +5878,14 @@ int64_t ObValidateDag::hash() const { int64_t hash_value = 0; if (NULL != ctx_) { - const ObPhysicalValidateArg& arg = ctx_->replica_op_arg_.validate_arg_; + const ObPhysicalValidateArg &arg = ctx_->replica_op_arg_.validate_arg_; hash_value = common::murmurhash(&(arg.backup_set_id_), sizeof(arg.backup_set_id_), hash_value); hash_value = common::murmurhash(&(arg.pg_key_), sizeof(arg.pg_key_), hash_value); } return hash_value; } -int ObValidateDag::init(ObMigrateCtx& ctx) +int ObValidateDag::init(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; @@ -5891,7 +5899,7 @@ int ObValidateDag::init(ObMigrateCtx& ctx) ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "replica op type is not validate", K(ret), K(ctx.replica_op_arg_)); } else { - const ObPartitionKey& pkey = ctx.replica_op_arg_.key_; + const ObPartitionKey &pkey = ctx.replica_op_arg_.key_; tenant_id_ = pkey.get_tenant_id(); set_priority(ObIDag::DAG_PRIO_VALIDATE); if (OB_FAIL(ctx.notice_start_part_task())) { @@ -5938,17 +5946,17 @@ ObBackupBackupsetDag::~ObBackupBackupsetDag() } } -bool ObBackupBackupsetDag::operator==(const ObIDag& other) const +bool ObBackupBackupsetDag::operator==(const ObIDag &other) const { bool equal = false; if (OB_UNLIKELY(this == &other)) { equal = true; } else { if (get_type() == other.get_type()) { - const ObBackupBackupsetDag& other_dag = static_cast(other); + const ObBackupBackupsetDag &other_dag = static_cast(other); if (OB_NOT_NULL(ctx_) && OB_NOT_NULL(other_dag.ctx_)) { - const share::ObBackupBackupsetArg& arg = ctx_->replica_op_arg_.backup_backupset_arg_; - const share::ObBackupBackupsetArg& other_arg = other_dag.ctx_->replica_op_arg_.backup_backupset_arg_; + const share::ObBackupBackupsetArg &arg = ctx_->replica_op_arg_.backup_backupset_arg_; + const share::ObBackupBackupsetArg &other_arg = other_dag.ctx_->replica_op_arg_.backup_backupset_arg_; if (arg.backup_set_id_ == other_arg.backup_set_id_ && arg.pg_key_ == other_arg.pg_key_) { equal = true; STORAGE_LOG( @@ -5964,14 +5972,14 @@ int64_t ObBackupBackupsetDag::hash() const { int64_t hash_value = 0; if (OB_NOT_NULL(ctx_)) { - const share::ObBackupBackupsetArg& arg = ctx_->replica_op_arg_.backup_backupset_arg_; + const share::ObBackupBackupsetArg &arg = ctx_->replica_op_arg_.backup_backupset_arg_; hash_value = common::murmurhash(&(arg.backup_set_id_), sizeof(arg.backup_set_id_), hash_value); hash_value = common::murmurhash(&(arg.pg_key_), sizeof(arg.pg_key_), hash_value); } return hash_value; } -int ObBackupBackupsetDag::init(ObMigrateCtx& ctx) +int ObBackupBackupsetDag::init(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; if (IS_INIT) { @@ -5984,9 +5992,9 @@ int ObBackupBackupsetDag::init(ObMigrateCtx& ctx) ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "replica op type is not backup backupset", KR(ret), K(ctx.replica_op_arg_)); } else { - const ObPartitionKey& pkey = ctx.replica_op_arg_.key_; + const ObPartitionKey &pkey = ctx.replica_op_arg_.key_; tenant_id_ = pkey.get_tenant_id(); - const share::ObBackupBackupsetArg& arg = ctx.replica_op_arg_.backup_backupset_arg_; + const share::ObBackupBackupsetArg &arg = ctx.replica_op_arg_.backup_backupset_arg_; if (OB_SUCC(ret)) { set_priority(ObIDag::DAG_PRIO_BACKUP); @@ -6035,7 +6043,7 @@ ObBackupArchiveLogDag::~ObBackupArchiveLogDag() } } -int ObBackupArchiveLogDag::init(ObMigrateCtx& ctx) +int ObBackupArchiveLogDag::init(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; if (IS_INIT) { @@ -6048,7 +6056,7 @@ int ObBackupArchiveLogDag::init(ObMigrateCtx& ctx) ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "replica op type is not backup archivelog", KR(ret), K(ctx.replica_op_arg_)); } else { - const ObPartitionKey& pkey = ctx.replica_op_arg_.key_; + const ObPartitionKey &pkey = ctx.replica_op_arg_.key_; tenant_id_ = pkey.get_tenant_id(); if (OB_SUCC(ret)) { @@ -6093,7 +6101,7 @@ int ObMigratePrepareTask::init() ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); is_inited_ = true; bandwidth_throttle_ = MIGRATOR.get_bandwidth_throttle(); partition_service_ = MIGRATOR.get_partition_service(); @@ -6107,8 +6115,8 @@ int ObMigratePrepareTask::init() int ObMigratePrepareTask::prepare_restore_reader_if_needed() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPartGroupMigrationTask* group_task = NULL; + ObIPartitionGroup *partition = NULL; + ObPartGroupMigrationTask *group_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -6138,14 +6146,14 @@ int ObMigratePrepareTask::prepare_restore_reader_if_needed() int ObMigratePrepareTask::prepare_restore_reader() { int ret = OB_SUCCESS; - ObPartGroupMigrationTask* group_task = NULL; + ObPartGroupMigrationTask *group_task = NULL; const int64_t compatible = ctx_->replica_op_arg_.phy_restore_arg_.restore_info_.compatible_; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); } else if (OB_BACKUP_COMPATIBLE_VERSION_V3 == compatible) { - ObPartitionGroupMetaRestoreReaderV2* restore_meta_reader_v2 = NULL; - ObPhyRestoreMacroIndexStoreV2* macro_index = NULL; + ObPartitionGroupMetaRestoreReaderV2 *restore_meta_reader_v2 = NULL; + ObPhyRestoreMacroIndexStoreV2 *macro_index = NULL; if (OB_ISNULL(ctx_->macro_indexs_)) { ret = OB_ERR_UNEXPECTED; @@ -6153,11 +6161,11 @@ int ObMigratePrepareTask::prepare_restore_reader() } else if (ObIPhyRestoreMacroIndexStore::PHY_RESTORE_MACRO_INDEX_STORE_V2 != ctx_->macro_indexs_->get_type()) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "macro indexs type is unexpected", K(ret), K(ctx_->macro_indexs_->get_type())); - } else if (FALSE_IT(macro_index = reinterpret_cast(ctx_->macro_indexs_))) { + } else if (FALSE_IT(macro_index = reinterpret_cast(ctx_->macro_indexs_))) { } else if (OB_ISNULL(restore_meta_reader_v2 = cp_fty_->get_partition_group_meta_restore_reader_v2())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("meta reader should not be NULL", K(ret), KP(restore_meta_reader_v2)); - } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { + } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { } else if (OB_FAIL(restore_meta_reader_v2->init(*bandwidth_throttle_, ctx_->replica_op_arg_.phy_restore_arg_, group_task->get_meta_indexs(), @@ -6173,19 +6181,19 @@ int ObMigratePrepareTask::prepare_restore_reader() } } } else if (OB_BACKUP_COMPATIBLE_VERSION_V1 == compatible || OB_BACKUP_COMPATIBLE_VERSION_V2 == compatible) { - ObPartitionGroupMetaRestoreReaderV1* restore_meta_reader_v1 = NULL; - ObPhyRestoreMacroIndexStore* macro_index = NULL; + ObPartitionGroupMetaRestoreReaderV1 *restore_meta_reader_v1 = NULL; + ObPhyRestoreMacroIndexStore *macro_index = NULL; if (OB_ISNULL(ctx_->macro_indexs_)) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "macro indexs should not be NULL", K(ret), KP(ctx_->macro_indexs_)); } else if (ObIPhyRestoreMacroIndexStore::PHY_RESTORE_MACRO_INDEX_STORE_V1 != ctx_->macro_indexs_->get_type()) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "macro indexs type is unexpected", K(ret), K(ctx_->macro_indexs_->get_type())); - } else if (FALSE_IT(macro_index = reinterpret_cast(ctx_->macro_indexs_))) { + } else if (FALSE_IT(macro_index = reinterpret_cast(ctx_->macro_indexs_))) { } else if (OB_ISNULL(restore_meta_reader_v1 = cp_fty_->get_partition_group_meta_restore_reader_v1())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("meta reader should not be NULL", K(ret), KP(restore_meta_reader_v1)); - } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { + } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { } else if (OB_FAIL(restore_meta_reader_v1->init(*bandwidth_throttle_, ctx_->replica_op_arg_.phy_restore_arg_, group_task->get_meta_indexs(), @@ -6209,7 +6217,7 @@ int ObMigratePrepareTask::prepare_restore_reader() // TODO() interface optimization for restore and rebuild int ObMigratePrepareTask::create_partition_if_needed( - ObIPartitionGroupGuard& pg_guard, const ObPGPartitionStoreMeta& partition_meta) + ObIPartitionGroupGuard &pg_guard, const ObPGPartitionStoreMeta &partition_meta) { int ret = OB_SUCCESS; @@ -6220,10 +6228,10 @@ int ObMigratePrepareTask::create_partition_if_needed( ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "partition_meta is not valid", K(ret), K(partition_meta)); } else { - const ObPartitionKey& pg_key = ctx_->replica_op_arg_.key_; - const ObPartitionKey& pkey = partition_meta.pkey_; + const ObPartitionKey &pg_key = ctx_->replica_op_arg_.key_; + const ObPartitionKey &pkey = partition_meta.pkey_; ObIPartitionGroupGuard guard; - ObIPartitionGroup* pg = NULL; + ObIPartitionGroup *pg = NULL; int tmp_ret = OB_SUCCESS; if (OB_SUCCESS == (tmp_ret = ObPartitionService::get_instance().get_partition(pkey, guard))) { STORAGE_LOG(INFO, "partition exist, not need to create", K(ret), K(pkey)); @@ -6289,11 +6297,11 @@ int ObMigratePrepareTask::process() int ObMigratePrepareTask::generate_and_schedule_tasks() { int ret = OB_SUCCESS; - ObMigrateTransTableTaskGeneratorTask* migrate_trans_table_task_generator_task = NULL; - ObMigrateTaskGeneratorTask* migrate_task_generator_task = NULL; - ObMigrateRecoveryPointTaskGeneratorTask* recovery_point_task_generator_task = NULL; - ObFakeTask* wait_trans_table_finish_task = NULL; - ObFakeTask* wait_recovery_point_finish_task = NULL; + ObMigrateTransTableTaskGeneratorTask *migrate_trans_table_task_generator_task = NULL; + ObMigrateTaskGeneratorTask *migrate_task_generator_task = NULL; + ObMigrateRecoveryPointTaskGeneratorTask *recovery_point_task_generator_task = NULL; + ObFakeTask *wait_trans_table_finish_task = NULL; + ObFakeTask *wait_recovery_point_finish_task = NULL; // migrate_trans_table_task_generator_task -> wait_trans_table_finish_task // wait_trans_table_finish_task -> recovery_point_task_generator_task // wait_trans_table_finish_task -> wait_recovery_point_finish_task @@ -6348,7 +6356,7 @@ int ObMigratePrepareTask::generate_and_schedule_tasks() return ret; } -int ObITableTaskGeneratorTask::need_generate_sstable_migrate_tasks(bool& need_schedule) +int ObITableTaskGeneratorTask::need_generate_sstable_migrate_tasks(bool &need_schedule) { int ret = OB_SUCCESS; need_schedule = true; @@ -6428,8 +6436,8 @@ int ObMigratePrepareTask::prepare_migrate() int ObMigrateTaskSchedulerTask::try_hold_local_partition() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGStorage* pg_storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGStorage *pg_storage = NULL; common::ObAddr leader; ObReplicaProperty replica_property; int16_t restore_state = 0; @@ -6437,7 +6445,7 @@ int ObMigrateTaskSchedulerTask::try_hold_local_partition() int64_t trans_table_timestamp = 0; ObRole role; ObPartitionGroupMeta local_pg_meta; - ObPartGroupMigrationTask* group_task = NULL; + ObPartGroupMigrationTask *group_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -6527,7 +6535,7 @@ int ObMigrateTaskSchedulerTask::try_hold_local_partition() } else if (OB_ISNULL(ctx_->group_task_)) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("group task should not be null here", K(ret)); - } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { + } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { } else if (OB_FAIL(group_task->set_migrate_in(partition->get_pg_storage()))) { LOG_WARN("failed to set migrate int", "pkey", ctx_->replica_op_arg_.key_, K(ret)); } @@ -6666,7 +6674,7 @@ int ObMigratePrepareTask::choose_migrate_src() } int ObMigratePrepareTask::choose_ob_migrate_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; const int64_t local_cluster_id = GCONF.cluster_id; @@ -6687,7 +6695,7 @@ int ObMigratePrepareTask::choose_ob_migrate_src( } int ObMigratePrepareTask::choose_ob_rebuild_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -6700,7 +6708,7 @@ int ObMigratePrepareTask::choose_ob_rebuild_src( } int ObMigratePrepareTask::choose_rebuild_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; ObArray src_info_array; @@ -6728,9 +6736,9 @@ int ObMigratePrepareTask::choose_rebuild_src( return ret; } -int ObMigratePrepareTask::copy_needed_table_info(const ObReplicaOpArg& arg, - const obrpc::ObPGPartitionMetaInfo& data_src_result, ObIArray& table_info_res, - ObIArray& table_id_list, bool& found) +int ObMigratePrepareTask::copy_needed_table_info(const ObReplicaOpArg &arg, + const obrpc::ObPGPartitionMetaInfo &data_src_result, ObIArray &table_info_res, + ObIArray &table_id_list, bool &found) { int ret = OB_SUCCESS; found = false; @@ -6777,7 +6785,7 @@ int ObMigratePrepareTask::copy_needed_table_info(const ObReplicaOpArg& arg, } int ObMigratePrepareTask::fetch_partition_group_info( - const ObReplicaOpArg& arg, const ObMigrateSrcInfo& src_info, ObPartitionGroupInfoResult& result) + const ObReplicaOpArg &arg, const ObMigrateSrcInfo &src_info, ObPartitionGroupInfoResult &result) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -6800,8 +6808,8 @@ int ObMigratePrepareTask::fetch_partition_group_info( return ret; } -int ObMigratePrepareTask::choose_rebuild_candidate(const ObReplicaOpArg& arg, - const common::ObIArray& src_info_array, ObPartitionGroupMeta& meta, ObMigrateSrcInfo& src_info) +int ObMigratePrepareTask::choose_rebuild_candidate(const ObReplicaOpArg &arg, + const common::ObIArray &src_info_array, ObPartitionGroupMeta &meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -6873,7 +6881,7 @@ int ObMigratePrepareTask::choose_rebuild_candidate(const ObReplicaOpArg& arg, } int ObMigratePrepareTask::copy_rebuild_partition_info_result( - ObPartitionGroupInfoResult& tmp_result, ObPartitionGroupInfoResult& target_result, bool& find_src) + ObPartitionGroupInfoResult &tmp_result, ObPartitionGroupInfoResult &target_result, bool &find_src) { int ret = OB_SUCCESS; find_src = false; @@ -6900,12 +6908,12 @@ int ObMigratePrepareTask::copy_rebuild_partition_info_result( return ret; } -int ObMigratePrepareTask::split_candidate_with_region(const ObIArray& src_info_array, - ObIArray& same_region_array, ObIArray& diff_region_array) +int ObMigratePrepareTask::split_candidate_with_region(const ObIArray &src_info_array, + ObIArray &same_region_array, ObIArray &diff_region_array) { int ret = OB_SUCCESS; ObRegion local_addr_region; - const ObAddr& self_addr = OBSERVER.get_self(); + const ObAddr &self_addr = OBSERVER.get_self(); if (!is_inited_) { ret = OB_NOT_INIT; @@ -6918,7 +6926,7 @@ int ObMigratePrepareTask::split_candidate_with_region(const ObIArrayget_server_region_across_cluster(src.src_addr_, tmp_region))) { LOG_WARN("fail to get server region", K(ret), K(src)); } else if (local_addr_region == tmp_region) { @@ -6935,13 +6943,13 @@ int ObMigratePrepareTask::split_candidate_with_region(const ObIArray& src_array, ObPartitionGroupInfoResult& out_result) +int ObMigratePrepareTask::fetch_suitable_rebuild_src(const ObReplicaOpArg &arg, + const common::ObIArray &src_array, ObPartitionGroupInfoResult &out_result) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGStorage* pg_storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGStorage *pg_storage = NULL; ObPartitionGroupMeta local_pg_meta; if (!is_inited_) { @@ -6966,7 +6974,7 @@ int ObMigratePrepareTask::fetch_suitable_rebuild_src(const ObReplicaOpArg& arg, int64_t max_last_replay_log_id = ctx_->local_last_replay_log_id_; for (int64_t i = 0; OB_SUCC(ret) && i < src_array.count(); ++i) { tmp_result.reset(); - const ObMigrateSrcInfo& src_info = src_array.at(i); + const ObMigrateSrcInfo &src_info = src_array.at(i); bool is_valid_src = false; bool is_suitable = false; if (!src_info.is_valid()) { @@ -6979,7 +6987,7 @@ int ObMigratePrepareTask::fetch_suitable_rebuild_src(const ObReplicaOpArg& arg, } else if (!is_valid_src) { // do nothing } else { - const ObDataStorageInfo& data_info = tmp_result.result_.pg_meta_.storage_info_.get_data_info(); + const ObDataStorageInfo &data_info = tmp_result.result_.pg_meta_.storage_info_.get_data_info(); const int64_t remote_minor_snapshot_version = data_info.get_publish_version(); const int64_t remote_major_snapshot_version = tmp_result.result_.pg_meta_.report_status_.snapshot_version_; const uint64_t remote_last_replay_log_id = @@ -7054,7 +7062,7 @@ int ObMigratePrepareTask::fetch_suitable_rebuild_src(const ObReplicaOpArg& arg, } int ObMigratePrepareTask::choose_restore_migrate_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; const int64_t compatible = ctx_->replica_op_arg_.phy_restore_arg_.restore_info_.compatible_; @@ -7088,7 +7096,7 @@ int ObMigratePrepareTask::choose_restore_migrate_src( } int ObMigratePrepareTask::choose_phy_restore_follower_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; ObPartitionGroupInfoResult src_result; @@ -7112,7 +7120,7 @@ int ObMigratePrepareTask::choose_phy_restore_follower_src( // TODO(muwei.ym) delete it later int ObMigratePrepareTask::choose_backup_migrate_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; @@ -7134,7 +7142,7 @@ int ObMigratePrepareTask::choose_backup_migrate_src( } int ObMigratePrepareTask::choose_standby_restore_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; const int64_t local_cluster_id = GCONF.cluster_id; @@ -7155,7 +7163,7 @@ int ObMigratePrepareTask::choose_standby_restore_src( } int ObMigratePrepareTask::choose_ob_src( - IsValidSrcFunc is_valid_src, const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + IsValidSrcFunc is_valid_src, const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; ObPartitionGroupInfoResult data_src_result; @@ -7195,12 +7203,12 @@ int ObMigratePrepareTask::choose_ob_src( } int ObMigratePrepareTask::is_valid_migrate_src( - const obrpc::ObFetchPGInfoResult& result, ObMigrateCtx& ctx, bool& is_valid) + const obrpc::ObFetchPGInfoResult &result, ObMigrateCtx &ctx, bool &is_valid) { int ret = OB_SUCCESS; is_valid = false; - const ObDataStorageInfo& data_info = result.pg_meta_.storage_info_.get_data_info(); - const ObBaseStorageInfo& clog_info = result.pg_meta_.storage_info_.get_clog_info(); + const ObDataStorageInfo &data_info = result.pg_meta_.storage_info_.get_data_info(); + const ObBaseStorageInfo &clog_info = result.pg_meta_.storage_info_.get_clog_info(); const ObReplicaType replica_type = ctx.replica_op_arg_.dst_.get_replica_type(); const int64_t remote_last_replay_log_id = result.pg_meta_.storage_info_.get_clog_info().get_last_replay_log_id(); const int64_t remote_publish_version = data_info.get_publish_version(); @@ -7242,12 +7250,12 @@ int ObMigratePrepareTask::is_valid_migrate_src( } int ObMigratePrepareTask::is_valid_standby_restore_src( - const obrpc::ObFetchPGInfoResult& result, ObMigrateCtx& ctx, bool& is_valid) + const obrpc::ObFetchPGInfoResult &result, ObMigrateCtx &ctx, bool &is_valid) { int ret = OB_SUCCESS; is_valid = false; - const ObDataStorageInfo& data_info = result.pg_meta_.storage_info_.get_data_info(); - const ObBaseStorageInfo& clog_info = result.pg_meta_.storage_info_.get_clog_info(); + const ObDataStorageInfo &data_info = result.pg_meta_.storage_info_.get_data_info(); + const ObBaseStorageInfo &clog_info = result.pg_meta_.storage_info_.get_clog_info(); const ObReplicaType replica_type = ctx.replica_op_arg_.dst_.get_replica_type(); const int64_t remote_last_replay_log_id = result.pg_meta_.storage_info_.get_clog_info().get_last_replay_log_id(); @@ -7274,7 +7282,7 @@ int ObMigratePrepareTask::is_valid_standby_restore_src( } int ObMigratePrepareTask::is_valid_rebuild_src( - const obrpc::ObFetchPGInfoResult& result, ObMigrateCtx& ctx, bool& is_valid) + const obrpc::ObFetchPGInfoResult &result, ObMigrateCtx &ctx, bool &is_valid) { int ret = OB_SUCCESS; is_valid = false; @@ -7302,7 +7310,7 @@ int ObMigratePrepareTask::is_valid_rebuild_src( return ret; } -bool ObMigratePrepareTask::can_migrate_src_skip_log_sync(const obrpc::ObFetchPGInfoResult& result, ObMigrateCtx& ctx) +bool ObMigratePrepareTask::can_migrate_src_skip_log_sync(const obrpc::ObFetchPGInfoResult &result, ObMigrateCtx &ctx) { bool b_ret = false; @@ -7320,7 +7328,7 @@ bool ObMigratePrepareTask::can_migrate_src_skip_log_sync(const obrpc::ObFetchPGI int ObMigratePrepareTask::build_migrate_pg_partition_info() { int ret = OB_SUCCESS; - ObIPGPartitionBaseDataMetaObReader* reader = NULL; + ObIPGPartitionBaseDataMetaObReader *reader = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -7348,16 +7356,16 @@ int ObMigratePrepareTask::build_migrate_pg_partition_info() return ret; } -int ObMigratePrepareTask::build_migrate_partition_info(const ObPGPartitionMetaInfo& partition_meta_info, - const common::ObIArray& table_info_res, - const common::ObIArray& table_id_list, ObPartitionMigrateCtx& part_migrate_ctx) +int ObMigratePrepareTask::build_migrate_partition_info(const ObPGPartitionMetaInfo &partition_meta_info, + const common::ObIArray &table_info_res, + const common::ObIArray &table_id_list, ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; ObArray local_tables_info; ObMigrateTableInfo table_info; int64_t cost_ts = ObTimeUtility::current_time(); - const ObPartitionKey& pkey = partition_meta_info.meta_.pkey_; - ObMigratePartitionInfo& info = part_migrate_ctx.copy_info_; + const ObPartitionKey &pkey = partition_meta_info.meta_.pkey_; + ObMigratePartitionInfo &info = part_migrate_ctx.copy_info_; part_migrate_ctx.ctx_ = ctx_; DEBUG_SYNC(BEFORE_BUILD_MIGRATE_PARTITION_INFO); @@ -7377,7 +7385,7 @@ int ObMigratePrepareTask::build_migrate_partition_info(const ObPGPartitionMetaIn for (int64_t i = 0; OB_SUCC(ret) && i < table_info_res.count(); ++i) { table_info.reuse(); local_tables_info.reuse(); - const obrpc::ObFetchTableInfoResult& table_res = table_info_res.at(i); + const obrpc::ObFetchTableInfoResult &table_res = table_info_res.at(i); const uint64_t table_id = table_id_list.at(i); LOG_INFO("build_migrate_partition_info for table", "table_id", table_id); @@ -7417,13 +7425,13 @@ int ObMigratePrepareTask::build_migrate_partition_info(const ObPGPartitionMetaIn } int ObMigratePrepareTask::get_local_table_info( - const uint64_t table_id, const ObPartitionKey& pkey, ObIArray& local_tables_info) + const uint64_t table_id, const ObPartitionKey &pkey, ObIArray &local_tables_info) { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; ObPGPartitionGuard guard; - ObPGPartition* pg_partition = NULL; - ObIPartitionStorage* storage = NULL; + ObPGPartition *pg_partition = NULL; + ObIPartitionStorage *storage = NULL; ObTablesHandle handle; local_tables_info.reuse(); bool is_ready_for_read = false; @@ -7445,12 +7453,12 @@ int ObMigratePrepareTask::get_local_table_info( } else if (OB_ISNULL(storage = pg_partition->get_storage())) { ret = OB_ERR_SYS; LOG_ERROR("storage must not null", K(ret), KP(storage)); - } else if (OB_FAIL(static_cast(storage)->get_partition_store().get_migrate_tables( + } else if (OB_FAIL(static_cast(storage)->get_partition_store().get_migrate_tables( table_id, handle, is_ready_for_read))) { LOG_WARN("failed to get effective tables", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < handle.get_count(); ++i) { - const ObITable* table = handle.get_table(i); + const ObITable *table = handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); @@ -7466,9 +7474,9 @@ int ObMigratePrepareTask::get_local_table_info( return ret; } -int ObMigratePrepareTask::build_migrate_table_info(const uint64_t table_id, const ObPartitionKey& pkey, - ObIArray& local_tables_info, const obrpc::ObFetchTableInfoResult& result, - ObMigrateTableInfo& info, ObPartitionMigrateCtx& part_ctx) +int ObMigratePrepareTask::build_migrate_table_info(const uint64_t table_id, const ObPartitionKey &pkey, + ObIArray &local_tables_info, const obrpc::ObFetchTableInfoResult &result, + ObMigrateTableInfo &info, ObPartitionMigrateCtx &part_ctx) { int ret = OB_SUCCESS; ObArray remote_major_sstables; @@ -7477,7 +7485,7 @@ int ObMigratePrepareTask::build_migrate_table_info(const uint64_t table_id, cons ObArray remote_gc_inc_sstables; ObArray local_major_sstables; ObArray local_inc_sstables; - bool& need_reuse_local_minor = part_ctx.need_reuse_local_minor_; + bool &need_reuse_local_minor = part_ctx.need_reuse_local_minor_; info.reuse(); info.table_id_ = table_id; // TODO only use source minor sstable now, consider performance later @@ -7542,7 +7550,7 @@ int ObMigratePrepareTask::build_migrate_table_info(const uint64_t table_id, cons return ret; } -int ObMigratePrepareTask::fill_log_ts_for_compat(ObMigrateTableInfo& info) +int ObMigratePrepareTask::fill_log_ts_for_compat(ObMigrateTableInfo &info) { int ret = OB_SUCCESS; @@ -7564,14 +7572,14 @@ int ObMigratePrepareTask::fill_log_ts_for_compat(ObMigrateTableInfo& info) } int ObMigratePrepareTask::check_remote_sstables(const uint64_t table_id, - common::ObIArray& remote_major_sstables, - common::ObIArray& remote_inc_tables) + common::ObIArray &remote_major_sstables, + common::ObIArray &remote_inc_tables) { int ret = OB_SUCCESS; bool need_check_major_sstable = true; - const share::schema::ObTableSchema* table_schema = NULL; + const share::schema::ObTableSchema *table_schema = NULL; share::schema::ObSchemaGetterGuard schema_guard; - share::schema::ObMultiVersionSchemaService& schema_service = + share::schema::ObMultiVersionSchemaService &schema_service = share::schema::ObMultiVersionSchemaService::get_instance(); const uint64_t fetch_tenant_id = is_inner_table(table_id) ? OB_SYS_TENANT_ID : extract_tenant_id(table_id); @@ -7617,7 +7625,7 @@ int ObMigratePrepareTask::check_remote_sstables(const uint64_t table_id, return ret; } -int ObMigratePrepareTask::check_remote_inc_sstables_continuity(common::ObIArray& remote_inc_tables) +int ObMigratePrepareTask::check_remote_inc_sstables_continuity(common::ObIArray &remote_inc_tables) { int ret = OB_SUCCESS; @@ -7629,7 +7637,7 @@ int ObMigratePrepareTask::check_remote_inc_sstables_continuity(common::ObIArray< } else { int64_t last_end_log_ts = remote_inc_tables.at(0).get_start_log_ts(); for (int64_t i = 0; OB_SUCC(ret) && i < remote_inc_tables.count(); ++i) { - const ObITable::TableKey& remote_inc_table = remote_inc_tables.at(i); + const ObITable::TableKey &remote_inc_table = remote_inc_tables.at(i); if (remote_inc_table.is_complement_minor_sstable()) { // skip buffer minor sstable and complement sstable } else if (remote_inc_table.get_start_log_ts() != last_end_log_ts) { @@ -7645,11 +7653,11 @@ int ObMigratePrepareTask::check_remote_inc_sstables_continuity(common::ObIArray< } // TODO only use source minor sstable now, consider performance later -int ObMigratePrepareTask::build_remote_minor_sstables(const common::ObIArray& local_minor_sstables, - const common::ObIArray& tmp_remote_minor_sstables, - const common::ObIArray& tmp_remote_gc_minor_sstables, - common::ObIArray& remote_minor_sstables, - common::ObIArray& remote_gc_minor_sstables, bool& need_reuse_local_minor) +int ObMigratePrepareTask::build_remote_minor_sstables(const common::ObIArray &local_minor_sstables, + const common::ObIArray &tmp_remote_minor_sstables, + const common::ObIArray &tmp_remote_gc_minor_sstables, + common::ObIArray &remote_minor_sstables, + common::ObIArray &remote_gc_minor_sstables, bool &need_reuse_local_minor) { return OB_NOT_SUPPORTED; int ret = OB_SUCCESS; @@ -7666,7 +7674,7 @@ int ObMigratePrepareTask::build_remote_minor_sstables(const common::ObIArray local_last_log_ts_range.end_log_ts_) { need_reuse_local_minor = false; @@ -7684,7 +7692,7 @@ int ObMigratePrepareTask::build_remote_minor_sstables(const common::ObIArray local_last_log_ts_range.end_log_ts_) { if (OB_FAIL(remote_gc_minor_sstables.push_back(remote_sstable))) { LOG_WARN("failed to push back remote sstable", K(ret), K(remote_sstable)); @@ -7703,9 +7711,9 @@ int ObMigratePrepareTask::build_remote_minor_sstables(const common::ObIArray& local_major_tables, ObIArray& local_inc_tables, - ObIArray& remote_major_tables, ObIArray& remote_inc_tables, - ObIArray& copy_sstables, ObPartitionMigrateCtx& part_ctx) + ObIArray &local_major_tables, ObIArray &local_inc_tables, + ObIArray &remote_major_tables, ObIArray &remote_inc_tables, + ObIArray ©_sstables, ObPartitionMigrateCtx &part_ctx) { int ret = OB_SUCCESS; @@ -7721,9 +7729,9 @@ int ObMigratePrepareTask::build_migrate_major_sstable(const bool need_reuse_loca return ret; } -int ObMigratePrepareTask::build_migrate_major_sstable_(ObIArray& local_major_tables, - ObIArray& local_inc_tables, ObIArray& remote_major_tables, - ObIArray& remote_inc_tables, ObIArray& copy_sstables) +int ObMigratePrepareTask::build_migrate_major_sstable_(ObIArray &local_major_tables, + ObIArray &local_inc_tables, ObIArray &remote_major_tables, + ObIArray &remote_inc_tables, ObIArray ©_sstables) { int ret = OB_SUCCESS; // static func, skip check is_inited_ @@ -7739,7 +7747,7 @@ int ObMigratePrepareTask::build_migrate_major_sstable_(ObIArray& local_major_tables, ObIArray& local_inc_tables, - ObIArray& remote_major_tables, ObIArray& remote_inc_tables, - ObIArray& copy_sstables, ObPartitionMigrateCtx& part_ctx) + ObIArray &local_major_tables, ObIArray &local_inc_tables, + ObIArray &remote_major_tables, ObIArray &remote_inc_tables, + ObIArray ©_sstables, ObPartitionMigrateCtx &part_ctx) { int ret = OB_SUCCESS; int64_t max_snapshot_version = 0; @@ -7826,14 +7834,14 @@ int ObMigratePrepareTask::build_migrate_major_sstable_v2_(const bool need_reuse_ // need local major const int64_t follower_replica_merge_level = GCONF._follower_replica_merge_level; for (int64_t i = 0; i < local_major_tables.count(); ++i) { - const ObITable::TableKey& local_major_table = local_major_tables.at(i); + const ObITable::TableKey &local_major_table = local_major_tables.at(i); if (ObITable::is_major_sstable(local_major_table.table_type_)) { max_snapshot_version = local_major_table.get_snapshot_version(); } } for (int64_t i = 0; OB_SUCC(ret) && i < remote_major_tables.count(); ++i) { - const ObITable::TableKey& remote_major_table = remote_major_tables.at(i); + const ObITable::TableKey &remote_major_table = remote_major_tables.at(i); if (remote_major_table.get_snapshot_version() <= max_snapshot_version && !remote_major_table.is_trans_sstable()) { need_add_local_major = true; continue; @@ -7854,15 +7862,15 @@ int ObMigratePrepareTask::build_migrate_major_sstable_v2_(const bool need_reuse_ if (OB_SUCC(ret) && need_add_local_major) { ObTableHandle table_handle; for (int64_t i = 0; OB_SUCC(ret) && i < local_major_tables.count(); ++i) { - const ObITable::TableKey& local_major_table = local_major_tables.at(i); - ObITable* table = NULL; + const ObITable::TableKey &local_major_table = local_major_tables.at(i); + ObITable *table = NULL; table_handle.reset(); if (OB_FAIL(ObPartitionService::get_instance().acquire_sstable(local_major_table, table_handle))) { LOG_WARN("failed to get complete sstable by key", K(ret), K(local_major_table)); } else if (NULL == (table = table_handle.get_table())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be NULL", K(ret), KP(table)); - } else if (OB_FAIL(part_ctx.add_sstable(*reinterpret_cast(table)))) { + } else if (OB_FAIL(part_ctx.add_sstable(*reinterpret_cast(table)))) { LOG_WARN("failed to add sstable", K(ret)); } } @@ -7879,9 +7887,9 @@ int ObMigratePrepareTask::build_migrate_major_sstable_v2_(const bool need_reuse_ return ret; } -int ObMigratePrepareTask::get_migrate_suitable_src(const common::ObIArray& src_info_array, - const ObReplicaOpArg& arg, IsValidSrcFunc is_valid_src, bool& find_suitable_src, ObPartitionGroupMeta& pg_meta, - ObMigrateSrcInfo& src_info) +int ObMigratePrepareTask::get_migrate_suitable_src(const common::ObIArray &src_info_array, + const ObReplicaOpArg &arg, IsValidSrcFunc is_valid_src, bool &find_suitable_src, ObPartitionGroupMeta &pg_meta, + ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; find_suitable_src = false; @@ -7900,7 +7908,7 @@ int ObMigratePrepareTask::get_migrate_suitable_src(const common::ObIArray& src_info_array) + const ObReplicaOpArg &arg, ObIArray &src_info_array) { int ret = OB_SUCCESS; ObArray tmp_info_array; @@ -7972,7 +7980,7 @@ int ObMigratePrepareTask::get_minor_src_candidate_with_region( } int ObMigratePrepareTask::get_minor_src_candidate_without_region( - const ObReplicaOpArg& arg, common::ObIArray& src_info_array) + const ObReplicaOpArg &arg, common::ObIArray &src_info_array) { int ret = OB_SUCCESS; @@ -7989,7 +7997,7 @@ int ObMigratePrepareTask::get_minor_src_candidate_without_region( { ret = OB_SUCCESS; for (int64_t i = 0; i < src_info_array.count() && !found_recommendable_src; ++i) { - const ObMigrateSrcInfo& src_info = src_info_array.at(i); + const ObMigrateSrcInfo &src_info = src_info_array.at(i); if (arg.data_src_.get_server() == src_info.src_addr_) { found_recommendable_src = true; } @@ -8010,7 +8018,7 @@ int ObMigratePrepareTask::get_minor_src_candidate_without_region( } int ObMigratePrepareTask::choose_recommendable_src( - const ObReplicaOpArg& arg, ObPartitionGroupMeta& pg_meta, ObMigrateSrcInfo& src_info) + const ObReplicaOpArg &arg, ObPartitionGroupMeta &pg_meta, ObMigrateSrcInfo &src_info) { int ret = OB_SUCCESS; ObPartitionGroupInfoResult src_result; @@ -8046,8 +8054,8 @@ int ObMigratePrepareTask::choose_recommendable_src( } int ObMigratePrepareTask::build_migrate_minor_sstable(const bool need_reuse_local_minor, - ObIArray& local_inc_tables, ObIArray& remote_inc_tables, - ObIArray& remote_gc_inc_sstables, ObIArray& copy_sstables) + ObIArray &local_inc_tables, ObIArray &remote_inc_tables, + ObIArray &remote_gc_inc_sstables, ObIArray ©_sstables) { int ret = OB_SUCCESS; // ObITable::Tablekey's table_key.version is mark major version flag which is smaller than copy sstables need to @@ -8069,7 +8077,7 @@ int ObMigratePrepareTask::build_migrate_minor_sstable(const bool need_reuse_loca ObMigrateTableInfo::SSTableInfo info; for (int64_t i = 0; OB_SUCC(ret) && i < remote_inc_tables.count(); ++i) { info.reset(); - const ObITable::TableKey& remote_table = remote_inc_tables.at(i); + const ObITable::TableKey &remote_table = remote_inc_tables.at(i); info.src_table_key_ = remote_table; info.dest_base_version_ = remote_table.trans_version_range_.base_version_; info.dest_log_ts_range_ = remote_table.log_ts_range_; @@ -8093,7 +8101,7 @@ int ObMigratePrepareTask::build_migrate_minor_sstable(const bool need_reuse_loca } int ObMigratePrepareTask::check_can_reuse_sstable( - const ObPartitionKey& pkey, ObMigrateTableInfo& table_info, ObPartitionMigrateCtx& part_ctx) + const ObPartitionKey &pkey, ObMigrateTableInfo &table_info, ObPartitionMigrateCtx &part_ctx) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -8138,8 +8146,8 @@ int ObMigratePrepareTask::check_can_reuse_sstable( return ret; } -int ObMigrateUtil::get_report_result(const common::ObIArray& report_list, - common::ObIArray& report_res_list) +int ObMigrateUtil::get_report_result(const common::ObIArray &report_list, + common::ObIArray &report_res_list) { int ret = OB_SUCCESS; ObPartMigrationRes tmp_res; @@ -8152,7 +8160,7 @@ int ObMigrateUtil::get_report_result(const common::ObIArray(table)))) { + } else if (OB_FAIL(part_ctx.add_sstable(*reinterpret_cast(table)))) { LOG_WARN("failed to add sstable", K(ret)); } else { is_reuse = true; @@ -8226,7 +8234,7 @@ int ObMigratePrepareTask::prepare_new_partition() int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; ObStorageFileHandle file_handle; - ObPartGroupMigrationTask* group_task = NULL; + ObPartGroupMigrationTask *group_task = NULL; bool has_mark_creating = false; if (!is_inited_) { @@ -8262,7 +8270,7 @@ int ObMigratePrepareTask::prepare_new_partition() } else if (OB_ISNULL(ctx_->get_partition()) || OB_ISNULL(&(ctx_->get_partition()->get_pg_storage()))) { ret = OB_ERR_SYS; LOG_ERROR("partition or storage must not null", K(ctx_->get_partition()), K(ret)); - } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { + } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { } else if (OB_FAIL(group_task->set_create_new_pg(ctx_->get_partition()->get_partition_key()))) { LOG_WARN("failed to set create new pg", K(ret)); } else { @@ -8289,10 +8297,10 @@ int ObMigratePrepareTask::prepare_new_partition() return ret; } -int ObMigrateUtil::enable_replay_with_new_partition(ObMigrateCtx& ctx) +int ObMigrateUtil::enable_replay_with_new_partition(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; LOG_INFO("enable_replay_with_new_partition"); if (OB_ISNULL(partition = ctx.get_partition())) { @@ -8338,8 +8346,8 @@ int ObMigrateUtil::enable_replay_with_new_partition(ObMigrateCtx& ctx) int ObMigrateTaskGeneratorTask::deal_with_old_partition() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - clog::ObIPartitionLogService* pls = NULL; + ObIPartitionGroup *partition = NULL; + clog::ObIPartitionLogService *pls = NULL; const bool write_slog = true; bool is_log_sync = false; @@ -8362,9 +8370,9 @@ int ObMigrateTaskGeneratorTask::deal_with_old_partition() bool is_replica_with_data = true; common::ObReplicaType replica_type = ctx_->replica_op_arg_.dst_.get_replica_type(); common::ObReplicaType local_replica_type = partition->get_replica_type(); - const ObReplicaProperty& local_replica_property = partition->get_replica_property(); + const ObReplicaProperty &local_replica_property = partition->get_replica_property(); ctx_->need_offline_ = true; - const ObPartitionSplitInfo& split_info = ctx_->pg_meta_.split_info_; + const ObPartitionSplitInfo &split_info = ctx_->pg_meta_.split_info_; if (split_info.is_valid() && OB_FAIL(partition->save_split_info(split_info))) { LOG_WARN("failed to save split info", K(ret), K(split_info), K(*ctx_)); } else if (OB_FAIL(update_multi_version_start())) { @@ -8425,10 +8433,11 @@ int ObMigrateTaskGeneratorTask::deal_with_old_partition() return ret; } -int ObMigrateUtil::enable_replay_with_old_partition(ObMigrateCtx& ctx) +int ObMigrateUtil::enable_replay_with_old_partition(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; + ObReplicaRestoreStatus restore_status = ObReplicaRestoreStatus::REPLICA_RESTORE_MAX; LOG_INFO("start enable replay"); if (!ctx.is_valid()) { @@ -8437,14 +8446,26 @@ int ObMigrateUtil::enable_replay_with_old_partition(ObMigrateCtx& ctx) } else if (OB_ISNULL(partition = ctx.get_partition())) { ret = OB_ERR_SYS; LOG_ERROR("cannot use old partition", K(ret)); + } else if (FALSE_IT(restore_status = partition->get_pg_storage().get_restore_status())) { } else { int64_t retry_times = 0; - ObPartitionGroupMeta& meta = ctx.pg_meta_; - ObBaseStorageInfo& clog_info = meta.storage_info_.get_clog_info(); - ObDataStorageInfo& data_info = meta.storage_info_.get_data_info(); - int64_t restore_snapshot_version = meta.restore_snapshot_version_; - uint64_t last_restore_log_id = meta.last_restore_log_id_; - int64_t last_restore_log_ts = meta.last_restore_log_ts_; + int64_t restore_snapshot_version = OB_INVALID_VERSION; + uint64_t last_restore_log_id = OB_INVALID_ID; + int64_t last_restore_log_ts = OB_INVALID_TIMESTAMP; + + ObPartitionGroupMeta &meta = ctx.pg_meta_; + ObBaseStorageInfo &clog_info = meta.storage_info_.get_clog_info(); + ObDataStorageInfo &data_info = meta.storage_info_.get_data_info(); + if (ObReplicaRestoreStatus::REPLICA_NOT_RESTORE == restore_status) { + restore_snapshot_version = meta.restore_snapshot_version_; + last_restore_log_id = meta.last_restore_log_id_; + last_restore_log_ts = meta.last_restore_log_ts_; + } else { + if (OB_FAIL(partition->get_pg_storage().get_restore_replay_info( + last_restore_log_id, last_restore_log_ts, restore_snapshot_version))) { + LOG_WARN("failed to get restore replay info", K(ret)); + } + } const int64_t local_last_replay_log_id = partition->get_log_service()->get_next_index_log_id() - 1; const int64_t src_last_replay_log_id = @@ -8507,10 +8528,10 @@ int ObMigrateUtil::enable_replay_with_old_partition(ObMigrateCtx& ctx) } int ObMigrateUtil::push_reference_tables_if_need( - ObMigrateCtx& ctx, const ObPartitionSplitInfo& split_info, const int64_t last_replay_log_id) + ObMigrateCtx &ctx, const ObPartitionSplitInfo &split_info, const int64_t last_replay_log_id) { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; if (!ctx.is_valid()) { ret = OB_NOT_INIT; LOG_ERROR("ctx not valid", K(ret), K(ctx)); @@ -8518,7 +8539,7 @@ int ObMigrateUtil::push_reference_tables_if_need( ret = OB_ERR_SYS; LOG_ERROR("cannot use old partition", K(ret)); } else { - ObPartitionGroupMeta& meta = ctx.pg_meta_; + ObPartitionGroupMeta &meta = ctx.pg_meta_; if (split_info.get_src_partition() == meta.pg_key_) { const int64_t source_log_id = split_info.get_source_log_id(); if (last_replay_log_id >= source_log_id && OB_INVALID_ID != source_log_id) { @@ -8533,15 +8554,15 @@ int ObMigrateUtil::push_reference_tables_if_need( return ret; } -int ObMigrateUtil::merge_trans_table(ObMigrateCtx& ctx) +int ObMigrateUtil::merge_trans_table(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; - ObIPartitionGroup* pg = nullptr; - ObSSTable* trans_sstable = nullptr; + ObIPartitionGroup *pg = nullptr; + ObSSTable *trans_sstable = nullptr; ObPartitionKey pg_key; bool is_replica_with_data = false; - if (OB_ISNULL(trans_sstable = static_cast(ctx.trans_table_handle_.get_table()))) { + if (OB_ISNULL(trans_sstable = static_cast(ctx.trans_table_handle_.get_table()))) { FLOG_INFO("trans sstable is empty", K(ret), K(ctx)); if (need_migrate_trans_table(ctx.replica_op_arg_.type_) && ctx.is_migrate_compat_version()) { if (OB_FAIL(ObMigrateUtil::create_empty_trans_sstable_for_compat(ctx))) { @@ -8587,7 +8608,7 @@ int ObMigrateUtil::merge_trans_table(ObMigrateCtx& ctx) return ret; } -int ObMigrateUtil::create_empty_trans_sstable_for_compat(ObMigrateCtx& ctx) +int ObMigrateUtil::create_empty_trans_sstable_for_compat(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; ObTableSchema table_schema; @@ -8607,7 +8628,7 @@ int ObMigrateUtil::create_empty_trans_sstable_for_compat(ObMigrateCtx& ctx) } else { ObCreateSSTableParamWithTable param; ObITable::TableKey table_key; - ObSSTable* sstable = nullptr; + ObSSTable *sstable = nullptr; ObTableHandle table_handle; table_key.table_type_ = ObITable::TableType::TRANS_SSTABLE; @@ -8645,12 +8666,12 @@ int ObMigrateUtil::create_empty_trans_sstable_for_compat(ObMigrateCtx& ctx) } int ObMigrateUtil::add_trans_sstable_to_part_ctx( - const ObPartitionKey& trans_table_pkey, ObSSTable& sstable, ObMigrateCtx& ctx) + const ObPartitionKey &trans_table_pkey, ObSSTable &sstable, ObMigrateCtx &ctx) { int ret = OB_SUCCESS; bool found = false; for (int64_t i = 0; OB_SUCC(ret) && i < ctx.part_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_ctx = ctx.part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_ctx = ctx.part_ctx_array_.at(i); if (part_ctx.copy_info_.meta_.pkey_.is_trans_table()) { if (OB_FAIL(part_ctx.add_sstable(sstable))) { LOG_WARN("failed to add new trans sstable to partition migrate ctx", K(ret), K(trans_table_pkey)); @@ -8682,7 +8703,7 @@ int ObMigrateTaskGeneratorTask::deal_with_rebuild_partition() { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; common::ObAddr leader; ctx_->need_offline_ = true; ObRole role; @@ -8717,8 +8738,8 @@ int ObMigrateTaskGeneratorTask::deal_with_rebuild_partition() LOG_WARN("leader can not as rebuild dst", K(ret), K(leader), "myaddr", MYADDR, "arg", ctx_->replica_op_arg_); } } else { - ObBaseStorageInfo& remote_clog_info = ctx_->pg_meta_.storage_info_.get_clog_info(); - const ObPartitionSplitInfo& split_info = ctx_->pg_meta_.split_info_; + ObBaseStorageInfo &remote_clog_info = ctx_->pg_meta_.storage_info_.get_clog_info(); + const ObPartitionSplitInfo &split_info = ctx_->pg_meta_.split_info_; const int64_t local_max_confirm_log_id = partition->get_log_service()->get_next_index_log_id() - 1; const int64_t src_last_replay_log_id = remote_clog_info.get_last_replay_log_id(); const bool is_replica_with_remote_memstore = partition->get_pg_storage().is_replica_with_remote_memstore(); @@ -8788,7 +8809,7 @@ int ObMigrateTaskGeneratorTask::deal_with_rebuild_partition() int ObMigrateTaskGeneratorTask::deal_with_standby_restore_partition() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; LOG_INFO("start deal_with_standby restore_partition"); @@ -8806,7 +8827,7 @@ int ObMigrateTaskGeneratorTask::deal_with_standby_restore_partition() ret = OB_ERR_SYS; LOG_ERROR("cannot use old partition", K(ret)); } else { - ObBaseStorageInfo& remote_clog_info = ctx_->pg_meta_.storage_info_.get_clog_info(); + ObBaseStorageInfo &remote_clog_info = ctx_->pg_meta_.storage_info_.get_clog_info(); uint64_t unused_log_id = OB_INVALID_ID; ObBaseStorageInfo clog_info; if (OB_FAIL(partition->get_log_service()->get_base_storage_info(clog_info, unused_log_id))) { @@ -8826,10 +8847,10 @@ int ObMigrateTaskGeneratorTask::deal_with_standby_restore_partition() return ret; } -int ObMigrateTaskGeneratorTask::generate_pg_validate_tasks(ObIArray& last_task_array) +int ObMigrateTaskGeneratorTask::generate_pg_validate_tasks(ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); @@ -8845,10 +8866,10 @@ int ObMigrateTaskGeneratorTask::generate_pg_validate_tasks(ObIArray& l return ret; } -int ObMigrateTaskGeneratorTask::generate_validate_tasks(ObITask*& last_task) +int ObMigrateTaskGeneratorTask::generate_validate_tasks(ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_validate_finish_task = NULL; + ObFakeTask *wait_validate_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -8868,10 +8889,10 @@ int ObMigrateTaskGeneratorTask::generate_validate_tasks(ObITask*& last_task) return ret; } -int ObMigrateTaskGeneratorTask::generate_validate_tasks(ObFakeTask& wait_validate_finish_task) +int ObMigrateTaskGeneratorTask::generate_validate_tasks(ObFakeTask &wait_validate_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; @@ -8884,10 +8905,10 @@ int ObMigrateTaskGeneratorTask::generate_validate_tasks(ObFakeTask& wait_validat return ret; } -int ObMigrateTaskGeneratorTask::generate_validate_backup_tasks(share::ObITask*& parent_task) +int ObMigrateTaskGeneratorTask::generate_validate_backup_tasks(share::ObITask *&parent_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_finish_task = NULL; + ObFakeTask *wait_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate prepare task do not init", K(ret)); @@ -8907,15 +8928,15 @@ int ObMigrateTaskGeneratorTask::generate_validate_backup_tasks(share::ObITask*& return ret; } -int ObMigrateTaskGeneratorTask::generate_validate_backup_task(share::ObITask* parent_task, share::ObITask* child_task) +int ObMigrateTaskGeneratorTask::generate_validate_backup_task(share::ObITask *parent_task, share::ObITask *child_task) { int ret = OB_SUCCESS; const int64_t task_idx = 0; const int64_t clog_file_id = 1; - ObValidatePrepareTask* prepare_task = NULL; - ObValidateClogDataTask* clog_task = NULL; - ObValidateBaseDataTask* base_task = NULL; - ObValidateFinishTask* finish_task = NULL; + ObValidatePrepareTask *prepare_task = NULL; + ObValidateClogDataTask *clog_task = NULL; + ObValidateBaseDataTask *base_task = NULL; + ObValidateFinishTask *finish_task = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -8976,13 +8997,13 @@ int ObMigrateTaskGeneratorTask::generate_validate_backup_task(share::ObITask* pa return ret; } -int ObMigrateTaskGeneratorTask::build_validate_backup_ctx(ObValidateBackupPGCtx& pg_ctx) +int ObMigrateTaskGeneratorTask::build_validate_backup_ctx(ObValidateBackupPGCtx &pg_ctx) { int ret = OB_SUCCESS; pg_ctx.reset(); ObBackupBaseDataPathInfo path_info; ObArray macro_index_list; - const ObPartitionKey& pg_key = ctx_->replica_op_arg_.validate_arg_.pg_key_; + const ObPartitionKey &pg_key = ctx_->replica_op_arg_.validate_arg_.pg_key_; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -9004,19 +9025,19 @@ int ObMigrateTaskGeneratorTask::build_validate_backup_ctx(ObValidateBackupPGCtx& } int ObMigrateTaskGeneratorTask::fetch_pg_macro_index_list( - const ObPartitionKey& pg_key, ObValidateBackupPGCtx& pg_ctx, ObIArray& macro_index_list) + const ObPartitionKey &pg_key, ObValidateBackupPGCtx &pg_ctx, ObIArray ¯o_index_list) { int ret = OB_SUCCESS; share::ObBackupMetaIndex meta_index; - ObArray* index_list = NULL; - ObBackupMetaIndexStore* meta_index_store = NULL; - ObBackupMacroIndexStore& macro_index_store = ctx_->macro_index_store_; - ObPartGroupMigrationTask* group_task = NULL; + ObArray *index_list = NULL; + ObBackupMetaIndexStore *meta_index_store = NULL; + ObBackupMacroIndexStore ¯o_index_store = ctx_->macro_index_store_; + ObPartGroupMigrationTask *group_task = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); - } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { + } else if (FALSE_IT(group_task = reinterpret_cast(ctx_->group_task_))) { } else if (FALSE_IT(meta_index_store = &group_task->get_meta_index_store())) { } else if (OB_ISNULL(meta_index_store)) { ret = OB_ERR_UNEXPECTED; @@ -9043,10 +9064,10 @@ int ObMigrateTaskGeneratorTask::fetch_pg_macro_index_list( } int ObMigrateTaskGeneratorTask::build_validate_sub_task( - const ObIArray& macro_index_list, ObValidateBackupPGCtx& ctx) + const ObIArray ¯o_index_list, ObValidateBackupPGCtx &ctx) { int ret = OB_SUCCESS; - void* buf = NULL; + void *buf = NULL; int64_t max_macro_block_count_per_task = 1024 /*MAX_MACRO_BLOCK_COUNT_PER_TASK*/; LOG_INFO("start to build validate sub task"); if (OB_UNLIKELY(!is_inited_)) { @@ -9069,7 +9090,7 @@ int ObMigrateTaskGeneratorTask::build_validate_sub_task( } for (int64_t i = 0; OB_SUCC(ret) && i < ctx.sub_task_cnt_; ++i) { - ObValidateBackupPGCtx::SubTask& sub_task = ctx.sub_tasks_[i]; + ObValidateBackupPGCtx::SubTask &sub_task = ctx.sub_tasks_[i]; sub_task.macro_block_count_ = std::min(max_macro_block_count_per_task, macro_index_list.count() - i * max_macro_block_count_per_task); sub_task.pkey_ = ctx.pg_key_; @@ -9085,8 +9106,8 @@ int ObMigrateTaskGeneratorTask::build_validate_sub_task( if (macro_idx >= macro_index_list.count()) { break; } - const ObBackupMacroIndex& macro_index = macro_index_list.at(macro_idx); - ObBackupMacroIndex& index = ctx.sub_tasks_[i].macro_block_infos_[j]; + const ObBackupMacroIndex ¯o_index = macro_index_list.at(macro_idx); + ObBackupMacroIndex &index = ctx.sub_tasks_[i].macro_block_infos_[j]; index = macro_index; } } @@ -9094,10 +9115,10 @@ int ObMigrateTaskGeneratorTask::build_validate_sub_task( return ret; } -int ObMigrateTaskGeneratorTask::generate_pg_backup_backupset_tasks(common::ObIArray& last_task_array) +int ObMigrateTaskGeneratorTask::generate_pg_backup_backupset_tasks(common::ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_ERROR("not inited", KR(ret)); @@ -9112,10 +9133,10 @@ int ObMigrateTaskGeneratorTask::generate_pg_backup_backupset_tasks(common::ObIAr return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_backupset_tasks(share::ObITask*& last_task) +int ObMigrateTaskGeneratorTask::generate_backup_backupset_tasks(share::ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_migrate_finish_task = NULL; + ObFakeTask *wait_migrate_finish_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -9135,10 +9156,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_backupset_tasks(share::ObITask*& return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_backupset_tasks(share::ObFakeTask& wait_finish_task) +int ObMigrateTaskGeneratorTask::generate_backup_backupset_tasks(share::ObFakeTask &wait_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -9151,10 +9172,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_backupset_tasks(share::ObFakeTas return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_backupset_pg_tasks(share::ObITask*& parent_task) +int ObMigrateTaskGeneratorTask::generate_backup_backupset_pg_tasks(share::ObITask *&parent_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_finish_task = NULL; + ObFakeTask *wait_finish_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("migrate prepare task do not init", KR(ret)); @@ -9175,12 +9196,12 @@ int ObMigrateTaskGeneratorTask::generate_backup_backupset_pg_tasks(share::ObITas } int ObMigrateTaskGeneratorTask::generate_backup_backupset_pg_tasks( - share::ObITask*& parent_task, share::ObITask* child_task) + share::ObITask *&parent_task, share::ObITask *child_task) { int ret = OB_SUCCESS; int64_t cur_idx = 0; - ObBackupBackupsetFileTask* copy_task = NULL; - ObBackupBackupsetFinishTask* finish_task = NULL; + ObBackupBackupsetFileTask *copy_task = NULL; + ObBackupBackupsetFinishTask *finish_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -9228,12 +9249,12 @@ int ObMigrateTaskGeneratorTask::generate_backup_backupset_pg_tasks( return ret; } -int ObMigrateTaskGeneratorTask::build_backup_backupset_ctx_v2(ObBackupBackupsetPGFileCtx& pg_ctx) +int ObMigrateTaskGeneratorTask::build_backup_backupset_ctx_v2(ObBackupBackupsetPGFileCtx &pg_ctx) { int ret = OB_SUCCESS; ObStorageUtil util(true /*need retry*/); - const share::ObBackupBackupsetArg& bb_arg = ctx_->replica_op_arg_.backup_backupset_arg_; - const common::ObPGKey& pg_key = bb_arg.pg_key_; + const share::ObBackupBackupsetArg &bb_arg = ctx_->replica_op_arg_.backup_backupset_arg_; + const common::ObPGKey &pg_key = bb_arg.pg_key_; const uint64_t table_id = pg_key.get_table_id(); const int64_t partition_id = pg_key.get_partition_id(); const int64_t compatible = bb_arg.compatible_; @@ -9284,7 +9305,7 @@ int ObMigrateTaskGeneratorTask::build_backup_backupset_ctx_v2(ObBackupBackupsetP } int ObMigrateTaskGeneratorTask::get_backup_backup_minor_task_id( - const share::ObBackupBaseDataPathInfo& path_info, const common::ObPGKey& pg_key, int64_t& task_id) + const share::ObBackupBaseDataPathInfo &path_info, const common::ObPGKey &pg_key, int64_t &task_id) { int ret = OB_SUCCESS; task_id = 0; @@ -9292,7 +9313,7 @@ int ObMigrateTaskGeneratorTask::get_backup_backup_minor_task_id( ObStorageUtil util(true /*need retry*/); const uint64_t table_id = pg_key.get_table_id(); const int64_t partition_id = pg_key.get_partition_id(); - const share::ObBackupBackupsetArg& bb_arg = ctx_->replica_op_arg_.backup_backupset_arg_; + const share::ObBackupBackupsetArg &bb_arg = ctx_->replica_op_arg_.backup_backupset_arg_; ObBackupPath pg_path; ObArray dir_list; if (IS_NOT_INIT) { @@ -9303,8 +9324,8 @@ int ObMigrateTaskGeneratorTask::get_backup_backup_minor_task_id( LOG_WARN("get invalid args", KR(ret), K(pg_key)); } else if (OB_FAIL(ObBackupPathUtil::get_tenant_pg_minor_dir_path(path_info, table_id, partition_id, pg_path))) { LOG_WARN("failed to get tenant pg minor data path", KR(ret), K(path_info), K(pg_key)); - } else if (OB_FAIL(util.list_directories(pg_path.get_obstr(), - path_info.dest_.get_storage_info(), allocator, dir_list))) { + } else if (OB_FAIL( + util.list_directories(pg_path.get_obstr(), path_info.dest_.get_storage_info(), allocator, dir_list))) { LOG_WARN("failed to list files", KR(ret), K(pg_path), K(path_info)); } else if (dir_list.empty()) { ret = OB_ERR_UNEXPECTED; @@ -9312,7 +9333,7 @@ int ObMigrateTaskGeneratorTask::get_backup_backup_minor_task_id( } else { for (int64_t i = 0; OB_SUCC(ret) && i < dir_list.count(); ++i) { int64_t tmp_task_id = 0; - const ObString &dir= dir_list.at(i); + const ObString &dir = dir_list.at(i); const char *str = dir.ptr(); for (int64_t j = 0; OB_SUCC(ret) && j < dir.length(); ++j) { const char end_flag = '/'; @@ -9338,10 +9359,11 @@ int ObMigrateTaskGeneratorTask::get_backup_backup_minor_task_id( return ret; } -int ObMigrateTaskGeneratorTask::generate_pg_backup_archive_log_tasks(common::ObIArray& last_task_array) +int ObMigrateTaskGeneratorTask::generate_pg_backup_archive_log_tasks( + common::ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_ERROR("not inited", KR(ret)); @@ -9356,10 +9378,10 @@ int ObMigrateTaskGeneratorTask::generate_pg_backup_archive_log_tasks(common::ObI return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_archive_log_tasks(share::ObITask*& last_task) +int ObMigrateTaskGeneratorTask::generate_backup_archive_log_tasks(share::ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_migrate_finish_task = NULL; + ObFakeTask *wait_migrate_finish_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_ERROR("not inited", KR(ret)); @@ -9378,10 +9400,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_archive_log_tasks(share::ObITask return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_archive_log_tasks(share::ObFakeTask& wait_finish_task) +int ObMigrateTaskGeneratorTask::generate_backup_archive_log_tasks(share::ObFakeTask &wait_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_ERROR("not inited", KR(ret)); @@ -9393,10 +9415,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_archive_log_tasks(share::ObFakeT return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_archive_log_pg_tasks(share::ObITask*& parent_task) +int ObMigrateTaskGeneratorTask::generate_backup_archive_log_pg_tasks(share::ObITask *&parent_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_finish_task = NULL; + ObFakeTask *wait_finish_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("migrate prepare task do not init", KR(ret)); @@ -9417,11 +9439,11 @@ int ObMigrateTaskGeneratorTask::generate_backup_archive_log_pg_tasks(share::ObIT } int ObMigrateTaskGeneratorTask::generate_backup_archive_log_pg_tasks( - share::ObITask*& parent_task, share::ObITask* child_task) + share::ObITask *&parent_task, share::ObITask *child_task) { int ret = OB_SUCCESS; - ObBackupArchiveLogPGTask* copy_task = NULL; - ObBackupArchiveLogFinishTask* finish_task = NULL; + ObBackupArchiveLogPGTask *copy_task = NULL; + ObBackupArchiveLogFinishTask *finish_task = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -9461,10 +9483,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_archive_log_pg_tasks( return ret; } -int ObMigrateTaskGeneratorTask::build_backup_archive_log_ctx(ObBackupArchiveLogPGCtx& ctx) +int ObMigrateTaskGeneratorTask::build_backup_archive_log_ctx(ObBackupArchiveLogPGCtx &ctx) { int ret = OB_SUCCESS; - const common::ObPGKey& pg_key = ctx_->replica_op_arg_.backup_archive_log_arg_.pg_key_; + const common::ObPGKey &pg_key = ctx_->replica_op_arg_.backup_archive_log_arg_.pg_key_; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("not init", KR(ret)); @@ -9476,10 +9498,10 @@ int ObMigrateTaskGeneratorTask::build_backup_archive_log_ctx(ObBackupArchiveLogP return ret; } -int ObMigrateTaskGeneratorTask::generate_pg_backup_tasks(ObIArray& last_task_array) +int ObMigrateTaskGeneratorTask::generate_pg_backup_tasks(ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); @@ -9500,10 +9522,10 @@ int ObMigrateTaskGeneratorTask::generate_pg_backup_tasks(ObIArray& las return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_tasks(ObITask*& last_task) +int ObMigrateTaskGeneratorTask::generate_backup_tasks(ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_migrate_finish_task = NULL; + ObFakeTask *wait_migrate_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -9523,10 +9545,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_tasks(ObITask*& last_task) return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_tasks(ObFakeTask& wait_migrate_finish_task) +int ObMigrateTaskGeneratorTask::generate_backup_tasks(ObFakeTask &wait_migrate_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; @@ -9539,10 +9561,10 @@ int ObMigrateTaskGeneratorTask::generate_backup_tasks(ObFakeTask& wait_migrate_f return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_major_tasks(share::ObITask*& parent_task) +int ObMigrateTaskGeneratorTask::generate_backup_major_tasks(share::ObITask *&parent_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_finish_task = NULL; + ObFakeTask *wait_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate prepare task do not init", K(ret)); @@ -9562,11 +9584,11 @@ int ObMigrateTaskGeneratorTask::generate_backup_major_tasks(share::ObITask*& par return ret; } -int ObMigrateTaskGeneratorTask::generate_backup_major_copy_task(ObITask* parent_task, ObITask* child_task) +int ObMigrateTaskGeneratorTask::generate_backup_major_copy_task(ObITask *parent_task, ObITask *child_task) { int ret = OB_SUCCESS; - ObBackupCopyPhysicalTask* copy_task = NULL; - ObBackupFinishTask* finish_task = NULL; + ObBackupCopyPhysicalTask *copy_task = NULL; + ObBackupFinishTask *finish_task = NULL; const int64_t task_idx = 0; if (OB_UNLIKELY(!is_inited_)) { @@ -9615,7 +9637,7 @@ int ObMigrateTaskGeneratorTask::generate_backup_major_copy_task(ObITask* parent_ return ret; } -int ObMigrateTaskGeneratorTask::build_backup_physical_ctx(ObBackupPhysicalPGCtx& physical_backup_ctx) +int ObMigrateTaskGeneratorTask::build_backup_physical_ctx(ObBackupPhysicalPGCtx &physical_backup_ctx) { int ret = OB_SUCCESS; @@ -9638,7 +9660,7 @@ int ObMigrateTaskGeneratorTask::build_backup_physical_ctx(ObBackupPhysicalPGCtx& return ret; } -int ObMigrateTaskGeneratorTask::fetch_backup_sstables(ObIArray& table_keys) +int ObMigrateTaskGeneratorTask::fetch_backup_sstables(ObIArray &table_keys) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -9647,19 +9669,19 @@ int ObMigrateTaskGeneratorTask::fetch_backup_sstables(ObIArraypart_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_migrate_ctx = ctx_->part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_migrate_ctx = ctx_->part_ctx_array_.at(i); if (OB_LIKELY(!part_migrate_ctx.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("part_migrate_ctx is invalid", K(ret), K(part_migrate_ctx)); } else { // tables - const ObArray& table_infos = part_migrate_ctx.copy_info_.table_infos_; + const ObArray &table_infos = part_migrate_ctx.copy_info_.table_infos_; for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) { - const ObMigrateTableInfo& table_info = table_infos.at(i); + const ObMigrateTableInfo &table_info = table_infos.at(i); // major sstables for (int64_t sstable_idx = 0; OB_SUCC(ret) && sstable_idx < table_info.major_sstables_.count(); ++sstable_idx) { - const ObITable::TableKey& major_table_key = table_info.major_sstables_.at(sstable_idx).src_table_key_; + const ObITable::TableKey &major_table_key = table_info.major_sstables_.at(sstable_idx).src_table_key_; if (OB_UNLIKELY(!major_table_key.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid major table key", K(ret), K(major_table_key)); @@ -9677,7 +9699,7 @@ int ObMigrateTaskGeneratorTask::fetch_backup_sstables(ObIArray& last_task_array) +int ObMigrateTaskGeneratorTask::generate_pg_migrate_tasks(ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); @@ -9725,7 +9747,7 @@ int ObMigrateTaskGeneratorTask::generate_pg_migrate_tasks(ObIArray& la LOG_WARN("no need to generate migrate tasks", K(ret), K(ctx_->replica_op_arg_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_migrate_ctx = ctx_->part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_migrate_ctx = ctx_->part_ctx_array_.at(i); if (part_migrate_ctx.copy_info_.meta_.pkey_.is_trans_table()) { continue; } else if (OB_FAIL(generate_migrate_tasks(part_migrate_ctx, last_task))) { @@ -9738,10 +9760,10 @@ int ObMigrateTaskGeneratorTask::generate_pg_migrate_tasks(ObIArray& la return ret; } -int ObMigrateTaskGeneratorTask::generate_pg_rebuild_tasks(ObIArray& last_task_array) +int ObMigrateTaskGeneratorTask::generate_pg_rebuild_tasks(ObIArray &last_task_array) { int ret = OB_SUCCESS; - ObITask* last_task = NULL; + ObITask *last_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); @@ -9750,7 +9772,7 @@ int ObMigrateTaskGeneratorTask::generate_pg_rebuild_tasks(ObIArray& la LOG_WARN("no need to generate rebuild tasks", K(ret), K(ctx_->replica_op_arg_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_migrate_ctx = ctx_->part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_migrate_ctx = ctx_->part_ctx_array_.at(i); if (part_migrate_ctx.copy_info_.meta_.pkey_.is_trans_table()) { continue; } else if (OB_FAIL(generate_rebuild_tasks(part_migrate_ctx, last_task))) { @@ -9763,10 +9785,10 @@ int ObMigrateTaskGeneratorTask::generate_pg_rebuild_tasks(ObIArray& la return ret; } -int ObMigrateTaskGeneratorTask::generate_migrate_tasks(ObPartitionMigrateCtx& part_migrate_ctx, ObITask*& last_task) +int ObMigrateTaskGeneratorTask::generate_migrate_tasks(ObPartitionMigrateCtx &part_migrate_ctx, ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_migrate_finish_task = NULL; + ObFakeTask *wait_migrate_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -9780,10 +9802,10 @@ int ObMigrateTaskGeneratorTask::generate_migrate_tasks(ObPartitionMigrateCtx& pa ret = OB_ERR_SYS; LOG_ERROR("wait_rebuild_finish_task must not null", K(ret)); } else { - const ObMigratePartitionInfo& copy_info = part_migrate_ctx.copy_info_; - const ObArray& table_infos = copy_info.table_infos_; + const ObMigratePartitionInfo ©_info = part_migrate_ctx.copy_info_; + const ObArray &table_infos = copy_info.table_infos_; for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) { - const ObMigrateTableInfo& table_info = table_infos.at(i); + const ObMigrateTableInfo &table_info = table_infos.at(i); if (OB_FAIL(generate_migrate_tasks( ctx_->migrate_src_info_, part_migrate_ctx, table_info, *wait_migrate_finish_task))) { LOG_WARN("failed to generate_migrate_tasks", K(ret), K(i), K(table_info), K(part_migrate_ctx)); @@ -9805,10 +9827,10 @@ int ObMigrateTaskGeneratorTask::generate_migrate_tasks(ObPartitionMigrateCtx& pa return ret; } -int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(ObPartitionMigrateCtx& part_migrate_ctx, ObITask*& last_task) +int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(ObPartitionMigrateCtx &part_migrate_ctx, ObITask *&last_task) { int ret = OB_SUCCESS; - ObFakeTask* wait_rebuild_finish_task = NULL; + ObFakeTask *wait_rebuild_finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -9822,10 +9844,10 @@ int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(ObPartitionMigrateCtx& pa ret = OB_ERR_SYS; LOG_ERROR("wait_rebuild_finish_task must not null", K(ret)); } else { - const ObMigratePartitionInfo& copy_info = part_migrate_ctx.copy_info_; - const ObArray& table_infos = copy_info.table_infos_; + const ObMigratePartitionInfo ©_info = part_migrate_ctx.copy_info_; + const ObArray &table_infos = copy_info.table_infos_; for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) { - const ObMigrateTableInfo& table_info = table_infos.at(i); + const ObMigrateTableInfo &table_info = table_infos.at(i); if (OB_FAIL(generate_rebuild_tasks( ctx_->migrate_src_info_, part_migrate_ctx, table_info, *wait_rebuild_finish_task))) { LOG_WARN("failed to generate_rebuild_tasks", K(ret), K(i), K(table_info), K(part_migrate_ctx)); @@ -9847,7 +9869,7 @@ int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(ObPartitionMigrateCtx& pa return ret; } -int ObITableTaskGeneratorTask::generate_wait_migrate_finish_task(ObFakeTask*& wait_migrate_finish_task) +int ObITableTaskGeneratorTask::generate_wait_migrate_finish_task(ObFakeTask *&wait_migrate_finish_task) { int ret = OB_SUCCESS; wait_migrate_finish_task = NULL; @@ -9865,11 +9887,11 @@ int ObITableTaskGeneratorTask::generate_wait_migrate_finish_task(ObFakeTask*& wa return ret; } -int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(const ObMigrateSrcInfo& src_info, - ObPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo& table_info, ObFakeTask& wait_rebuild_finish_task) +int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(const ObMigrateSrcInfo &src_info, + ObPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo &table_info, ObFakeTask &wait_rebuild_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; @@ -9891,11 +9913,11 @@ int ObMigrateTaskGeneratorTask::generate_rebuild_tasks(const ObMigrateSrcInfo& s return ret; } -int ObMigrateTaskGeneratorTask::generate_migrate_tasks(const ObMigrateSrcInfo& src_info, - ObPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo& table_info, ObFakeTask& wait_migrate_finish_task) +int ObMigrateTaskGeneratorTask::generate_migrate_tasks(const ObMigrateSrcInfo &src_info, + ObPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo &table_info, ObFakeTask &wait_migrate_finish_task) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; @@ -9917,8 +9939,8 @@ int ObMigrateTaskGeneratorTask::generate_migrate_tasks(const ObMigrateSrcInfo& s return ret; } -int ObMigrateTaskGeneratorTask::generate_major_tasks(const ObMigrateSrcInfo& src_info, - ObPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo& table_info, share::ObITask*& parent_task) +int ObMigrateTaskGeneratorTask::generate_major_tasks(const ObMigrateSrcInfo &src_info, + ObPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo &table_info, share::ObITask *&parent_task) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -9930,8 +9952,8 @@ int ObMigrateTaskGeneratorTask::generate_major_tasks(const ObMigrateSrcInfo& src } else { // add major sstables for (int64_t sstable_idx = 0; OB_SUCC(ret) && sstable_idx < table_info.major_sstables_.count(); ++sstable_idx) { - const ObMigrateTableInfo::SSTableInfo& major_table_info = table_info.major_sstables_.at(sstable_idx); - ObFakeTask* wait_finish_task = NULL; + const ObMigrateTableInfo::SSTableInfo &major_table_info = table_info.major_sstables_.at(sstable_idx); + ObFakeTask *wait_finish_task = NULL; if (!ObITable::is_major_sstable(major_table_info.src_table_key_.table_type_)) { ret = OB_ERR_SYS; LOG_ERROR("table type not match major sstable", K(ret), K(major_table_info), K(table_info)); @@ -9953,8 +9975,8 @@ int ObMigrateTaskGeneratorTask::generate_major_tasks(const ObMigrateSrcInfo& src return ret; } -int ObMigrateTaskGeneratorTask::generate_minor_tasks(const ObMigrateSrcInfo& src_info, - ObPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo& table_info, share::ObITask*& parent_task) +int ObMigrateTaskGeneratorTask::generate_minor_tasks(const ObMigrateSrcInfo &src_info, + ObPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo &table_info, share::ObITask *&parent_task) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -9965,8 +9987,8 @@ int ObMigrateTaskGeneratorTask::generate_minor_tasks(const ObMigrateSrcInfo& src LOG_WARN("generate migrate minor task get invalid argument", K(ret), K(src_info), KP(parent_task)); } else { for (int64_t sstable_idx = 0; OB_SUCC(ret) && sstable_idx < table_info.minor_sstables_.count(); ++sstable_idx) { - const ObMigrateTableInfo::SSTableInfo& minor_sstable_info = table_info.minor_sstables_.at(sstable_idx); - ObFakeTask* wait_finish_task = NULL; + const ObMigrateTableInfo::SSTableInfo &minor_sstable_info = table_info.minor_sstables_.at(sstable_idx); + ObFakeTask *wait_finish_task = NULL; if (!ObITable::is_minor_sstable(minor_sstable_info.src_table_key_.table_type_) && !ObITable::is_memtable(minor_sstable_info.src_table_key_.table_type_)) { ret = OB_ERR_SYS; @@ -9995,9 +10017,9 @@ int ObMigrateTaskGeneratorTask::generate_minor_tasks(const ObMigrateSrcInfo& src // now only support rebuild from old server, // if want support more condition, modified it -int ObMigrateTaskGeneratorTask::generate_physic_minor_sstable_copy_task(const ObMigrateSrcInfo& src_info, - ObPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo::SSTableInfo& minor_sstable_info, - ObITask* parent_task, ObITask* child_task) +int ObMigrateTaskGeneratorTask::generate_physic_minor_sstable_copy_task(const ObMigrateSrcInfo &src_info, + ObPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo::SSTableInfo &minor_sstable_info, + ObITask *parent_task, ObITask *child_task) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -10022,15 +10044,15 @@ int ObMigrateTaskGeneratorTask::generate_physic_minor_sstable_copy_task(const Ob return ret; } -int ObITableTaskGeneratorTask::generate_logic_minor_sstable_copy_task(ObITask* parent_task, ObITask* child_task, - const ObMigrateSrcInfo& src_info, const ObMigrateTableInfo::SSTableInfo& minor_sstable_info, - ObPartitionMigrateCtx& part_migrate_ctx) +int ObITableTaskGeneratorTask::generate_logic_minor_sstable_copy_task(ObITask *parent_task, ObITask *child_task, + const ObMigrateSrcInfo &src_info, const ObMigrateTableInfo::SSTableInfo &minor_sstable_info, + ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; - ObMigrateCopyLogicTask* copy_task = NULL; - ObMigrateFinishLogicTask* finish_task = NULL; + ObMigrateCopyLogicTask *copy_task = NULL; + ObMigrateFinishLogicTask *finish_task = NULL; const int64_t task_idx = 0; - const ObITable::TableKey& table_key = minor_sstable_info.src_table_key_; + const ObITable::TableKey &table_key = minor_sstable_info.src_table_key_; if (OB_ISNULL(ctx_)) { ret = OB_NOT_INIT; @@ -10078,9 +10100,9 @@ int ObITableTaskGeneratorTask::generate_logic_minor_sstable_copy_task(ObITask* p return ret; } -int ObMigrateTaskGeneratorTask::generate_minor_sstable_copy_task(share::ObITask* parent_task, - share::ObITask* child_task, const ObMigrateSrcInfo& src_info, - const ObMigrateTableInfo::SSTableInfo& minor_sstable_info, ObPartitionMigrateCtx& part_migrate_ctx) +int ObMigrateTaskGeneratorTask::generate_minor_sstable_copy_task(share::ObITask *parent_task, + share::ObITask *child_task, const ObMigrateSrcInfo &src_info, + const ObMigrateTableInfo::SSTableInfo &minor_sstable_info, ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -10113,8 +10135,8 @@ int ObMigrateTaskGeneratorTask::generate_minor_sstable_copy_task(share::ObITask* return ret; } -int ObITableTaskGeneratorTask::build_logic_sstable_ctx(const ObMigrateSrcInfo& src_info, - const ObMigrateTableInfo::SSTableInfo& minor_sstable_info, ObMigrateLogicSSTableCtx& ctx) +int ObITableTaskGeneratorTask::build_logic_sstable_ctx(const ObMigrateSrcInfo &src_info, + const ObMigrateTableInfo::SSTableInfo &minor_sstable_info, ObMigrateLogicSSTableCtx &ctx) { int ret = OB_SUCCESS; obrpc::ObFetchLogicBaseMetaArg arg; @@ -10175,13 +10197,13 @@ int ObITableTaskGeneratorTask::build_logic_sstable_ctx(const ObMigrateSrcInfo& s return ret; } -int ObITableTaskGeneratorTask::generate_physical_sstable_copy_task(const ObMigrateSrcInfo& src_info, - ObIPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo::SSTableInfo& sstable_info, ObITask* parent_task, - ObITask* child_task) +int ObITableTaskGeneratorTask::generate_physical_sstable_copy_task(const ObMigrateSrcInfo &src_info, + ObIPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo::SSTableInfo &sstable_info, ObITask *parent_task, + ObITask *child_task) { int ret = OB_SUCCESS; - ObMigrateCopyPhysicalTask* copy_task = NULL; - ObMigrateFinishPhysicalTask* finish_task = NULL; + ObMigrateCopyPhysicalTask *copy_task = NULL; + ObMigrateFinishPhysicalTask *finish_task = NULL; const int64_t task_idx = 0; if (OB_ISNULL(ctx_)) { @@ -10233,9 +10255,9 @@ int ObITableTaskGeneratorTask::generate_physical_sstable_copy_task(const ObMigra return ret; } -int ObMigrateTaskGeneratorTask::generate_major_sstable_copy_task(const ObMigrateSrcInfo& src_info, - ObPartitionMigrateCtx& part_migrate_ctx, const ObMigrateTableInfo::SSTableInfo& major_sstable_info, - ObITask* parent_task, ObITask* child_task) +int ObMigrateTaskGeneratorTask::generate_major_sstable_copy_task(const ObMigrateSrcInfo &src_info, + ObPartitionMigrateCtx &part_migrate_ctx, const ObMigrateTableInfo::SSTableInfo &major_sstable_info, + ObITask *parent_task, ObITask *child_task) { int ret = OB_SUCCESS; @@ -10262,10 +10284,10 @@ int ObMigrateTaskGeneratorTask::generate_major_sstable_copy_task(const ObMigrate } int ObMigrateTaskGeneratorTask::generate_finish_migrate_task( - const ObIArray& last_task_array, share::ObITask*& last_task) + const ObIArray &last_task_array, share::ObITask *&last_task) { int ret = OB_SUCCESS; - ObMigrateFinishTask* finish_task = NULL; + ObMigrateFinishTask *finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -10278,7 +10300,7 @@ int ObMigrateTaskGeneratorTask::generate_finish_migrate_task( if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < last_task_array.count(); ++i) { - ObITask* last_task = last_task_array.at(i); + ObITask *last_task = last_task_array.at(i); if (NULL != last_task) { if (OB_FAIL(last_task->add_child(*finish_task))) { LOG_WARN("failed to add child of last task", K(ret)); @@ -10302,7 +10324,7 @@ int ObMigrateTaskGeneratorTask::generate_finish_migrate_task( } int ObITableTaskGeneratorTask::get_base_meta_reader( - const ObMigrateSrcInfo& src_info, const obrpc::ObFetchPhysicalBaseMetaArg& arg, ObIPhysicalBaseMetaReader*& reader) + const ObMigrateSrcInfo &src_info, const obrpc::ObFetchPhysicalBaseMetaArg &arg, ObIPhysicalBaseMetaReader *&reader) { int ret = OB_SUCCESS; const int64_t compatible = ctx_->replica_op_arg_.phy_restore_arg_.restore_info_.compatible_; @@ -10339,10 +10361,10 @@ int ObITableTaskGeneratorTask::get_base_meta_reader( } int ObITableTaskGeneratorTask::get_base_meta_restore_reader_v1( - const ObITable::TableKey& table_key, ObIPhysicalBaseMetaReader*& reader) + const ObITable::TableKey &table_key, ObIPhysicalBaseMetaReader *&reader) { int ret = OB_SUCCESS; - ObPhysicalBaseMetaRestoreReaderV1* tmp_reader = NULL; + ObPhysicalBaseMetaRestoreReaderV1 *tmp_reader = NULL; if (OB_ISNULL(ctx_)) { ret = OB_NOT_INIT; @@ -10379,10 +10401,10 @@ int ObITableTaskGeneratorTask::get_base_meta_restore_reader_v1( } int ObITableTaskGeneratorTask::get_base_meta_restore_reader_v2( - const ObITable::TableKey& table_key, ObIPhysicalBaseMetaReader*& reader) + const ObITable::TableKey &table_key, ObIPhysicalBaseMetaReader *&reader) { int ret = OB_SUCCESS; - ObPhysicalBaseMetaRestoreReaderV2* tmp_reader = NULL; + ObPhysicalBaseMetaRestoreReaderV2 *tmp_reader = NULL; if (OB_ISNULL(ctx_)) { ret = OB_NOT_INIT; @@ -10420,10 +10442,10 @@ int ObITableTaskGeneratorTask::get_base_meta_restore_reader_v2( // TODO() delete it later int ObITableTaskGeneratorTask::get_base_meta_backup_reader( - const ObITable::TableKey& table_key, ObIPhysicalBaseMetaReader*& reader) + const ObITable::TableKey &table_key, ObIPhysicalBaseMetaReader *&reader) { int ret = OB_SUCCESS; - ObPhysicalBaseMetaBackupReader* tmp_reader = NULL; + ObPhysicalBaseMetaBackupReader *tmp_reader = NULL; UNUSED(table_key); if (OB_ISNULL(ctx_)) { @@ -10453,7 +10475,7 @@ int ObITableTaskGeneratorTask::get_base_meta_backup_reader( } int ObITableTaskGeneratorTask::get_base_meta_ob_reader( - const ObMigrateSrcInfo& src_info, const obrpc::ObFetchPhysicalBaseMetaArg& arg, ObIPhysicalBaseMetaReader*& reader) + const ObMigrateSrcInfo &src_info, const obrpc::ObFetchPhysicalBaseMetaArg &arg, ObIPhysicalBaseMetaReader *&reader) { int ret = OB_SUCCESS; @@ -10476,10 +10498,10 @@ int ObITableTaskGeneratorTask::get_base_meta_ob_reader( } int ObITableTaskGeneratorTask::get_base_meta_rpc_reader( - const ObMigrateSrcInfo& src_info, const obrpc::ObFetchPhysicalBaseMetaArg& arg, ObIPhysicalBaseMetaReader*& reader) + const ObMigrateSrcInfo &src_info, const obrpc::ObFetchPhysicalBaseMetaArg &arg, ObIPhysicalBaseMetaReader *&reader) { int ret = OB_SUCCESS; - ObPhysicalBaseMetaReader* tmp_reader = NULL; + ObPhysicalBaseMetaReader *tmp_reader = NULL; if (OB_ISNULL(ctx_)) { ret = OB_NOT_INIT; @@ -10507,15 +10529,15 @@ int ObITableTaskGeneratorTask::get_base_meta_rpc_reader( return ret; } -int ObITableTaskGeneratorTask::build_physical_sstable_ctx(const ObMigrateSrcInfo& src_info, - const ObMigrateTableInfo::SSTableInfo& sstable_info, ObMigratePhysicalSSTableCtx& ctx) +int ObITableTaskGeneratorTask::build_physical_sstable_ctx(const ObMigrateSrcInfo &src_info, + const ObMigrateTableInfo::SSTableInfo &sstable_info, ObMigratePhysicalSSTableCtx &ctx) { int ret = OB_SUCCESS; obrpc::ObFetchPhysicalBaseMetaArg arg; common::ObArray macro_block_list; ObTablesHandle handle; ctx.reset(); - ObIPhysicalBaseMetaReader* reader = NULL; + ObIPhysicalBaseMetaReader *reader = NULL; arg.table_key_ = sstable_info.src_table_key_; ctx.sstable_info_ = sstable_info; ctx.src_info_ = src_info; @@ -10553,10 +10575,10 @@ int ObITableTaskGeneratorTask::build_physical_sstable_ctx(const ObMigrateSrcInfo } int ObITableTaskGeneratorTask::build_sub_physical_task( - ObMigratePhysicalSSTableCtx& ctx, common::ObIArray& macro_block_list) + ObMigratePhysicalSSTableCtx &ctx, common::ObIArray ¯o_block_list) { int ret = OB_SUCCESS; - void* buf = NULL; + void *buf = NULL; if (OB_ISNULL(ctx_)) { ret = OB_NOT_INIT; @@ -10579,7 +10601,7 @@ int ObITableTaskGeneratorTask::build_sub_physical_task( buf = NULL; } for (int64_t task_idx = 0; OB_SUCC(ret) && task_idx < ctx.task_count_; ++task_idx) { - ObMigratePhysicalSSTableCtx::SubTask& sub_task = ctx.tasks_[task_idx]; + ObMigratePhysicalSSTableCtx::SubTask &sub_task = ctx.tasks_[task_idx]; sub_task.pkey_ = ctx.sstable_info_.src_table_key_.pkey_; sub_task.block_count_ = std::min( max_macro_block_count_per_task, macro_block_list.count() - task_idx * max_macro_block_count_per_task); @@ -10598,8 +10620,8 @@ int ObITableTaskGeneratorTask::build_sub_physical_task( break; } - const blocksstable::ObSSTablePair& pair = macro_block_list.at(macro_idx); - ObMigrateMacroBlockInfo& info = ctx.tasks_[task_idx].block_info_[i]; + const blocksstable::ObSSTablePair &pair = macro_block_list.at(macro_idx); + ObMigrateMacroBlockInfo &info = ctx.tasks_[task_idx].block_info_[i]; info.pair_ = pair; info.need_copy_ = true; } @@ -10609,7 +10631,7 @@ int ObITableTaskGeneratorTask::build_sub_physical_task( } int ObITableTaskGeneratorTask::calc_macro_block_reuse( - const ObITable::TableKey& table_key, ObIArray& macro_block_list) + const ObITable::TableKey &table_key, ObIArray ¯o_block_list) { int ret = OB_SUCCESS; @@ -10626,7 +10648,7 @@ int ObITableTaskGeneratorTask::calc_macro_block_reuse( } int ObMigratePrepareTask::build_index_partition_info( - const ObReplicaOpArg& arg, ObIPGPartitionBaseDataMetaObReader* reader) + const ObReplicaOpArg &arg, ObIPGPartitionBaseDataMetaObReader *reader) { int ret = OB_SUCCESS; ObPartitionMigrateCtx part_migrate_ctx; @@ -10695,7 +10717,7 @@ int ObMigratePrepareTask::build_index_partition_info( } int ObMigratePrepareTask::build_table_partition_info( - const ObReplicaOpArg& arg, ObIPGPartitionBaseDataMetaObReader* reader) + const ObReplicaOpArg &arg, ObIPGPartitionBaseDataMetaObReader *reader) { int ret = OB_SUCCESS; ObPartitionMigrateCtx part_migrate_ctx; @@ -10746,11 +10768,11 @@ int ObMigratePrepareTask::build_table_partition_info( return ret; } -int ObMigratePrepareTask::remove_uncontinue_local_tables(const ObPartitionKey& pkey, const uint64_t table_id) +int ObMigratePrepareTask::remove_uncontinue_local_tables(const ObPartitionKey &pkey, const uint64_t table_id) { int ret = OB_SUCCESS; ObPGPartitionGuard guard; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -10771,7 +10793,7 @@ int ObMigrateTaskGeneratorTask::check_partition_integrity() { int ret = OB_SUCCESS; ObPGPartitionGuard guard; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; ObPartitionArray local_pkeys; if (!is_inited_) { ret = OB_NOT_INIT; @@ -10787,11 +10809,11 @@ int ObMigrateTaskGeneratorTask::check_partition_integrity() LOG_WARN("failed to get pg partition keys", K(ret), K(*ctx_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& pctx = ctx_->part_ctx_array_.at(i); - const ObPartitionKey& remote_pkey = pctx.copy_info_.meta_.pkey_; + ObPartitionMigrateCtx &pctx = ctx_->part_ctx_array_.at(i); + const ObPartitionKey &remote_pkey = pctx.copy_info_.meta_.pkey_; pctx.is_partition_exist_ = false; for (int64_t j = 0; OB_SUCC(ret) && j < local_pkeys.count() && !pctx.is_partition_exist_; ++j) { - const ObPartitionKey& local_pkey = local_pkeys.at(j); + const ObPartitionKey &local_pkey = local_pkeys.at(j); if (local_pkey == remote_pkey) { pctx.is_partition_exist_ = true; } @@ -10804,7 +10826,7 @@ int ObMigrateTaskGeneratorTask::check_partition_integrity() } int ObMigratePrepareTask::create_pg_partition( - const ObPGPartitionStoreMeta& meta, ObIPartitionGroup* partition, const bool in_slog_trans) + const ObPGPartitionStoreMeta &meta, ObIPartitionGroup *partition, const bool in_slog_trans) { int ret = OB_SUCCESS; @@ -10817,7 +10839,7 @@ int ObMigratePrepareTask::create_pg_partition( } else { ObTablesHandle sstables_handle; // empty obrpc::ObCreatePartitionArg arg; - const ObSavedStorageInfoV2& saved_storage_info = ctx_->pg_meta_.storage_info_; + const ObSavedStorageInfoV2 &saved_storage_info = ctx_->pg_meta_.storage_info_; arg.schema_version_ = saved_storage_info.get_data_info().get_schema_version(); arg.lease_start_ = meta.create_timestamp_; arg.restore_ = ctx_->is_restore_; @@ -10835,7 +10857,7 @@ int ObMigratePrepareTask::create_pg_partition( } int ObMigratePrepareTask::inner_get_partition_table_info_reader( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader) + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader) { int ret = OB_SUCCESS; UNUSED(src_info); @@ -10843,7 +10865,7 @@ int ObMigratePrepareTask::inner_get_partition_table_info_reader( COPY_GLOBAL_INDEX_OP == ctx_->replica_op_arg_.type_ || LINK_SHARE_MAJOR_OP == ctx_->replica_op_arg_.type_; - ObPGPartitionBaseDataMetaObReader* tmp_reader = NULL; + ObPGPartitionBaseDataMetaObReader *tmp_reader = NULL; obrpc::ObFetchPGPartitionInfoArg rpc_arg; rpc_arg.pg_key_ = ctx_->replica_op_arg_.key_; rpc_arg.snapshot_version_ = ctx_->pg_meta_.storage_info_.get_data_info().get_publish_version(); @@ -10874,12 +10896,12 @@ int ObMigratePrepareTask::inner_get_partition_table_info_reader( } int ObMigratePrepareTask::inner_get_partition_table_info_restore_reader_v1( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader) + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader) { int ret = OB_SUCCESS; UNUSED(src_info); - ObPGPartitionBaseDataMetaRestoreReaderV1* tmp_reader = NULL; - ObPartitionGroupMetaRestoreReaderV1* restore_meta_reader = NULL; + ObPGPartitionBaseDataMetaRestoreReaderV1 *tmp_reader = NULL; + ObPartitionGroupMetaRestoreReaderV1 *restore_meta_reader = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -10900,7 +10922,7 @@ int ObMigratePrepareTask::inner_get_partition_table_info_restore_reader_v1( ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "restore meta reader type is unexpected", K(ret), K(ctx_->restore_meta_reader_->get_type())); } else if (FALSE_IT(restore_meta_reader = - reinterpret_cast(ctx_->restore_meta_reader_))) { + reinterpret_cast(ctx_->restore_meta_reader_))) { } else if (OB_FAIL(tmp_reader->init(ctx_->pg_meta_.partitions_, restore_meta_reader))) { LOG_WARN("fail to init partition table info restore reader", K(ret)); } else { @@ -10918,12 +10940,12 @@ int ObMigratePrepareTask::inner_get_partition_table_info_restore_reader_v1( } int ObMigratePrepareTask::inner_get_partition_table_info_restore_reader_v2( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader) + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader) { int ret = OB_SUCCESS; UNUSED(src_info); - ObPGPartitionBaseDataMetaRestoreReaderV2* tmp_reader = NULL; - ObPartitionGroupMetaRestoreReaderV2* restore_meta_reader = NULL; + ObPGPartitionBaseDataMetaRestoreReaderV2 *tmp_reader = NULL; + ObPartitionGroupMetaRestoreReaderV2 *restore_meta_reader = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -10944,7 +10966,7 @@ int ObMigratePrepareTask::inner_get_partition_table_info_restore_reader_v2( ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "restore meta reader type is unexpected", K(ret), K(ctx_->restore_meta_reader_->get_type())); } else if (FALSE_IT(restore_meta_reader = - reinterpret_cast(ctx_->restore_meta_reader_))) { + reinterpret_cast(ctx_->restore_meta_reader_))) { } else if (OB_FAIL(tmp_reader->init(ctx_->pg_meta_.partitions_, restore_meta_reader))) { LOG_WARN("fail to init partition table info restore reader", K(ret)); } else { @@ -10963,11 +10985,11 @@ int ObMigratePrepareTask::inner_get_partition_table_info_restore_reader_v2( // TODO(muwei.ym) delete it later int ObMigratePrepareTask::inner_get_partition_table_info_backup_reader( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader) + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader) { int ret = OB_SUCCESS; UNUSED(src_info); - ObPGPartitionBaseDataMetaBackupReader* tmp_reader = NULL; + ObPGPartitionBaseDataMetaBackupReader *tmp_reader = NULL; if (OB_ISNULL(cp_fty_)) { ret = OB_ERR_SYS; @@ -10990,7 +11012,7 @@ int ObMigratePrepareTask::inner_get_partition_table_info_backup_reader( } int ObMigratePrepareTask::get_partition_table_info_reader( - const ObMigrateSrcInfo& src_info, ObIPGPartitionBaseDataMetaObReader*& reader) + const ObMigrateSrcInfo &src_info, ObIPGPartitionBaseDataMetaObReader *&reader) { int ret = OB_SUCCESS; reader = NULL; @@ -11035,7 +11057,7 @@ int ObMigratePrepareTask::get_partition_table_info_reader( int ObMigratePrepareTask::check_backup_data_continues() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; clog::ObPGLogArchiveStatus pg_log_archive_status; ObLogArchiveBackupInfo archive_backup_info; const int64_t start_ts = ObTimeUtility::current_time(); @@ -11168,10 +11190,10 @@ bool ObMigrateLogicSSTableCtx::is_valid() return valid; } -int ObMigrateLogicSSTableCtx::build_sub_task(const common::ObIArray& end_key_list) +int ObMigrateLogicSSTableCtx::build_sub_task(const common::ObIArray &end_key_list) { int ret = OB_SUCCESS; - void* buf = NULL; + void *buf = NULL; if (NULL != tasks_) { ret = OB_INIT_TWICE; @@ -11201,7 +11223,7 @@ int ObMigrateLogicSSTableCtx::build_sub_task(const common::ObIArrayctx_; + ObMigrateCtx *ctx = part_migrate_ctx_->ctx_; bool has_lob_column = false; const uint64_t table_id = sstable_ctx_.table_key_.table_id_; @@ -11464,7 +11486,7 @@ int ObMigrateFinishLogicTask::process() ObPGCreateSSTableParam param; param.with_table_param_ = &create_sstable_param; for (int64_t task_idx = 0; OB_SUCC(ret) && task_idx < sstable_ctx_.task_count_; ++task_idx) { - ObMigrateLogicSSTableCtx::SubLogicTask& sub_task = sstable_ctx_.tasks_[task_idx]; + ObMigrateLogicSSTableCtx::SubLogicTask &sub_task = sstable_ctx_.tasks_[task_idx]; if (!sub_task.block_write_ctx_.file_handle_.is_valid() && OB_FAIL(sub_task.block_write_ctx_.file_handle_.assign( part_migrate_ctx_->ctx_->partition_guard_.get_partition_group()->get_storage_file_handle()))) { @@ -11484,7 +11506,7 @@ int ObMigrateFinishLogicTask::process() } if (OB_SUCC(ret)) { - ObIPartitionGroup* pg = nullptr; + ObIPartitionGroup *pg = nullptr; if (OB_ISNULL(pg = part_migrate_ctx_->ctx_->partition_guard_.get_partition_group())) { ret = OB_ERR_SYS; LOG_WARN("partition must not null", K(ret)); @@ -11519,7 +11541,7 @@ ObMigratePhysicalSSTableCtx::SubTask::~SubTask() { int ret = OB_SUCCESS; storage::ObIPartitionGroupGuard pg_guard; - blocksstable::ObStorageFile* pg_file = NULL; + blocksstable::ObStorageFile *pg_file = NULL; if (OB_FAIL(ObFileSystemUtil::get_pg_file_with_guard(pkey_, pg_guard, pg_file))) { LOG_ERROR("meta must not null", K(ret), K_(pkey)); } else { @@ -11589,7 +11611,7 @@ void ObMigratePhysicalSSTableCtx::reset() { if (NULL != tasks_ && task_count_ > 0) { for (int64_t task_idx = 0; task_idx < task_count_; ++task_idx) { - ObMigratePhysicalSSTableCtx::SubTask& task = tasks_[task_idx]; + ObMigratePhysicalSSTableCtx::SubTask &task = tasks_[task_idx]; task.~SubTask(); } } @@ -11603,7 +11625,7 @@ void ObMigratePhysicalSSTableCtx::reset() restore_version_ = 0; } -int ObMigratePhysicalSSTableCtx::get_dest_table_key(ObITable::TableKey& dest_table_key) +int ObMigratePhysicalSSTableCtx::get_dest_table_key(ObITable::TableKey &dest_table_key) { int ret = OB_SUCCESS; @@ -11632,7 +11654,7 @@ ObMigrateCopyPhysicalTask::ObMigrateCopyPhysicalTask() ObMigrateCopyPhysicalTask::~ObMigrateCopyPhysicalTask() {} -int ObMigrateCopyPhysicalTask::init(const int64_t task_idx, ObMigratePhysicalSSTableCtx& sstable_ctx, ObMigrateCtx& ctx) +int ObMigrateCopyPhysicalTask::init(const int64_t task_idx, ObMigratePhysicalSSTableCtx &sstable_ctx, ObMigrateCtx &ctx) { int ret = OB_SUCCESS; @@ -11653,10 +11675,10 @@ int ObMigrateCopyPhysicalTask::init(const int64_t task_idx, ObMigratePhysicalSST return ret; } -int ObMigrateCopyPhysicalTask::get_macro_block_reader(obrpc::ObPartitionServiceRpcProxy* srv_rpc_proxy, - common::ObInOutBandwidthThrottle* bandwidth_throttle, const ObMigrateSrcInfo& src_info, - common::ObIArray& list, ObITable::TableKey& table_key, - const ObRestoreInfo* restore_info, ObIPartitionMacroBlockReader*& reader) +int ObMigrateCopyPhysicalTask::get_macro_block_reader(obrpc::ObPartitionServiceRpcProxy *srv_rpc_proxy, + common::ObInOutBandwidthThrottle *bandwidth_throttle, const ObMigrateSrcInfo &src_info, + common::ObIArray &list, ObITable::TableKey &table_key, + const ObRestoreInfo *restore_info, ObIPartitionMacroBlockReader *&reader) { int ret = OB_SUCCESS; UNUSED(restore_info); @@ -11686,12 +11708,12 @@ int ObMigrateCopyPhysicalTask::get_macro_block_reader(obrpc::ObPartitionServiceR return ret; } -int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v1(common::ObInOutBandwidthThrottle& bandwidth_throttle, - common::ObIArray& list, const share::ObPhysicalRestoreArg& restore_info, - const ObITable::TableKey& table_key, ObIPartitionMacroBlockReader*& reader) +int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v1(common::ObInOutBandwidthThrottle &bandwidth_throttle, + common::ObIArray &list, const share::ObPhysicalRestoreArg &restore_info, + const ObITable::TableKey &table_key, ObIPartitionMacroBlockReader *&reader) { int ret = OB_SUCCESS; - ObPartitionMacroBlockRestoreReaderV1* tmp_reader = NULL; + ObPartitionMacroBlockRestoreReaderV1 *tmp_reader = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -11705,7 +11727,7 @@ int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v1(common::ObInOut } else if (OB_FAIL(tmp_reader->init(bandwidth_throttle, list, restore_info, - *static_cast(ctx_->macro_indexs_), + *static_cast(ctx_->macro_indexs_), table_key))) { STORAGE_LOG(WARN, "failed to init restore reader", K(ret), K(table_key)); } else { @@ -11728,13 +11750,13 @@ int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v1(common::ObInOut return ret; } -int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v2(common::ObInOutBandwidthThrottle& bandwidth_throttle, - common::ObIArray& list, const share::ObPhysicalRestoreArg& restore_info, - const ObITable::TableKey& table_key, ObIPartitionMacroBlockReader*& reader) +int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v2(common::ObInOutBandwidthThrottle &bandwidth_throttle, + common::ObIArray &list, const share::ObPhysicalRestoreArg &restore_info, + const ObITable::TableKey &table_key, ObIPartitionMacroBlockReader *&reader) { int ret = OB_SUCCESS; - ObPartitionMacroBlockRestoreReaderV2* tmp_reader = NULL; - ObPhyRestoreMacroIndexStoreV2* macro_index = NULL; + ObPartitionMacroBlockRestoreReaderV2 *tmp_reader = NULL; + ObPhyRestoreMacroIndexStoreV2 *macro_index = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -11748,7 +11770,7 @@ int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v2(common::ObInOut } else if (ObIPhyRestoreMacroIndexStore::PHY_RESTORE_MACRO_INDEX_STORE_V2 != ctx_->macro_indexs_->get_type()) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "macro index type is unexpected", K(ret), "type", ctx_->macro_indexs_->get_type()); - } else if (FALSE_IT(macro_index = reinterpret_cast(ctx_->macro_indexs_))) { + } else if (FALSE_IT(macro_index = reinterpret_cast(ctx_->macro_indexs_))) { } else if (OB_FAIL(tmp_reader->init(bandwidth_throttle, list, restore_info, *macro_index, table_key))) { STORAGE_LOG(WARN, "failed to init restore reader", K(ret), K(table_key)); } else { @@ -11771,13 +11793,13 @@ int ObMigrateCopyPhysicalTask::get_macro_block_restore_reader_v2(common::ObInOut return ret; } -int ObMigrateCopyPhysicalTask::get_macro_block_ob_reader(obrpc::ObPartitionServiceRpcProxy& srv_rpc_proxy, - common::ObInOutBandwidthThrottle& bandwidth_throttle, const ObMigrateSrcInfo& src_info, - ObITable::TableKey& table_key, common::ObIArray& list, - ObIPartitionMacroBlockReader*& reader) +int ObMigrateCopyPhysicalTask::get_macro_block_ob_reader(obrpc::ObPartitionServiceRpcProxy &srv_rpc_proxy, + common::ObInOutBandwidthThrottle &bandwidth_throttle, const ObMigrateSrcInfo &src_info, + ObITable::TableKey &table_key, common::ObIArray &list, + ObIPartitionMacroBlockReader *&reader) { int ret = OB_SUCCESS; - ObPartitionMacroBlockObReader* tmp_reader = NULL; + ObPartitionMacroBlockObReader *tmp_reader = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -11813,11 +11835,11 @@ int ObMigrateCopyPhysicalTask::get_macro_block_ob_reader(obrpc::ObPartitionServi return ret; } -int ObMigrateCopyPhysicalTask::generate_next_task(ObITask*& next_task) +int ObMigrateCopyPhysicalTask::generate_next_task(ObITask *&next_task) { int ret = OB_SUCCESS; const int64_t next_task_idx = task_idx_ + 1; - ObMigrateCopyPhysicalTask* tmp_next_task = NULL; + ObMigrateCopyPhysicalTask *tmp_next_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -11846,7 +11868,7 @@ int ObMigrateCopyPhysicalTask::process() int64_t copy_count = 0; int64_t reuse_count = 0; storage::ObIPartitionGroupGuard pg_guard; - blocksstable::ObStorageFile* pg_file = NULL; + blocksstable::ObStorageFile *pg_file = NULL; DEBUG_SYNC(BEFORE_MIGRATE_COPY_BASE_DATA); if (NULL != sstable_ctx_) { @@ -11977,12 +11999,12 @@ int ObMigrateCopyPhysicalTask::process() } int ObMigrateCopyPhysicalTask::fetch_major_block_with_retry( - ObIArray& list, ObMacroBlocksWriteCtx& copied_ctx) + ObIArray &list, ObMacroBlocksWriteCtx &copied_ctx) { int ret = OB_SUCCESS; int64_t retry_times = 0; - obrpc::ObPartitionServiceRpcProxy* srv_rpc_proxy = MIGRATOR.get_svr_rpc_proxy(); - common::ObInOutBandwidthThrottle* bandwidth_throttle = MIGRATOR.get_bandwidth_throttle(); + obrpc::ObPartitionServiceRpcProxy *srv_rpc_proxy = MIGRATOR.get_svr_rpc_proxy(); + common::ObInOutBandwidthThrottle *bandwidth_throttle = MIGRATOR.get_bandwidth_throttle(); if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate copy physical task do not init", K(ret)); @@ -12017,7 +12039,7 @@ int ObMigrateCopyPhysicalTask::fetch_major_block_with_retry( } int ObMigrateCopyPhysicalTask::alloc_migrate_writer( - ObIPartitionMacroBlockReader* reader, ObIMigrateMacroBlockWriter*& writer) + ObIPartitionMacroBlockReader *reader, ObIMigrateMacroBlockWriter *&writer) { int ret = OB_SUCCESS; writer = nullptr; @@ -12031,14 +12053,14 @@ int ObMigrateCopyPhysicalTask::alloc_migrate_writer( ret = OB_ERR_SYS; LOG_WARN("invalid inner state", K(ret), KP(sstable_ctx_), KP(ctx_)); } else { - void* buf = nullptr; + void *buf = nullptr; const uint64_t tenant_id = sstable_ctx_->sstable_info_.src_table_key_.get_tenant_id(); - ObStorageFile* dest_pg_file = ctx_->get_partition()->get_pg_storage().get_storage_file(); + ObStorageFile *dest_pg_file = ctx_->get_partition()->get_pg_storage().get_storage_file(); if (OB_ISNULL(buf = ob_malloc(sizeof(ObMigrateMacroBlockWriter), ObModIds::OB_PARTITION_MIGRATE))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("fail to alloc migrate macro block writer", K(ret)); } else { - ObMigrateMacroBlockWriter* tmp_writer = new (buf) ObMigrateMacroBlockWriter; + ObMigrateMacroBlockWriter *tmp_writer = new (buf) ObMigrateMacroBlockWriter; if (OB_FAIL(tmp_writer->init(reader, tenant_id, dest_pg_file))) { LOG_WARN("failed to init writer", K(ret), KP(reader), K(tenant_id), KP(dest_pg_file)); tmp_writer->~ObMigrateMacroBlockWriter(); @@ -12053,7 +12075,7 @@ int ObMigrateCopyPhysicalTask::alloc_migrate_writer( return ret; } -void ObMigrateCopyPhysicalTask::free_migrate_writer(ObIMigrateMacroBlockWriter*& writer) +void ObMigrateCopyPhysicalTask::free_migrate_writer(ObIMigrateMacroBlockWriter *&writer) { if (NULL != writer) { writer->~ObIMigrateMacroBlockWriter(); @@ -12063,13 +12085,13 @@ void ObMigrateCopyPhysicalTask::free_migrate_writer(ObIMigrateMacroBlockWriter*& } int ObMigrateCopyPhysicalTask::fetch_major_block( - ObIArray& list, ObMacroBlocksWriteCtx& copied_ctx) + ObIArray &list, ObMacroBlocksWriteCtx &copied_ctx) { int ret = OB_SUCCESS; - obrpc::ObPartitionServiceRpcProxy* srv_rpc_proxy = MIGRATOR.get_svr_rpc_proxy(); - common::ObInOutBandwidthThrottle* bandwidth_throttle = MIGRATOR.get_bandwidth_throttle(); - ObIMigrateMacroBlockWriter* writer = NULL; - ObIPartitionMacroBlockReader* reader = NULL; + obrpc::ObPartitionServiceRpcProxy *srv_rpc_proxy = MIGRATOR.get_svr_rpc_proxy(); + common::ObInOutBandwidthThrottle *bandwidth_throttle = MIGRATOR.get_bandwidth_throttle(); + ObIMigrateMacroBlockWriter *writer = NULL; + ObIPartitionMacroBlockReader *reader = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate copy physical task do not init", K(ret)); @@ -12120,7 +12142,7 @@ int ObMigrateCopyPhysicalTask::calc_migrate_data_statics(const int64_t copy_coun ret = OB_NOT_INIT; LOG_WARN("migrate copy physic task do not init", K(ret)); } else { - const ObITable::TableKey& src_table_key = sstable_ctx_->sstable_info_.src_table_key_; + const ObITable::TableKey &src_table_key = sstable_ctx_->sstable_info_.src_table_key_; ctx_->action_ = src_table_key.is_major_sstable() ? ObMigrateCtx::COPY_MAJOR : ObMigrateCtx::COPY_MINOR; ATOMIC_AAF(&ctx_->data_statics_.ready_macro_block_, sub_task_->block_count_); if (src_table_key.is_major_sstable()) { @@ -12146,7 +12168,7 @@ ObMigrateFinishPhysicalTask::ObMigrateFinishPhysicalTask() ObMigrateFinishPhysicalTask::~ObMigrateFinishPhysicalTask() {} -int ObMigrateFinishPhysicalTask::init(ObIPartitionMigrateCtx& part_migrate_ctx) +int ObMigrateFinishPhysicalTask::init(ObIPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; @@ -12166,10 +12188,10 @@ int ObMigrateFinishPhysicalTask::init(ObIPartitionMigrateCtx& part_migrate_ctx) int ObMigrateFinishPhysicalTask::process() { int ret = OB_SUCCESS; - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; ObTableHandle handle; - ObIPartitionGroup* partition = NULL; - ObMigrateCtx* ctx = part_migrate_ctx_->ctx_; + ObIPartitionGroup *partition = NULL; + ObMigrateCtx *ctx = part_migrate_ctx_->ctx_; ObITable::TableKey dest_table_key; blocksstable::ObMacroBlocksWriteCtx write_ctx, lob_write_ctx; // TODO(): fix it for ofs ObPGCreateSSTableParam param; @@ -12204,10 +12226,10 @@ int ObMigrateFinishPhysicalTask::process() } tg.click("init"); for (int64_t task_idx = 0; OB_SUCC(ret) && task_idx < sstable_ctx_.task_count_; ++task_idx) { - ObMigratePhysicalSSTableCtx::SubTask& sub_task = sstable_ctx_.tasks_[task_idx]; + ObMigratePhysicalSSTableCtx::SubTask &sub_task = sstable_ctx_.tasks_[task_idx]; for (int64_t i = 0; OB_SUCC(ret) && i < sub_task.block_count_; ++i) { const MacroBlockId macro_block_id = sub_task.block_info_[i].macro_block_id_; - const ObFullMacroBlockMeta& macro_meta = sub_task.block_info_[i].full_meta_; + const ObFullMacroBlockMeta ¯o_meta = sub_task.block_info_[i].full_meta_; if (sstable_ctx_.meta_.lob_macro_block_count_ > 0) { if (OB_UNLIKELY(!macro_meta.is_valid())) { ret = OB_ERR_SYS; @@ -12289,11 +12311,11 @@ int ObMigrateFinishPhysicalTask::process() return ret; } -int ObMigrateFinishPhysicalTask::acquire_sstable(const ObITable::TableKey& dest_table_key, ObTableHandle& handle) +int ObMigrateFinishPhysicalTask::acquire_sstable(const ObITable::TableKey &dest_table_key, ObTableHandle &handle) { int ret = OB_SUCCESS; handle.reset(); - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("finish physical task do not init", K(ret)); @@ -12316,7 +12338,7 @@ ObMigrateFinishTask::ObMigrateFinishTask() : ObITask(TASK_TYPE_MIGRATE_FINISH), ObMigrateFinishTask::~ObMigrateFinishTask() {} -int ObMigrateFinishTask::init(ObMigrateCtx& ctx) +int ObMigrateFinishTask::init(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; @@ -12335,8 +12357,8 @@ int ObMigrateFinishTask::process() int ret = OB_SUCCESS; bool is_change_replica_with_data = true; bool is_add_replica_during_restore = false; - ObIPartitionGroup* partition = NULL; - ObPGStorage* pg_storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGStorage *pg_storage = NULL; DEBUG_SYNC(BEFORE_FINISH_MIGRATE_TASK); if (NULL != ctx_) { @@ -12369,12 +12391,11 @@ int ObMigrateFinishTask::process() LOG_WARN("failed to merge trans table", K(ret)); } else if (OB_FAIL(create_pg_partition_if_need())) { LOG_WARN("Failed to create pg partition if need", K(ret)); - } else if (ADD_REPLICA_OP == ctx_->replica_op_arg_.type_ - && ((ctx_->is_restore_ > REPLICA_NOT_RESTORE && ctx_->is_restore_ < REPLICA_RESTORE_MAX) - || REPLICA_RESTORE_STANDBY == ctx_->is_restore_)) { - is_add_replica_during_restore = true; - LOG_INFO("no need check read add replica during restore", K(ctx_->is_restore_), - "pkey", ctx_->replica_op_arg_.key_); + } else if (ADD_REPLICA_OP == ctx_->replica_op_arg_.type_ && + ((ctx_->is_restore_ > REPLICA_NOT_RESTORE && ctx_->is_restore_ < REPLICA_RESTORE_MAX) || + REPLICA_RESTORE_STANDBY == ctx_->is_restore_)) { + is_add_replica_during_restore = true; + LOG_INFO("no need check read add replica during restore", K(ctx_->is_restore_), "pkey", ctx_->replica_op_arg_.key_); } else { if (ObReplicaTypeCheck::is_replica_with_ssstore(ctx_->replica_op_arg_.dst_.get_replica_type())) { if (OB_FAIL(check_pg_partition_ready_for_read())) { @@ -12483,21 +12504,21 @@ int ObMigrateFinishTask::process() return ret; } -int ObMigrateFinishTask::lock_pg_owner(common::ObMySQLTransaction& trans, ObIPartitionGroup& pg, - const common::ObAddr& data_src_addr, const int64_t epoch_number) +int ObMigrateFinishTask::lock_pg_owner(common::ObMySQLTransaction &trans, ObIPartitionGroup &pg, + const common::ObAddr &data_src_addr, const int64_t epoch_number) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!pg.is_valid() || !data_src_addr.is_valid() || OB_INVALID_VERSION == epoch_number)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(pg), K(data_src_addr), K(epoch_number)); } else { - const ObPGKey& pg_key = pg.get_partition_key(); + const ObPGKey &pg_key = pg.get_partition_key(); ObSqlString sql; SMART_VAR(ObISQLClient::ReadResult, result) { - sqlclient::ObMySQLResult* mysql_result = nullptr; + sqlclient::ObMySQLResult *mysql_result = nullptr; char ip_str[32] = {0}; - const char* sql_template = " SELECT is_owner, epoch_num " + const char *sql_template = " SELECT is_owner, epoch_num " " FROM __all_tenant_meta_table " " WHERE tenant_id=%lu AND table_id=%lu AND partition_id=%ld " " AND svr_ip='%s' AND svr_port=%d AND epoch_num=%ld and is_owner=%d" @@ -12550,7 +12571,7 @@ int ObMigrateFinishTask::enable_replay() int ObMigrateFinishTask::create_pg_partition_if_need() { int ret = OB_SUCCESS; - ObIPartitionGroup* pg = NULL; + ObIPartitionGroup *pg = NULL; const bool in_slog_trans = false; const int64_t max_kept_major_version_number = 0; @@ -12566,7 +12587,7 @@ int ObMigrateFinishTask::create_pg_partition_if_need() // no need to replace store map, just skip it. LOG_INFO("replica op tyoe is no need batch replace sstable, skip it"); } else { - const ObSavedStorageInfoV2& saved_storage_info = ctx_->pg_meta_.storage_info_; + const ObSavedStorageInfoV2 &saved_storage_info = ctx_->pg_meta_.storage_info_; if (OB_FAIL(pg->get_pg_storage().batch_replace_store_map(ctx_->part_ctx_array_, saved_storage_info.get_data_info().get_schema_version(), ctx_->is_restore_, @@ -12594,9 +12615,9 @@ int ObMigrateFinishTask::check_pg_partition_ready_for_read() int ObMigrateFinishTask::check_partition_ready_for_read_in_remote() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGPartition* pg_partition = NULL; - ObIPartitionStorage* storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGPartition *pg_partition = NULL; + ObIPartitionStorage *storage = NULL; ObPartitionArray pkeys; if (!is_inited_) { @@ -12614,8 +12635,8 @@ int ObMigrateFinishTask::check_partition_ready_for_read_in_remote() for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { ObPGPartitionGuard guard; storage = NULL; - const ObMigratePartitionInfo& copy_info = ctx_->part_ctx_array_.at(i).copy_info_; - const ObPartitionKey& pkey = copy_info.meta_.pkey_; + const ObMigratePartitionInfo ©_info = ctx_->part_ctx_array_.at(i).copy_info_; + const ObPartitionKey &pkey = copy_info.meta_.pkey_; if (pkey.is_trans_table()) { continue; } else if (OB_FAIL(partition->get_pg_partition(pkey, guard))) { @@ -12635,7 +12656,7 @@ int ObMigrateFinishTask::check_partition_ready_for_read_in_remote() } int ObMigrateFinishTask::check_partition_ready_for_read( - const ObMigratePartitionInfo& copy_info, ObIPartitionStorage* storage) + const ObMigratePartitionInfo ©_info, ObIPartitionStorage *storage) { int ret = OB_SUCCESS; ObTablesHandle handle; @@ -12648,16 +12669,16 @@ int ObMigrateFinishTask::check_partition_ready_for_read( ret = OB_INVALID_ARGUMENT; LOG_WARN("check partition ready for read get invalid argument", K(ret), K(copy_info), KP(storage)); } else { - ObPartitionStore& store = static_cast(storage)->get_partition_store(); + ObPartitionStore &store = static_cast(storage)->get_partition_store(); for (int64_t i = 0; OB_SUCC(ret) && i < copy_info.table_infos_.count(); ++i) { - const ObMigrateTableInfo& info = copy_info.table_infos_[i]; + const ObMigrateTableInfo &info = copy_info.table_infos_[i]; handle.reset(); if (OB_FAIL(store.get_effective_tables(info.table_id_, handle, is_ready_for_read))) { LOG_WARN("failed to check ready for read", K(ret), K(info.table_id_)); } else if (info.ready_for_read_ && !is_ready_for_read) { const uint64_t tenant_id = extract_tenant_id(info.table_id_); share::schema::ObSchemaGetterGuard schema_guard; - share::schema::ObMultiVersionSchemaService& schema_service = + share::schema::ObMultiVersionSchemaService &schema_service = share::schema::ObMultiVersionSchemaService::get_instance(); bool is_exist = true; if (OB_FAIL(schema_service.get_tenant_schema_guard(tenant_id, schema_guard))) { @@ -12680,9 +12701,9 @@ int ObMigrateFinishTask::check_partition_ready_for_read( int ObMigrateFinishTask::check_partition_ready_for_read_out_remote() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGPartition* pg_partition = NULL; - ObIPartitionStorage* storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGPartition *pg_partition = NULL; + ObIPartitionStorage *storage = NULL; ObTablesHandle handle; ObPartitionArray pkeys; ObHashSet remote_pkeys; @@ -12708,15 +12729,15 @@ int ObMigrateFinishTask::check_partition_ready_for_read_out_remote() LOG_WARN("failed to create remote pkeys set", K(ret), K(ctx_->part_ctx_array_.count())); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - const ObMigratePartitionInfo& copy_info = ctx_->part_ctx_array_.at(i).copy_info_; - const ObPartitionKey& pkey = copy_info.meta_.pkey_; + const ObMigratePartitionInfo ©_info = ctx_->part_ctx_array_.at(i).copy_info_; + const ObPartitionKey &pkey = copy_info.meta_.pkey_; if (OB_FAIL(remote_pkeys.set_refactored(pkey))) { LOG_WARN("failed to set pkey into remote pkey set", K(ret), K(pkey)); } } for (int64_t i = 0; OB_SUCC(ret) && i < pkeys.count(); ++i) { - const ObPartitionKey& pkey = pkeys.at(i); + const ObPartitionKey &pkey = pkeys.at(i); hash_ret = remote_pkeys.exist_refactored(pkey); if (OB_HASH_EXIST == hash_ret) { // do nothing @@ -12746,7 +12767,7 @@ int ObMigrateFinishTask::check_partition_ready_for_read_out_remote() return ret; } -int ObMigrateFinishTask::check_partition_ready_for_read(ObIPartitionStorage* storage) +int ObMigrateFinishTask::check_partition_ready_for_read(ObIPartitionStorage *storage) { int ret = OB_SUCCESS; ObTablesHandle handle; @@ -12760,7 +12781,7 @@ int ObMigrateFinishTask::check_partition_ready_for_read(ObIPartitionStorage* sto ret = OB_INVALID_ARGUMENT; LOG_WARN("check partition ready for read get invalid argument", K(ret), KP(storage)); } else { - ObPartitionStore& store = static_cast(storage)->get_partition_store(); + ObPartitionStore &store = static_cast(storage)->get_partition_store(); if (OB_FAIL(store.get_all_table_ids(table_ids))) { LOG_WARN("failed to get all table ids", K(ret), K(storage->get_partition_key())); } else { @@ -12786,9 +12807,9 @@ int ObMigrateFinishTask::check_partition_ready_for_read(ObIPartitionStorage* sto int ObMigrateFinishTask::check_pg_available_index_all_exist() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGPartition* pg_partition = NULL; - ObPartitionStorage* storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGPartition *pg_partition = NULL; + ObPartitionStorage *storage = NULL; ObPartitionArray pkeys; if (!is_inited_) { ret = OB_NOT_INIT; @@ -12802,13 +12823,13 @@ int ObMigrateFinishTask::check_pg_available_index_all_exist() for (int64_t i = 0; OB_SUCC(ret) && i < pkeys.count(); ++i) { ObPGPartitionGuard guard; storage = NULL; - const ObPartitionKey& pkey = pkeys.at(i); + const ObPartitionKey &pkey = pkeys.at(i); if (OB_FAIL(partition->get_pg_partition(pkey, guard))) { LOG_ERROR("failed to get pg partition", K(ret), K(pkey)); } else if (OB_ISNULL(pg_partition = guard.get_pg_partition())) { ret = OB_ERR_SYS; LOG_WARN("pg partition should not be NULL", K(ret), KP(pg_partition)); - } else if (OB_ISNULL(storage = static_cast(pg_partition->get_storage()))) { + } else if (OB_ISNULL(storage = static_cast(pg_partition->get_storage()))) { ret = OB_ERR_SYS; LOG_WARN("fail to get partition storage", K(ret), KP(storage)); } else if (OB_FAIL(check_available_index_all_exist(pkey, storage))) { @@ -12819,7 +12840,7 @@ int ObMigrateFinishTask::check_pg_available_index_all_exist() return ret; } -int ObMigrateFinishTask::check_available_index_all_exist(const ObPartitionKey& pkey, ObPartitionStorage* storage) +int ObMigrateFinishTask::check_available_index_all_exist(const ObPartitionKey &pkey, ObPartitionStorage *storage) { int ret = OB_SUCCESS; ObSchemaGetterGuard schema_guard; @@ -12857,7 +12878,7 @@ int ObMigrateFinishTask::update_pg_partition_report_status() { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; const int64_t version = ctx_->pg_meta_.report_status_.data_version_ > 0 ? ctx_->pg_meta_.report_status_.data_version_ : ObPartitionScheduler::get_instance().get_frozen_version(); @@ -12879,7 +12900,7 @@ int ObMigrateFinishTask::update_pg_partition_report_status() return ret; } -int64_t ObMigratePhysicalSSTableCtx::SubTask::to_string(char* buf, const int64_t buf_len) const +int64_t ObMigratePhysicalSSTableCtx::SubTask::to_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; if (OB_ISNULL(buf) || buf_len <= 0) { @@ -12890,7 +12911,7 @@ int64_t ObMigratePhysicalSSTableCtx::SubTask::to_string(char* buf, const int64_t J_COMMA(); J_ARRAY_START(); for (int64_t i = 0; i < block_count_; ++i) { - ObMigrateMacroBlockInfo& info = block_info_[i]; + ObMigrateMacroBlockInfo &info = block_info_[i]; J_OBJ_START(); J_KV(K(i), K(info)); J_OBJ_END(); @@ -12902,7 +12923,7 @@ int64_t ObMigratePhysicalSSTableCtx::SubTask::to_string(char* buf, const int64_t return pos; } -int64_t ObMigratePhysicalSSTableCtx::to_string(char* buf, const int64_t buf_len) const +int64_t ObMigratePhysicalSSTableCtx::to_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; if (OB_ISNULL(buf) || buf_len <= 0) { @@ -12913,7 +12934,7 @@ int64_t ObMigratePhysicalSSTableCtx::to_string(char* buf, const int64_t buf_len) J_COMMA(); J_ARRAY_START(); for (int64_t i = 0; i < task_count_; ++i) { - SubTask& task = tasks_[i]; + SubTask &task = tasks_[i]; J_OBJ_START(); J_KV(K(i), K(task)); J_OBJ_END(); @@ -13016,17 +13037,17 @@ int ObMigrateFinishTask::enable_replay_for_rebuild() int ObMigrateFinishTask::update_split_state() { int ret = OB_SUCCESS; - ObPartitionGroupMeta& meta = ctx_->pg_meta_; - ObBaseStorageInfo& clog_info = meta.storage_info_.get_clog_info(); - ObDataStorageInfo& data_info = meta.storage_info_.get_data_info(); - const ObPartitionSplitInfo& split_info = meta.split_info_; + ObPartitionGroupMeta &meta = ctx_->pg_meta_; + ObBaseStorageInfo &clog_info = meta.storage_info_.get_clog_info(); + ObDataStorageInfo &data_info = meta.storage_info_.get_data_info(); + const ObPartitionSplitInfo &split_info = meta.split_info_; int64_t split_state = meta.saved_split_state_; // 221,222 may set spit_status = -1, and it has bug during upgrade to 224. Now set split_status = 1. if (-1 == split_state) { split_state = 1; LOG_WARN("split state was -1, should be rewritten to 1", K(meta.pg_key_)); } - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; if (OB_ISNULL(partition = ctx_->get_partition())) { ret = OB_ERR_SYS; @@ -13093,7 +13114,7 @@ ObGroupMigrateDag::~ObGroupMigrateDag() } } -bool ObGroupMigrateDag::operator==(const ObIDag& other) const +bool ObGroupMigrateDag::operator==(const ObIDag &other) const { bool is_same = true; if (this == &other) { @@ -13101,7 +13122,7 @@ bool ObGroupMigrateDag::operator==(const ObIDag& other) const } else if (get_type() != other.get_type()) { is_same = false; } else { - const ObGroupMigrateDag& other_dag = static_cast(other); + const ObGroupMigrateDag &other_dag = static_cast(other); is_same = group_task_ == other_dag.group_task_; } return is_same; @@ -13113,7 +13134,7 @@ int64_t ObGroupMigrateDag::hash() const return common::murmurhash(&ptr, sizeof(ptr), 0); } -int ObGroupMigrateDag::init(ObPartGroupTask* group_task, storage::ObPartitionService* partition_service) +int ObGroupMigrateDag::init(ObPartGroupTask *group_task, storage::ObPartitionService *partition_service) { int ret = OB_SUCCESS; @@ -13141,7 +13162,7 @@ void ObGroupMigrateDag::clear() tenant_id_ = 0; } -int ObGroupMigrateDag::fill_comment(char* buf, const int64_t buf_len) const +int ObGroupMigrateDag::fill_comment(char *buf, const int64_t buf_len) const { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -13153,7 +13174,7 @@ int ObGroupMigrateDag::fill_comment(char* buf, const int64_t buf_len) const ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "invalid args", K(ret), K(*group_task_)); } else { - const ObReplicaOpArg& arg = group_task_->get_task_list().at(0).arg_; + const ObReplicaOpArg &arg = group_task_->get_task_list().at(0).arg_; int n = snprintf(buf, buf_len, "group partition migration executor: group_task_id=%s partition_count=%ld partition_id=%ld " @@ -13180,7 +13201,7 @@ ObGroupMigrateExecuteTask::ObGroupMigrateExecuteTask() ObGroupMigrateExecuteTask::~ObGroupMigrateExecuteTask() {} -int ObGroupMigrateExecuteTask::init(ObPartGroupTask* group_task) +int ObGroupMigrateExecuteTask::init(ObPartGroupTask *group_task) { int ret = OB_SUCCESS; @@ -13211,7 +13232,7 @@ int ObGroupMigrateExecuteTask::process() } int ObMigrateGetLeaderUtil::get_leader( - const common::ObPartitionKey& pkey, ObMigrateSrcInfo& leader_info, const bool force_renew) + const common::ObPartitionKey &pkey, ObMigrateSrcInfo &leader_info, const bool force_renew) { int ret = OB_SUCCESS; const int64_t cluster_id = GCONF.cluster_id; @@ -13220,7 +13241,7 @@ int ObMigrateGetLeaderUtil::get_leader( ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "pkey is invalid", K(ret), K(pkey)); } else { - share::ObIPartitionLocationCache* location_cache = NULL; + share::ObIPartitionLocationCache *location_cache = NULL; if (NULL == (location_cache = ObPartitionService::get_instance().get_location_cache())) { ret = OB_ERR_SYS; STORAGE_LOG(ERROR, "location cache must not null", K(ret)); @@ -13233,7 +13254,7 @@ int ObMigrateGetLeaderUtil::get_leader( return ret; } -int ObMigrateGetLeaderUtil::get_clog_parent(clog::ObIPartitionLogService& log_service, ObMigrateSrcInfo& parent_info) +int ObMigrateGetLeaderUtil::get_clog_parent(clog::ObIPartitionLogService &log_service, ObMigrateSrcInfo &parent_info) { int ret = OB_SUCCESS; parent_info.reset(); @@ -13254,8 +13275,8 @@ int ObMigrateTaskGeneratorTask::schedule_migrate_tasks() int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; bool need_schedule = false; - ObArray last_task_array; - ObITask* last_task = NULL; + ObArray last_task_array; + ObITask *last_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -13322,8 +13343,8 @@ int ObMigrateTaskGeneratorTask::schedule_migrate_tasks() int ObMigrateTaskGeneratorTask::update_multi_version_start() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; - ObPGStorage* pg_storage = NULL; + ObIPartitionGroup *partition = NULL; + ObPGStorage *pg_storage = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate prepare task do not init", K(ret)); @@ -13335,9 +13356,9 @@ int ObMigrateTaskGeneratorTask::update_multi_version_start() LOG_WARN("pg storage should not be NULL", K(ret), KP(pg_storage)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - const ObPartitionMigrateCtx& pctx = ctx_->part_ctx_array_.at(i); - const ObMigratePartitionInfo& copy_info = ctx_->part_ctx_array_.at(i).copy_info_; - const ObPartitionKey& pkey = copy_info.meta_.pkey_; + const ObPartitionMigrateCtx &pctx = ctx_->part_ctx_array_.at(i); + const ObMigratePartitionInfo ©_info = ctx_->part_ctx_array_.at(i).copy_info_; + const ObPartitionKey &pkey = copy_info.meta_.pkey_; if (pctx.is_partition_exist_) { if (OB_FAIL(pg_storage->update_multi_version_start(pkey, copy_info.meta_.multi_version_start_))) { LOG_WARN("fail to update multi version start", K(ret), K(pkey), K(copy_info)); @@ -13358,10 +13379,10 @@ int ObMigrateTaskGeneratorTask::deal_with_new_partition() return ret; } -int ObMigrateTaskGeneratorTask::generate_restore_tailored_task(share::ObITask* last_task) +int ObMigrateTaskGeneratorTask::generate_restore_tailored_task(share::ObITask *last_task) { int ret = OB_SUCCESS; - ObRestoreTailoredPrepareTask* prepare_task = NULL; + ObRestoreTailoredPrepareTask *prepare_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -13384,7 +13405,7 @@ int ObMigrateTaskGeneratorTask::generate_restore_tailored_task(share::ObITask* l return ret; } -int ObMigrateUtil::wait_trans_table_merge_finish(ObMigrateCtx& ctx) +int ObMigrateUtil::wait_trans_table_merge_finish(ObMigrateCtx &ctx) { int ret = OB_SUCCESS; const int64_t WAIT_TIMEOUT = 300L * 1000L * 1000L; // 5min @@ -13430,7 +13451,7 @@ int ObRestoreTailoredPrepareTask::init() ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); is_inited_ = true; } return ret; @@ -13439,8 +13460,8 @@ int ObRestoreTailoredPrepareTask::init() int ObRestoreTailoredPrepareTask::process() { int ret = OB_SUCCESS; - ObRestoreTailoredFinishTask* finish_task = NULL; - ObIPartitionGroup* partition_group = NULL; + ObRestoreTailoredFinishTask *finish_task = NULL; + ObIPartitionGroup *partition_group = NULL; bool need_generate = false; bool cleared_memstore = false; bool has_memstore = false; @@ -13468,7 +13489,7 @@ int ObRestoreTailoredPrepareTask::process() LOG_WARN("failed to get memtables", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tables_handle.get_count(); ++i) { - memtable::ObMemtable* memtable = static_cast(tables_handle.get_table(i)); + memtable::ObMemtable *memtable = static_cast(tables_handle.get_table(i)); if (OB_ISNULL(memtable)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("memtable should not be NULL", KP(memtable)); @@ -13515,10 +13536,10 @@ int ObRestoreTailoredPrepareTask::process() return ret; } -int ObRestoreTailoredPrepareTask::schedule_restore_tailored_task(ObRestoreTailoredFinishTask& finish_task) +int ObRestoreTailoredPrepareTask::schedule_restore_tailored_task(ObRestoreTailoredFinishTask &finish_task) { int ret = OB_SUCCESS; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; ObPartitionArray pkeys; const bool include_trans_table = false; const bool is_restore_point = false; @@ -13555,10 +13576,10 @@ int ObRestoreTailoredPrepareTask::schedule_restore_tailored_task(ObRestoreTailor LOG_WARN("failed to init schema filter", K(ret), K(tenant_id), K(restore_schema_version)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < pkeys.count(); ++i) { - const ObPartitionKey& pkey = pkeys.at(i); + const ObPartitionKey &pkey = pkeys.at(i); ObPGPartitionGuard pg_partition_guard; ObTablesHandle tables_handle; - ObPartitionStorage* storage = NULL; + ObPartitionStorage *storage = NULL; ObArray index_ids; bool is_exist = false; if (schema_filter.check_partition_exist(pkey, is_exist)) { @@ -13570,7 +13591,7 @@ int ObRestoreTailoredPrepareTask::schedule_restore_tailored_task(ObRestoreTailor } else if (OB_ISNULL(pg_partition_guard.get_pg_partition())) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "get pg partition error", K(ret), KP(pg_partition_guard.get_pg_partition())); - } else if (OB_ISNULL(storage = static_cast( + } else if (OB_ISNULL(storage = static_cast( pg_partition_guard.get_pg_partition()->get_storage()))) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "partition storage must not be NULL", K(ret)); @@ -13586,20 +13607,20 @@ int ObRestoreTailoredPrepareTask::schedule_restore_tailored_task(ObRestoreTailor return ret; } -int ObRestoreTailoredPrepareTask::schedule_restore_table_tailored_task_(const common::ObIArray& index_ids, - const ObPartitionKey& partition_key, ObPartitionStorage& storage, ObRestoreTailoredFinishTask& finish_task) +int ObRestoreTailoredPrepareTask::schedule_restore_table_tailored_task_(const common::ObIArray &index_ids, + const ObPartitionKey &partition_key, ObPartitionStorage &storage, ObRestoreTailoredFinishTask &finish_task) { int ret = OB_SUCCESS; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("restore tailored prepare task do not init", K(ret)); } else { - const ObPGKey& pg_key = ctx_->replica_op_arg_.key_; + const ObPGKey &pg_key = ctx_->replica_op_arg_.key_; for (int64_t i = 0; OB_SUCC(ret) && i < index_ids.count(); ++i) { const uint64_t index_id = index_ids.at(i); ObTablesHandle minor_tables_handle; ObTableHandle major_handle; - ObRestoreTailoredTask* task = NULL; + ObRestoreTailoredTask *task = NULL; if (OB_FAIL(storage.get_partition_store().get_latest_minor_sstables(index_id, minor_tables_handle))) { LOG_WARN("failed to get latest minor sstables", K(ret), K(index_id)); } else if (OB_FAIL(storage.get_partition_store().get_last_major_sstable(index_id, major_handle))) { @@ -13621,7 +13642,7 @@ int ObRestoreTailoredPrepareTask::schedule_restore_table_tailored_task_(const co } int ObRestoreTailoredPrepareTask::filter_tailored_tables( - common::ObIArray& index_ids, ObRecoveryPointSchemaFilter& schema_filter) + common::ObIArray &index_ids, ObRecoveryPointSchemaFilter &schema_filter) { int ret = OB_SUCCESS; ObArray tmp_index_ids; @@ -13650,7 +13671,7 @@ int ObRestoreTailoredPrepareTask::filter_tailored_tables( int ObRestoreTailoredPrepareTask::update_restore_flag_cut_data() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; int16_t restore_status = ObReplicaRestoreStatus::REPLICA_NOT_RESTORE; const int16_t flag = REPLICA_RESTORE_CUT_DATA; @@ -13671,7 +13692,7 @@ int ObRestoreTailoredPrepareTask::update_restore_flag_cut_data() } else if (REPLICA_RESTORE_CUT_DATA == restore_status) { // do nothing } else { - const ObPGKey& pg_key = ctx_->replica_op_arg_.key_; + const ObPGKey &pg_key = ctx_->replica_op_arg_.key_; if (OB_FAIL(MIGRATOR.get_partition_service()->set_restore_flag(pg_key, flag))) { LOG_WARN("failed to set restore flag", K(ret), K(pg_key)); } @@ -13679,14 +13700,14 @@ int ObRestoreTailoredPrepareTask::update_restore_flag_cut_data() return ret; } -int ObRestoreTailoredPrepareTask::check_need_generate_task(bool& need_generate) +int ObRestoreTailoredPrepareTask::check_need_generate_task(bool &need_generate) { int ret = OB_SUCCESS; need_generate = false; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; ObTablesHandle tables_handle; int64_t max_upper_trans_version = 0; - transaction::ObTransService* trans_service = NULL; + transaction::ObTransService *trans_service = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -13707,14 +13728,14 @@ int ObRestoreTailoredPrepareTask::check_need_generate_task(bool& need_generate) const int64_t restore_snapshot_version = ctx_->replica_op_arg_.phy_restore_arg_.restore_info_.restore_snapshot_version_; for (int64_t i = 0; OB_SUCC(ret) && i < tables_handle.get_count(); ++i) { - ObITable* table = tables_handle.get_table(i); - ObSSTable* sstable = NULL; + ObITable *table = tables_handle.get_table(i); + ObSSTable *sstable = NULL; if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be NULL", K(ret), KP(table)); } else if (table->is_major_sstable() || table->is_trans_sstable()) { // do nothing - } else if (OB_ISNULL(sstable = reinterpret_cast(table))) { + } else if (OB_ISNULL(sstable = reinterpret_cast(table))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("sstable should not be NULL", K(ret), KP(sstable)); } else { @@ -13769,9 +13790,9 @@ ObRestoreTailoredTask::ObRestoreTailoredTask() ObRestoreTailoredTask::~ObRestoreTailoredTask() {} -int ObRestoreTailoredTask::init(const uint64_t index_id, const ObTablesHandle& minor_tables_handle, - const ObTableHandle& major_table_handle, const ObPGKey& pg_key, const ObPartitionKey& partition_key, - ObRestoreTailoredFinishTask& finish_task) +int ObRestoreTailoredTask::init(const uint64_t index_id, const ObTablesHandle &minor_tables_handle, + const ObTableHandle &major_table_handle, const ObPGKey &pg_key, const ObPartitionKey &partition_key, + ObRestoreTailoredFinishTask &finish_task) { int ret = OB_SUCCESS; if (is_inited_) { @@ -13788,7 +13809,7 @@ int ObRestoreTailoredTask::init(const uint64_t index_id, const ObTablesHandle& m index_id_ = index_id; pg_key_ = pg_key; partition_key_ = partition_key; - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); finish_task_ = &finish_task; is_inited_ = true; } @@ -13840,7 +13861,7 @@ int ObRestoreTailoredTask::process() return ret; } -int ObRestoreTailoredTask::get_tailored_table_key(ObITable::TableKey& table_key) +int ObRestoreTailoredTask::get_tailored_table_key(ObITable::TableKey &table_key) { int ret = OB_SUCCESS; @@ -13856,7 +13877,7 @@ int ObRestoreTailoredTask::get_tailored_table_key(ObITable::TableKey& table_key) int64_t max_log_ts = 0; int64_t pre_log_ts = 0; for (int64_t i = 0; OB_SUCC(ret) && i < minor_tables_handle_.get_count(); ++i) { - const ObITable* table = minor_tables_handle_.get_table(i); + const ObITable *table = minor_tables_handle_.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be NULL", K(ret), KP(table), K(index_id_), K(partition_key_), K(pg_key_)); @@ -13904,7 +13925,7 @@ int ObRestoreTailoredTask::get_tailored_table_key(ObITable::TableKey& table_key) ret = OB_ERR_UNEXPECTED; LOG_WARN("tailored table key is invalid", K(ret), K(table_key)); } else if (1 == minor_tables_handle_.get_count()) { - const ObITable* table = minor_tables_handle_.get_table(0); + const ObITable *table = minor_tables_handle_.get_table(0); if (table->get_key() == table_key) { // same table key not allowed because can not add in table mgr table_key.table_type_ = ObITable::MINI_MINOR_SSTABLE; @@ -13924,12 +13945,12 @@ int ObRestoreTailoredTask::get_tailored_table_key(ObITable::TableKey& table_key) return ret; } -int ObRestoreTailoredTask::generate_new_minor_sstable(const ObITable::TableKey& table_key, - ObMacroBlocksWriteCtx& block_write_ctx, ObMacroBlocksWriteCtx& lob_block_write_ctx) +int ObRestoreTailoredTask::generate_new_minor_sstable(const ObITable::TableKey &table_key, + ObMacroBlocksWriteCtx &block_write_ctx, ObMacroBlocksWriteCtx &lob_block_write_ctx) { int ret = OB_SUCCESS; storage::ObCreateSSTableParamWithTable create_sstable_param; - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; ObSchemaGetterGuard schema_guard; ObTableHandle handle; bool has_lob_column = false; @@ -13981,7 +14002,7 @@ int ObRestoreTailoredTask::generate_new_minor_sstable(const ObITable::TableKey& } if (OB_SUCC(ret)) { - ObIPartitionGroup* pg = nullptr; + ObIPartitionGroup *pg = nullptr; if (OB_ISNULL(pg = ctx_->partition_guard_.get_partition_group())) { ret = OB_ERR_SYS; LOG_WARN("partition must not null", K(ret)); @@ -14028,7 +14049,7 @@ ObRestoreTailoredFinishTask::ObRestoreTailoredFinishTask() ObRestoreTailoredFinishTask::~ObRestoreTailoredFinishTask() {} -int ObRestoreTailoredFinishTask::add_sstable_handle(const ObPartitionKey& pkey, ObTableHandle& handle) +int ObRestoreTailoredFinishTask::add_sstable_handle(const ObPartitionKey &pkey, ObTableHandle &handle) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -14041,7 +14062,7 @@ int ObRestoreTailoredFinishTask::add_sstable_handle(const ObPartitionKey& pkey, common::SpinWLockGuard guard(lock_); bool found = false; for (int64_t i = 0; OB_SUCC(ret) && i < part_ctx_array_.count() && !found; ++i) { - ObPartitionMigrateCtx& part_ctx = part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_ctx = part_ctx_array_.at(i); if (part_ctx.copy_info_.meta_.pkey_ == pkey) { if (OB_FAIL(part_ctx.handle_.add_table(handle))) { LOG_WARN("failed to add table handle", K(ret), K(handle)); @@ -14076,7 +14097,7 @@ int ObRestoreTailoredFinishTask::init() ret = OB_INIT_TWICE; LOG_WARN("restore tailored finish task init twice", K(ret)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); is_inited_ = true; } return ret; @@ -14086,7 +14107,7 @@ int ObRestoreTailoredFinishTask::process() { int ret = OB_SUCCESS; const int64_t schema_version = OB_INVALID_VERSION; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; ObSavedStorageInfoV2 save_info; ObPGKey pg_key; @@ -14114,7 +14135,7 @@ int ObRestoreTailoredFinishTask::process() } else if (OB_FAIL(partition_group->get_all_saved_info(save_info))) { LOG_WARN("failed to get all saved info", K(ret)); } else { - ObDataStorageInfo& storage_info = save_info.get_data_info(); + ObDataStorageInfo &storage_info = save_info.get_data_info(); const int64_t publish_version = std::min(storage_info.get_publish_version(), restore_snapshot_version); storage_info.set_publish_version(publish_version); storage_info.set_schema_version(schema_version_); @@ -14166,7 +14187,7 @@ int ObMigrateTaskGeneratorTask::init() ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); is_inited_ = true; bandwidth_throttle_ = MIGRATOR.get_bandwidth_throttle(); partition_service_ = MIGRATOR.get_partition_service(); @@ -14241,7 +14262,7 @@ ObMigrateRecoveryPointTaskGeneratorTask::ObMigrateRecoveryPointTaskGeneratorTask ObMigrateRecoveryPointTaskGeneratorTask::~ObMigrateRecoveryPointTaskGeneratorTask() {} -int ObMigrateRecoveryPointTaskGeneratorTask::init(share::ObITask& wait_recovery_point_task) +int ObMigrateRecoveryPointTaskGeneratorTask::init(share::ObITask &wait_recovery_point_task) { int ret = OB_SUCCESS; @@ -14252,7 +14273,7 @@ int ObMigrateRecoveryPointTaskGeneratorTask::init(share::ObITask& wait_recovery_ ObIDag::DAG_TYPE_VALIDATE != dag_->get_type()) { ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); - } else if (FALSE_IT(ctx_ = static_cast(dag_)->get_ctx())) { + } else if (FALSE_IT(ctx_ = static_cast(dag_)->get_ctx())) { } else if (ADD_REPLICA_OP != ctx_->replica_op_arg_.type_ && MIGRATE_REPLICA_OP != ctx_->replica_op_arg_.type_ && REBUILD_REPLICA_OP != ctx_->replica_op_arg_.type_ && CHANGE_REPLICA_OP != ctx_->replica_op_arg_.type_) { ret = OB_INVALID_ARGUMENT; @@ -14260,7 +14281,7 @@ int ObMigrateRecoveryPointTaskGeneratorTask::init(share::ObITask& wait_recovery_ } else if (OB_FAIL(this->add_child(wait_recovery_point_task))) { LOG_WARN("failed to add recovery point finish task", K(ret)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); bandwidth_throttle_ = MIGRATOR.get_bandwidth_throttle(); partition_service_ = MIGRATOR.get_partition_service(); srv_rpc_proxy_ = MIGRATOR.get_svr_rpc_proxy(); @@ -14362,7 +14383,7 @@ int ObMigrateRecoveryPointTaskGeneratorTask::build_migrate_recovery_point_task() } int ObMigrateRecoveryPointTaskGeneratorTask::build_migrate_recovery_point_info( - const ObRecoveryPointKey& recovery_point_key) + const ObRecoveryPointKey &recovery_point_key) { int ret = OB_SUCCESS; @@ -14381,7 +14402,7 @@ int ObMigrateRecoveryPointTaskGeneratorTask::build_migrate_recovery_point_info( } int ObMigrateRecoveryPointTaskGeneratorTask::get_recovery_point_meta_info( - const ObMigrateSrcInfo& src_info, const ObRecoveryPointKey& recovery_point_key) + const ObMigrateSrcInfo &src_info, const ObRecoveryPointKey &recovery_point_key) { int ret = OB_SUCCESS; ObRecoveryPointMetaInfoReader reader; @@ -14410,7 +14431,7 @@ int ObMigrateRecoveryPointTaskGeneratorTask::get_recovery_point_meta_info( } int ObMigrateRecoveryPointTaskGeneratorTask::inner_build_migrate_recovery_point_info( - const ObRecoveryPointMetaInfo& recovery_point_meta_info) + const ObRecoveryPointMetaInfo &recovery_point_meta_info) { int ret = OB_SUCCESS; int64_t cost_ts = ObTimeUtility::current_time(); @@ -14431,10 +14452,10 @@ int ObMigrateRecoveryPointTaskGeneratorTask::inner_build_migrate_recovery_point_ } int ObMigrateRecoveryPointTaskGeneratorTask::check_local_recovery_point_exist( - const ObRecoveryPointKey& recovery_point_key, bool& is_exist) + const ObRecoveryPointKey &recovery_point_key, bool &is_exist) { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; is_exist = false; if (!is_inited_) { @@ -14451,7 +14472,7 @@ int ObMigrateRecoveryPointTaskGeneratorTask::check_local_recovery_point_exist( } int ObMigrateRecoveryPointTaskGeneratorTask::build_migrate_recovery_point_table_info( - const ObRecoveryPointMetaInfo& recovery_point_meta_info) + const ObRecoveryPointMetaInfo &recovery_point_meta_info) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -14462,9 +14483,9 @@ int ObMigrateRecoveryPointTaskGeneratorTask::build_migrate_recovery_point_table_ LOG_WARN("build migrate recovery point table info get invalid argument", K(ret), K(recovery_point_meta_info)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < recovery_point_meta_info.table_keys_.count(); ++i) { - const ObITable::TableKey& table_key = recovery_point_meta_info.table_keys_.at(i); + const ObITable::TableKey &table_key = recovery_point_meta_info.table_keys_.at(i); ObTableHandle table_handle; - ObITable* table = NULL; + ObITable *table = NULL; if (!table_key.is_valid() || table_key.is_memtable()) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table key is unexpected", K(ret), K(table_key)); @@ -14488,8 +14509,8 @@ int ObMigrateRecoveryPointTaskGeneratorTask::build_migrate_recovery_point_table_ int ObMigrateRecoveryPointTaskGeneratorTask::schedule_migrate_recovery_point_tasks() { int ret = OB_SUCCESS; - ObITask* last_task = NULL; - ObMigrateRecoveryPointFinishTask* finish_task = NULL; + ObITask *last_task = NULL; + ObMigrateRecoveryPointFinishTask *finish_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; @@ -14528,12 +14549,12 @@ int ObMigrateRecoveryPointTaskGeneratorTask::schedule_migrate_recovery_point_tas return ret; } -int ObMigrateRecoveryPointTaskGeneratorTask::generate_migrate_recovery_point_tasks(ObITask*& last_task) +int ObMigrateRecoveryPointTaskGeneratorTask::generate_migrate_recovery_point_tasks(ObITask *&last_task) { int ret = OB_SUCCESS; last_task = NULL; - ObFakeTask* wait_migrate_finish_task = NULL; - ObITask* parent_task = this; + ObFakeTask *wait_migrate_finish_task = NULL; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; @@ -14548,8 +14569,8 @@ int ObMigrateRecoveryPointTaskGeneratorTask::generate_migrate_recovery_point_tas LOG_ERROR("wait_rebuild_finish_task must not null", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < recovery_point_meta_info_.table_keys_.count(); ++i) { - const ObITable::TableKey& table_key = recovery_point_meta_info_.table_keys_.at(i); - ObFakeTask* wait_finish_task = NULL; + const ObITable::TableKey &table_key = recovery_point_meta_info_.table_keys_.at(i); + ObFakeTask *wait_finish_task = NULL; ObMigrateTableInfo::SSTableInfo sstable_info; sstable_info.src_table_key_ = table_key; sstable_info.dest_base_version_ = table_key.trans_version_range_.base_version_; @@ -14598,8 +14619,8 @@ ObMigrateRecoveryPointFinishTask::~ObMigrateRecoveryPointFinishTask() {} int ObMigrateRecoveryPointFinishTask::init(const bool is_recovery_point_exist, - const ObRecoveryPointMetaInfo& recovery_point_meta_info, ObMigrateCtx& ctx, - share::ObITask& wait_recovery_point_finish_task) + const ObRecoveryPointMetaInfo &recovery_point_meta_info, ObMigrateCtx &ctx, + share::ObITask &wait_recovery_point_finish_task) { int ret = OB_SUCCESS; @@ -14674,7 +14695,7 @@ int ObMigrateRecoveryPointFinishTask::process() int ObMigrateRecoveryPointFinishTask::create_recovery_point() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition = NULL; + ObIPartitionGroup *partition = NULL; ObRecoveryPointKey recovery_point_key; ObTablesHandle tables_handle; @@ -14693,7 +14714,7 @@ int ObMigrateRecoveryPointFinishTask::create_recovery_point() LOG_WARN("local partition do not exist", K(ret), K(*ctx_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < recovery_point_meta_info_.table_keys_.count(); ++i) { - const ObITable::TableKey& table_key = recovery_point_meta_info_.table_keys_.at(i); + const ObITable::TableKey &table_key = recovery_point_meta_info_.table_keys_.at(i); ObTableHandle table_handle; if (OB_FAIL(partition->acquire_sstable(table_key, table_handle))) { LOG_WARN("failed to acquire sstable", K(ret), K(table_key)); @@ -14727,7 +14748,7 @@ int ObMigrateRecoveryPointFinishTask::create_recovery_point() int ObMigrateRecoveryPointFinishTask::generate_next_task() { int ret = OB_SUCCESS; - ObITask* task = NULL; + ObITask *task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -14742,11 +14763,11 @@ int ObMigrateRecoveryPointFinishTask::generate_next_task() return ret; } -int ObMigrateRecoveryPointFinishTask::inner_generate_next_task(ObITask*& task) +int ObMigrateRecoveryPointFinishTask::inner_generate_next_task(ObITask *&task) { int ret = OB_SUCCESS; task = NULL; - ObMigrateRecoveryPointTaskGeneratorTask* recovert_point_task_generator_task = NULL; + ObMigrateRecoveryPointTaskGeneratorTask *recovert_point_task_generator_task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -14773,7 +14794,7 @@ ObMigrateTransTableTaskGeneratorTask::ObMigrateTransTableTaskGeneratorTask() ObMigrateTransTableTaskGeneratorTask::~ObMigrateTransTableTaskGeneratorTask() {} -int ObMigrateTransTableTaskGeneratorTask::init(share::ObITask& wait_finish_task) +int ObMigrateTransTableTaskGeneratorTask::init(share::ObITask &wait_finish_task) { int ret = OB_SUCCESS; @@ -14786,7 +14807,7 @@ int ObMigrateTransTableTaskGeneratorTask::init(share::ObITask& wait_finish_task) ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); bandwidth_throttle_ = MIGRATOR.get_bandwidth_throttle(); partition_service_ = MIGRATOR.get_partition_service(); srv_rpc_proxy_ = MIGRATOR.get_svr_rpc_proxy(); @@ -14849,7 +14870,7 @@ int ObMigrateTransTableTaskGeneratorTask::build_migrate_trans_table_task() LOG_INFO("no need to migrate trans table", K(ret), K(ctx_->replica_op_arg_.type_)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ctx_->part_ctx_array_.count(); ++i) { - ObPartitionMigrateCtx& part_migrate_ctx = ctx_->part_ctx_array_.at(i); + ObPartitionMigrateCtx &part_migrate_ctx = ctx_->part_ctx_array_.at(i); if (!part_migrate_ctx.copy_info_.meta_.pkey_.is_trans_table()) { // do nothing } else if (OB_FAIL(inner_build_migrate_trans_table_task(part_migrate_ctx))) { @@ -14860,7 +14881,7 @@ int ObMigrateTransTableTaskGeneratorTask::build_migrate_trans_table_task() return ret; } -int ObMigrateTransTableTaskGeneratorTask::inner_build_migrate_trans_table_task(ObPartitionMigrateCtx& part_migrate_ctx) +int ObMigrateTransTableTaskGeneratorTask::inner_build_migrate_trans_table_task(ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; if (!is_inited_) { @@ -14871,10 +14892,10 @@ int ObMigrateTransTableTaskGeneratorTask::inner_build_migrate_trans_table_task(O LOG_WARN("inner build migrate trans table task get invalid argument", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < part_migrate_ctx.copy_info_.table_infos_.count(); ++i) { - const ObMigratePartitionInfo& copy_info = part_migrate_ctx.copy_info_; - const ObArray& table_infos = copy_info.table_infos_; + const ObMigratePartitionInfo ©_info = part_migrate_ctx.copy_info_; + const ObArray &table_infos = copy_info.table_infos_; for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) { - const ObMigrateTableInfo& table_info = table_infos.at(i); + const ObMigrateTableInfo &table_info = table_infos.at(i); if (OB_FAIL(build_trans_sstable_tasks(ctx_->migrate_src_info_, table_info, part_migrate_ctx))) { LOG_WARN("failed to build trans sstable tasks", K(ret), K(i), K(table_info), K(part_migrate_ctx)); } @@ -14885,10 +14906,10 @@ int ObMigrateTransTableTaskGeneratorTask::inner_build_migrate_trans_table_task(O } int ObMigrateTransTableTaskGeneratorTask::build_trans_sstable_tasks( - const ObMigrateSrcInfo& src_info, const ObMigrateTableInfo& table_info, ObPartitionMigrateCtx& part_migrate_ctx) + const ObMigrateSrcInfo &src_info, const ObMigrateTableInfo &table_info, ObPartitionMigrateCtx &part_migrate_ctx) { int ret = OB_SUCCESS; - ObITask* parent_task = this; + ObITask *parent_task = this; if (!is_inited_) { ret = OB_NOT_INIT; LOG_WARN("migrate trans table task generator do not init", K(ret)); @@ -14898,8 +14919,8 @@ int ObMigrateTransTableTaskGeneratorTask::build_trans_sstable_tasks( } else { // add trans sstables for (int64_t sstable_idx = 0; OB_SUCC(ret) && sstable_idx < table_info.major_sstables_.count(); ++sstable_idx) { - const ObMigrateTableInfo::SSTableInfo& trans_table_info = table_info.major_sstables_.at(sstable_idx); - ObFakeTask* wait_finish_task = NULL; + const ObMigrateTableInfo::SSTableInfo &trans_table_info = table_info.major_sstables_.at(sstable_idx); + ObFakeTask *wait_finish_task = NULL; if (!ObITable::is_trans_sstable(trans_table_info.src_table_key_.table_type_)) { ret = OB_ERR_SYS; LOG_ERROR("table type not match major sstable", K(ret), K(trans_table_info), K(table_info)); @@ -14953,7 +14974,7 @@ int ObMigrateTaskSchedulerTask::init() ret = OB_ERR_SYS; LOG_ERROR("dag type not match", K(ret), K(*dag_)); } else { - ctx_ = static_cast(dag_)->get_ctx(); + ctx_ = static_cast(dag_)->get_ctx(); is_inited_ = true; bandwidth_throttle_ = MIGRATOR.get_bandwidth_throttle(); partition_service_ = MIGRATOR.get_partition_service(); @@ -15027,7 +15048,7 @@ int ObMigrateTaskSchedulerTask::process() return ret; } -int ObMigrateTaskSchedulerTask::add_partition_migration_status(const ObMigrateCtx& ctx) +int ObMigrateTaskSchedulerTask::add_partition_migration_status(const ObMigrateCtx &ctx) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -15069,7 +15090,7 @@ int ObMigrateTaskSchedulerTask::add_partition_migration_status(const ObMigrateCt int ObMigrateTaskSchedulerTask::schedule_task_by_type() { int ret = OB_SUCCESS; - ObIPartitionGroup* partition_group = NULL; + ObIPartitionGroup *partition_group = NULL; int16_t restore_flag = REPLICA_NOT_RESTORE; if (!is_inited_) { @@ -15094,7 +15115,7 @@ int ObMigrateTaskSchedulerTask::schedule_task_by_type() int ObMigrateTaskSchedulerTask::generate_restore_cut_prepare_task() { int ret = OB_SUCCESS; - ObRestoreTailoredPrepareTask* task = NULL; + ObRestoreTailoredPrepareTask *task = NULL; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); @@ -15113,7 +15134,7 @@ int ObMigrateTaskSchedulerTask::generate_restore_cut_prepare_task() int ObMigrateTaskSchedulerTask::generate_migrate_prepare_task() { int ret = OB_SUCCESS; - ObMigratePrepareTask* task = nullptr; + ObMigratePrepareTask *task = nullptr; if (!is_inited_) { ret = OB_NOT_INIT; LOG_ERROR("not inited", K(ret)); diff --git a/src/storage/ob_partition_service.cpp b/src/storage/ob_partition_service.cpp index 78daec6b9f44b25210fb8f0518059551888287b4..5e1956bbad20332302cf085ad0dd2d2025bc477a 100644 --- a/src/storage/ob_partition_service.cpp +++ b/src/storage/ob_partition_service.cpp @@ -11974,8 +11974,8 @@ void ObPartitionMigrationDataStatics::reset() reuse_count_ = 0; partition_count_ = 0; finish_partition_count_ = 0; - // input_bytes_; - // output_bytes_; + input_bytes_ = 0; + output_bytes_ = 0; } ObRestoreInfo::ObRestoreInfo() @@ -14057,5 +14057,69 @@ int ObPartitionService::check_standby_cluster_schema_condition(const ObPartition return ret; } +int ObPartitionService::standby_cut_data_batch(const obrpc::ObStandbyCutDataBatchTaskArg& arg) +{ + int ret = OB_SUCCESS; + ObArray task_list; + const ObReplicaOpType type = RESTORE_STANDBY_OP; + int64_t flashback_ts = 0; + + if (OB_UNLIKELY(!is_inited_)) { + ret = OB_NOT_INIT; + STORAGE_LOG(WARN, "The ObPartitionService has not been inited, ", K(ret)); + } else if (OB_UNLIKELY(!is_running_)) { + ret = OB_CANCELED; + STORAGE_LOG(WARN, "The service is not running, ", K(ret)); + } else if (OB_UNLIKELY(!is_scan_disk_finished())) { + ret = OB_EAGAIN; + STORAGE_LOG(WARN, "rebooting, replica op not allow", K(ret)); + } else if (!arg.is_valid() || arg.arg_array_.empty()) { + ret = OB_INVALID_ARGUMENT; + STORAGE_LOG(WARN, "failed args", K(ret), K(arg)); + } else if (OB_FAIL(task_list.reserve(arg.arg_array_.count()))) { + STORAGE_LOG(WARN, "failed to reserve task list", K(ret)); + } else if (FALSE_IT(flashback_ts = arg.flashback_ts_)) { + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < arg.arg_array_.count(); ++i) { + const obrpc::ObStandbyCutDataTaskArg& single_arg = arg.arg_array_.at(i); + ObReplicaOpArg replica_op_arg; + replica_op_arg.data_src_ = single_arg.dst_; + replica_op_arg.dst_ = single_arg.dst_; + replica_op_arg.key_ = single_arg.pkey_; + replica_op_arg.priority_ = ObReplicaOpPriority::PRIO_LOW; + replica_op_arg.cluster_id_ = GCONF.cluster_id; + replica_op_arg.type_ = type; + replica_op_arg.switch_epoch_ = GCTX.get_switch_epoch2(); + replica_op_arg.phy_restore_arg_.restore_info_.restore_snapshot_version_ = flashback_ts; + ObIPartitionGroupGuard guard; + ObIPartitionGroup* partition = NULL; + ObReplicaRestoreStatus restore_status; + if (OB_FAIL(get_partition(single_arg.pkey_, guard))) { + STORAGE_LOG(WARN, "get partition failed", K(single_arg), K(ret)); + } else if (OB_ISNULL(guard.get_partition_group())) { + ret = OB_ENTRY_NOT_EXIST; + STORAGE_LOG(WARN, "partition not exist, maybe migrate out", K(single_arg), K(ret)); + } else if (OB_ISNULL(partition = guard.get_partition_group())) { + ret = OB_ERR_UNEXPECTED; + STORAGE_LOG(WARN, "partition should not be NULL", K(ret), K(single_arg)); + } else if (FALSE_IT(restore_status = partition->get_pg_storage().get_restore_status())) { + } else if (ObReplicaRestoreStatus::REPLICA_RESTORE_STANDBY_CUT != restore_status) { + LOG_INFO("partition restore status is not cut data, skip it", K(ret), K(single_arg)); + } else if (OB_FAIL(task_list.push_back(replica_op_arg))) { + LOG_WARN("failed to push replica op arg into array", K(ret), K(replica_op_arg)); + } + } + } + + if (OB_SUCC(ret)) { + if (task_list.empty()) { + LOG_INFO("has no replica need cut data, skip", K(ret), K(arg)); + } else if (OB_FAIL(ObPartGroupMigrator::get_instance().schedule(task_list, arg.trace_id_))) { + STORAGE_LOG(WARN, "fail to schedule migrate task.", K(arg), K(ret)); + } + } + return ret; +} + } // end of namespace storage } // end of namespace oceanbase diff --git a/src/storage/ob_partition_service.h b/src/storage/ob_partition_service.h index 9f985f5ee517c3fd70632f7d0eb30a1e3914fcf1..12efa5ee22844ae099042c62d2c5911448b92634 100644 --- a/src/storage/ob_partition_service.h +++ b/src/storage/ob_partition_service.h @@ -632,6 +632,7 @@ public: const common::ObReplicaMember& src, const common::ObReplicaMember& data_src, /* data source, if invalid, use leader instead */ const int64_t quorum); + VIRTUAL_FOR_UNITTEST int standby_cut_data_batch(const obrpc::ObStandbyCutDataBatchTaskArg& arg); // interface for online/offline VIRTUAL_FOR_UNITTEST int add_replica(const obrpc::ObAddReplicaArg& rpc_arg, const share::ObTaskId& task_id); @@ -704,8 +705,8 @@ public: const int64_t* total_task_count, common::ObIArray* splitted_ranges, common::ObIArray* split_index) override; - virtual int get_multi_ranges_cost( - const common::ObPartitionKey& pkey, const common::ObIArray& ranges, int64_t& total_size) override; + virtual int get_multi_ranges_cost(const common::ObPartitionKey& pkey, + const common::ObIArray& ranges, int64_t& total_size) override; virtual int split_multi_ranges(const common::ObPartitionKey& pkey, const common::ObIArray& ranges, const int64_t expected_task_count, common::ObIAllocator& allocator, common::ObArrayArray& multi_range_split_array) override; diff --git a/src/storage/ob_partition_store.cpp b/src/storage/ob_partition_store.cpp index 147abb57a220c6640bc9a903ee889f5ebd19b810..616d2a411ac8921257eb432f1e34c4706c008ca0 100644 --- a/src/storage/ob_partition_store.cpp +++ b/src/storage/ob_partition_store.cpp @@ -77,9 +77,9 @@ ObPartitionStore::ObPartitionStore() meta_ = &meta_buf_[0]; } -ObPGPartitionStoreMeta& ObPartitionStore::get_next_meta() +ObPGPartitionStoreMeta &ObPartitionStore::get_next_meta() { - ObPGPartitionStoreMeta* meta = &meta_buf_[0]; + ObPGPartitionStoreMeta *meta = &meta_buf_[0]; if (meta == meta_) { meta = &meta_buf_[1]; } @@ -101,8 +101,8 @@ ObPartitionStore::~ObPartitionStore() destroy(); } -int ObPartitionStore::create_partition_store(const ObPGPartitionStoreMeta& meta, const bool write_slog, - ObIPartitionGroup* pg, ObFreezeInfoSnapshotMgr& freeze_info_mgr, ObPGMemtableMgr* pg_memtable_mgr) +int ObPartitionStore::create_partition_store(const ObPGPartitionStoreMeta &meta, const bool write_slog, + ObIPartitionGroup *pg, ObFreezeInfoSnapshotMgr &freeze_info_mgr, ObPGMemtableMgr *pg_memtable_mgr) { int ret = OB_SUCCESS; ObTimeGuard timeguard("create_partition_store", 1000L * 1000L); @@ -133,10 +133,10 @@ int ObPartitionStore::create_partition_store(const ObPGPartitionStoreMeta& meta, } int ObPartitionStore::init( - const ObPGPartitionStoreMeta& meta, ObIPartitionGroup* pg, ObFreezeInfoSnapshotMgr& freeze_info_mgr) + const ObPGPartitionStoreMeta &meta, ObIPartitionGroup *pg, ObFreezeInfoSnapshotMgr &freeze_info_mgr) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; freeze_info_mgr_ = &freeze_info_mgr; if (is_inited_) { @@ -168,11 +168,11 @@ int ObPartitionStore::init( return ret; } -void ObPartitionStore::destroy_store_map(TableStoreMap* store_map) +void ObPartitionStore::destroy_store_map(TableStoreMap *store_map) { if (OB_NOT_NULL(store_map)) { for (TableStoreMap::iterator it = store_map->begin(); it != store_map->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { LOG_ERROR("table store must not null"); } else { @@ -211,7 +211,7 @@ int ObPartitionStore::set_removed() return ret; } -void ObPartitionStore::set_replica_type(const common::ObReplicaType& replica_type) +void ObPartitionStore::set_replica_type(const common::ObReplicaType &replica_type) { const bool need_clean_sstable = !ObReplicaTypeCheck::is_replica_with_ssstore(replica_type); @@ -243,7 +243,7 @@ void ObPartitionStore::clear_sstores_no_lock() FLOG_INFO("clean sstables", "pkey", meta_->pkey_); cached_data_table_store_ = nullptr; for (TableStoreMap::iterator it = store_map_->begin(); it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; free_multi_version_table_store(table_store); } store_map_->clear(); @@ -263,7 +263,7 @@ common::ObReplicaType ObPartitionStore::get_replica_type() const int ObPartitionStore::create_index_table_store(const uint64_t table_id, const int64_t schema_version) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCWLockGuard guard(lock_); @@ -283,22 +283,22 @@ int ObPartitionStore::create_index_table_store(const uint64_t table_id, const in return ret; } -int ObPartitionStore::check_table_store_exist(const uint64_t index_id, bool& exist) +int ObPartitionStore::check_table_store_exist(const uint64_t index_id, bool &exist) { - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; TCRLockGuard lock_guard(lock_); return check_table_store_exist_nolock(index_id, exist, table_store); } int ObPartitionStore::check_table_store_exist_with_lock( - const uint64_t index_id, bool& exist, ObMultiVersionTableStore*& got_table_store) + const uint64_t index_id, bool &exist, ObMultiVersionTableStore *&got_table_store) { TCRLockGuard lock_guard(lock_); return check_table_store_exist_nolock(index_id, exist, got_table_store); } int ObPartitionStore::check_table_store_exist_nolock( - const uint64_t index_id, bool& exist, ObMultiVersionTableStore*& got_table_store) + const uint64_t index_id, bool &exist, ObMultiVersionTableStore *&got_table_store) { int ret = OB_SUCCESS; got_table_store = NULL; @@ -324,7 +324,7 @@ int ObPartitionStore::check_table_store_exist_nolock( int ObPartitionStore::drop_index(const uint64_t table_id, const bool write_slog) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* got_table_store = NULL; + ObMultiVersionTableStore *got_table_store = NULL; bool exist = false; { @@ -371,7 +371,7 @@ int ObPartitionStore::drop_index(const uint64_t table_id, const bool write_slog) int ObPartitionStore::set_dropped_flag(const uint64_t table_id) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* got_table_store = NULL; + ObMultiVersionTableStore *got_table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -390,8 +390,8 @@ int ObPartitionStore::set_dropped_flag(const uint64_t table_id) // add_sstable won't update partition meta // in_slog_trans == false, slog controlled by caller, drop partiton when failed // in_slog_trans == true, slog controlled by self -int ObPartitionStore::add_sstable(storage::ObSSTable* table, const int64_t max_kept_major_version_number, - const bool in_slog_trans, const ObMigrateStatus& migrate_status, const bool is_in_dest_split, +int ObPartitionStore::add_sstable(storage::ObSSTable *table, const int64_t max_kept_major_version_number, + const bool in_slog_trans, const ObMigrateStatus &migrate_status, const bool is_in_dest_split, const int64_t schema_version) { int ret = OB_SUCCESS; @@ -414,8 +414,7 @@ int ObPartitionStore::add_sstable(storage::ObSSTable* table, const int64_t max_k param.schema_version_ = schema_version; if (!param.in_slog_trans_) { - if (OB_FAIL(get_kept_multi_version_start( - is_in_dest_split, param.multi_version_start_, param.backup_snapshot_version_))) { + if (OB_FAIL(get_kept_multi_version_start(is_in_dest_split, param.multi_version_start_))) { LOG_WARN("failed to get_kept_multi_version_start", K(ret)); } } @@ -430,13 +429,13 @@ int ObPartitionStore::add_sstable(storage::ObSSTable* table, const int64_t max_k } int ObPartitionStore::do_add_sstable( - AddTableParam& param, const ObMigrateStatus& migrate_status, const bool is_in_source_split) + AddTableParam ¶m, const ObMigrateStatus &migrate_status, const bool is_in_source_split) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; - ObMultiVersionTableStore* multi_version_store = NULL; - ObTableStore* new_table_store = NULL; + ObMultiVersionTableStore *multi_version_store = NULL; + ObTableStore *new_table_store = NULL; ObTableHandle handle; ObITable::TableKey table_key; bool need_abort_slog = false; @@ -551,13 +550,13 @@ int ObPartitionStore::do_add_sstable( } int ObPartitionStore::check_new_table_store( - ObTableStore& new_table_store, const ObMigrateStatus migrate_status, const bool is_in_source_split) + ObTableStore &new_table_store, const ObMigrateStatus migrate_status, const bool is_in_source_split) { int ret = OB_SUCCESS; - memtable::ObMemtable* active_memtable = NULL; + memtable::ObMemtable *active_memtable = NULL; ObTablesHandle tmp_handle; ObTableHandle memtable_handle; - ObITable* last_table = nullptr; + ObITable *last_table = nullptr; if (OB_FAIL(pg_memtable_mgr_->get_active_memtable(memtable_handle))) { if (OB_ENTRY_NOT_EXIST == ret || is_in_source_split) { ret = OB_SUCCESS; @@ -596,9 +595,9 @@ int ObPartitionStore::check_new_table_store( } // max_kept_major_version_number means no need remove old versions -int ObPartitionStore::add_sstable_for_merge(storage::ObSSTable* table, const int64_t max_kept_major_version_number, - const ObMigrateStatus& migrate_status, const bool is_in_restore, const bool is_in_source_split, - const bool is_in_dest_split, ObSSTable* complement_minor_sstable) +int ObPartitionStore::add_sstable_for_merge(storage::ObSSTable *table, const int64_t max_kept_major_version_number, + const ObMigrateStatus &migrate_status, const bool is_in_restore, const bool is_in_source_split, + const bool is_in_dest_split, ObSSTable *complement_minor_sstable) { int ret = OB_SUCCESS; AddTableParam param; @@ -612,8 +611,7 @@ int ObPartitionStore::add_sstable_for_merge(storage::ObSSTable* table, const int LOG_WARN("invalid args", K(ret), K(max_kept_major_version_number), KPC(table)); } else if (is_in_restore) { // do nothing - } else if (OB_FAIL(get_kept_multi_version_start( - is_in_dest_split, param.multi_version_start_, param.backup_snapshot_version_))) { + } else if (OB_FAIL(get_kept_multi_version_start(is_in_dest_split, param.multi_version_start_))) { LOG_WARN("failed to get_kept_multi_version_start", K(ret)); } @@ -642,15 +640,15 @@ int ObPartitionStore::add_sstable_for_merge(storage::ObSSTable* table, const int return ret; } -int ObPartitionStore::set_reference_tables(const uint64_t table_id, ObTablesHandle& handle) +int ObPartitionStore::set_reference_tables(const uint64_t table_id, ObTablesHandle &handle) { int ret = OB_SUCCESS; bool tmp_ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; - ObMultiVersionTableStore* multi_version_store = NULL; - ObTableStore* new_table_store = NULL; + ObMultiVersionTableStore *multi_version_store = NULL; + ObTableStore *new_table_store = NULL; bool need_update = false; - memtable::ObMemtable* active_memtable = NULL; + memtable::ObMemtable *active_memtable = NULL; ObTableHandle memtable_handle; TCWLockGuard lock_guard(lock_); @@ -715,22 +713,22 @@ int ObPartitionStore::set_reference_tables(const uint64_t table_id, ObTablesHand } // caller must help lock_ -int ObPartitionStore::create_multi_version_store(const uint64_t table_id, ObMultiVersionTableStore*& out_table_store) +int ObPartitionStore::create_multi_version_store(const uint64_t table_id, ObMultiVersionTableStore *&out_table_store) { return create_multi_version_store_(table_id, 0, out_table_store); } int ObPartitionStore::create_multi_version_store( - const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore*& out_table_store) + const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore *&out_table_store) { return create_multi_version_store_(table_id, schema_version, out_table_store); } int ObPartitionStore::create_multi_version_store_( - const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore*& out_table_store) + const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore *&out_table_store) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* tmp_table_store = NULL; + ObMultiVersionTableStore *tmp_table_store = NULL; out_table_store = NULL; if (OB_UNLIKELY(!meta_->is_valid())) { // maybe called in init(), so only check meta @@ -776,12 +774,12 @@ int ObPartitionStore::create_multi_version_store_( } int ObPartitionStore::get_index_status(const int64_t schema_version, const bool is_physical_restore, - common::ObIArray& index_status, - common::ObIArray& deleted_and_error_index_ids) + common::ObIArray &index_status, + common::ObIArray &deleted_and_error_index_ids) { int ret = OB_SUCCESS; share::schema::ObSchemaGetterGuard schema_guard; - share::schema::ObMultiVersionSchemaService& schema_service = + share::schema::ObMultiVersionSchemaService &schema_service = share::schema::ObMultiVersionSchemaService::get_instance(); const bool with_global_index = false; int64_t save_schema_version; @@ -816,12 +814,12 @@ int ObPartitionStore::get_index_status(const int64_t schema_version, const bool LOG_WARN("failed to get full tenant schema guard", K(ret), K(fetch_tenant_id), K(pkey_)); } else if (OB_FAIL(schema_guard.get_schema_version(fetch_tenant_id, latest_schema_version))) { LOG_WARN("failed to get schema version", K(ret), K(fetch_tenant_id), K(pkey_)); - } else if (latest_schema_version > save_schema_version - || (is_physical_restore && latest_schema_version >= save_schema_version)) { + } else if (latest_schema_version > save_schema_version || + (is_physical_restore && latest_schema_version >= save_schema_version)) { // befor check the delete status of index, we should make sure the schema guard is refreshed for (int64_t i = 0; OB_SUCC(ret) && i < index_status.count(); ++i) { - const share::schema::ObTableSchema* table_schema = NULL; - share::schema::ObIndexTableStat& index_stat = index_status.at(i); + const share::schema::ObTableSchema *table_schema = NULL; + share::schema::ObIndexTableStat &index_stat = index_status.at(i); if (OB_FAIL(schema_guard.get_table_schema(index_stat.index_id_, table_schema))) { LOG_WARN("Failed to get table schema", K(ret), K(index_status.at(i))); } else if (NULL == table_schema || share::schema::INDEX_STATUS_INDEX_ERROR == table_schema->get_index_status()) { @@ -841,12 +839,12 @@ int ObPartitionStore::get_index_status(const int64_t schema_version, const bool return ret; } -int ObPartitionStore::check_all_tables_merged(const memtable::ObMemtable& memtable, - const common::ObIArray& index_status, - const common::ObIArray& deleted_index_ids, bool& all_merged, bool& can_release) +int ObPartitionStore::check_all_tables_merged(const memtable::ObMemtable &memtable, + const common::ObIArray &index_status, + const common::ObIArray &deleted_index_ids, bool &all_merged, bool &can_release) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; int64_t least_merged_snapshot_version = -1; int64_t latest_merged_snapshot_version = -1; int64_t least_merged_log_ts = -1; @@ -869,7 +867,7 @@ int ObPartitionStore::check_all_tables_merged(const memtable::ObMemtable& memtab } for (int64_t i = 0; OB_SUCC(ret) && i < index_status.count(); ++i) { - const share::schema::ObIndexTableStat& status = index_status.at(i); + const share::schema::ObIndexTableStat &status = index_status.at(i); bool can_skip = false; if (OB_FAIL(check_skip_check_index_merge_status(status, deleted_index_ids, can_skip))) { LOG_WARN("failed to check_skip_check_index_merge_status", K(ret), K(status)); @@ -935,10 +933,10 @@ int ObPartitionStore::check_all_tables_merged(const memtable::ObMemtable& memtab return ret; } -int ObPartitionStore::create_table_store_if_need(const uint64_t table_id, bool& is_created) +int ObPartitionStore::create_table_store_if_need(const uint64_t table_id, bool &is_created) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -955,7 +953,7 @@ int ObPartitionStore::create_table_store_if_need(const uint64_t table_id, bool& if (OB_HASH_NOT_EXIST == ret) { ret = OB_SUCCESS; TCWLockGuard lock_guard(lock_); - ObMultiVersionTableStore* tmp_table_store = NULL; + ObMultiVersionTableStore *tmp_table_store = NULL; LOG_INFO("create index table store", K(table_id)); is_created = true; if (OB_FAIL(create_multi_version_store(table_id, tmp_table_store))) { @@ -966,8 +964,8 @@ int ObPartitionStore::create_table_store_if_need(const uint64_t table_id, bool& return ret; } -int ObPartitionStore::check_skip_check_index_merge_status(const share::schema::ObIndexTableStat& index_stat, - const common::ObIArray& deleted_index_ids, bool& need_skip) +int ObPartitionStore::check_skip_check_index_merge_status(const share::schema::ObIndexTableStat &index_stat, + const common::ObIArray &deleted_index_ids, bool &need_skip) { int ret = OB_SUCCESS; const uint64_t index_id = index_stat.index_id_; @@ -984,11 +982,11 @@ int ObPartitionStore::check_skip_check_index_merge_status(const share::schema::O } // ObTableHandle *main_table_handle is for index back -int ObPartitionStore::get_read_tables(const uint64_t table_id, const int64_t snapshot_version, ObTablesHandle& handle, +int ObPartitionStore::get_read_tables(const uint64_t table_id, const int64_t snapshot_version, ObTablesHandle &handle, const bool allow_not_ready, const bool need_safety_check, const bool reset_handle, const bool print_dropped_alert) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; if (reset_handle) { handle.reset(); } @@ -1049,10 +1047,10 @@ int ObPartitionStore::get_read_tables(const uint64_t table_id, const int64_t sna } int ObPartitionStore::get_read_frozen_tables( - const uint64_t table_id, const common::ObVersion& frozen_version, ObTablesHandle& handle, const bool reset_handle) + const uint64_t table_id, const common::ObVersion &frozen_version, ObTablesHandle &handle, const bool reset_handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; if (reset_handle) { handle.reset(); } @@ -1078,10 +1076,10 @@ int ObPartitionStore::get_read_frozen_tables( } int ObPartitionStore::get_sample_read_tables( - const common::SampleInfo& sample_info, const uint64_t table_id, ObTablesHandle& handle, const bool reset_handle) + const common::SampleInfo &sample_info, const uint64_t table_id, ObTablesHandle &handle, const bool reset_handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; ObTableHandle memtable_handle; if (reset_handle) { handle.reset(); @@ -1110,10 +1108,10 @@ int ObPartitionStore::get_sample_read_tables( return ret; } -int ObPartitionStore::get_active_protection_clock(int64_t& active_protection_clock) +int ObPartitionStore::get_active_protection_clock(int64_t &active_protection_clock) { int ret = OB_SUCCESS; - memtable::ObMemtable* memtable = NULL; + memtable::ObMemtable *memtable = NULL; ObTableHandle handle; TCRLockGuard guard(lock_); @@ -1132,7 +1130,7 @@ int ObPartitionStore::get_active_protection_clock(int64_t& active_protection_clo return ret; } -int ObPartitionStore::get_active_memtable(ObTableHandle& handle) +int ObPartitionStore::get_active_memtable(ObTableHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -1145,7 +1143,7 @@ int ObPartitionStore::get_active_memtable(ObTableHandle& handle) return ret; } -int ObPartitionStore::get_memtables(ObTablesHandle& handle, const bool reset_handle) +int ObPartitionStore::get_memtables(ObTablesHandle &handle, const bool reset_handle) { int ret = OB_SUCCESS; if (reset_handle) { @@ -1175,16 +1173,16 @@ bool ObPartitionStore::has_active_memtable() return pg_memtable_mgr_->has_active_memtable(); } -int ObPartitionStore::has_major_sstable(const uint64_t index_id, bool& has_major) +int ObPartitionStore::has_major_sstable(const uint64_t index_id, bool &has_major) { TCRLockGuard guard(lock_); return has_major_sstable_nolock(index_id, has_major); } -int ObPartitionStore::has_major_sstable_nolock(const uint64_t index_id, bool& has_major) +int ObPartitionStore::has_major_sstable_nolock(const uint64_t index_id, bool &has_major) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); @@ -1203,7 +1201,7 @@ int ObPartitionStore::has_major_sstable_nolock(const uint64_t index_id, bool& ha return ret; } -int ObPartitionStore::get_all_tables(ObTablesHandle& handle) +int ObPartitionStore::get_all_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -1215,7 +1213,7 @@ int ObPartitionStore::get_all_tables(ObTablesHandle& handle) return ret; } -int ObPartitionStore::get_all_tables_unlock(ObTablesHandle& handle) +int ObPartitionStore::get_all_tables_unlock(ObTablesHandle &handle) { int ret = OB_SUCCESS; ObMultiVersionTableStore::TableSet table_set; @@ -1228,7 +1226,7 @@ int ObPartitionStore::get_all_tables_unlock(ObTablesHandle& handle) LOG_WARN("failed to create table set", K(ret), K(set_bucket_num)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; LOG_ERROR("table store is null", K(ret)); @@ -1256,7 +1254,7 @@ int ObPartitionStore::halt_prewarm() LOG_WARN("the partition has been removed, ", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; LOG_ERROR("table store is null", K(ret)); @@ -1270,14 +1268,14 @@ int ObPartitionStore::halt_prewarm() } int ObPartitionStore::fill_checksum( - const uint64_t index_id, const int sstable_type, share::ObSSTableChecksumItem& checksum) + const uint64_t index_id, const int sstable_type, share::ObSSTableChecksumItem &checksum) { int ret = OB_SUCCESS; - ObSSTable* major_sstable = NULL; + ObSSTable *major_sstable = NULL; bool has_major = false; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; ObTablesHandle table_handle; - ObSSTableDataChecksumItem& data_checksum = checksum.data_checksum_; + ObSSTableDataChecksumItem &data_checksum = checksum.data_checksum_; data_checksum.sstable_id_ = index_id; data_checksum.sstable_type_ = sstable_type; data_checksum.replica_type_ = get_replica_type(); @@ -1306,9 +1304,9 @@ int ObPartitionStore::fill_checksum( data_checksum.data_checksum_ = major_sstable->get_meta().data_checksum_; data_checksum.row_count_ = major_sstable->get_meta().row_count_; data_checksum.snapshot_version_ = snapshot_version; - const ObIArray& column_metas = major_sstable->get_meta().column_metas_; + const ObIArray &column_metas = major_sstable->get_meta().column_metas_; for (int64_t i = 0; OB_SUCC(ret) && i < column_metas.count(); ++i) { - const ObSSTableColumnMeta& column_meta = column_metas.at(i); + const ObSSTableColumnMeta &column_meta = column_metas.at(i); ObSSTableColumnChecksumItem column_checksum; column_checksum.tenant_id_ = extract_tenant_id(index_id); column_checksum.data_table_id_ = meta_->data_table_id_; @@ -1338,12 +1336,12 @@ int ObPartitionStore::fill_checksum( LOG_WARN("fail to get latest tables", K(ret)); } else { for (int64_t i = tables_handle.get_count() - 1; OB_SUCC(ret) && i >= 0; --i) { - ObITable* table = tables_handle.get_tables().at(i); + ObITable *table = tables_handle.get_tables().at(i); if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("error unexpected, table must not be NULL", K(ret)); } else if (table->is_minor_sstable() && table->get_snapshot_version() == snapshot_version) { - ObSSTable* minor_sstable = static_cast(table); + ObSSTable *minor_sstable = static_cast(table); if (minor_sstable->get_key().table_type_ == sstable_type) { data_checksum.row_checksum_ = minor_sstable->get_meta().row_checksum_; data_checksum.data_checksum_ = minor_sstable->get_meta().data_checksum_; @@ -1368,14 +1366,14 @@ int ObPartitionStore::fill_checksum( return ret; } -int ObPartitionStore::calc_report_status(ObReportStatus& status) +int ObPartitionStore::calc_report_status(ObReportStatus &status) { int ret = OB_SUCCESS; ObTableHandle main_handle; - ObSSTable* main_sstable = NULL; + ObSSTable *main_sstable = NULL; ObTablesHandle all_tables_handle; const int64_t macro_block_size = OB_FILE_SYSTEM.get_macro_block_size(); - ObMultiVersionTableStore* data_table_store = NULL; + ObMultiVersionTableStore *data_table_store = NULL; int64_t last_index_id = 0; TCRLockGuard guard(lock_); @@ -1414,7 +1412,7 @@ int ObPartitionStore::calc_report_status(ObReportStatus& status) ret = OB_ERR_SYS; LOG_ERROR("main_sstable must not null", K(ret)); } else { - const blocksstable::ObSSTableMeta& meta = main_sstable->get_meta(); + const blocksstable::ObSSTableMeta &meta = main_sstable->get_meta(); status.data_version_ = main_sstable->get_version(); status.row_count_ = meta.row_count_; status.row_checksum_ = meta.row_checksum_; @@ -1430,12 +1428,12 @@ int ObPartitionStore::calc_report_status(ObReportStatus& status) status.required_size_ = 0; const int64_t table_cnt = all_tables_handle.get_count(); for (int64_t i = 0; OB_SUCC(ret) && i < table_cnt; ++i) { - ObITable* table = all_tables_handle.get_tables().at(i); + ObITable *table = all_tables_handle.get_tables().at(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); } else if (table->is_major_sstable()) { - const blocksstable::ObSSTableMeta& meta = static_cast(table)->get_meta(); + const blocksstable::ObSSTableMeta &meta = static_cast(table)->get_meta(); if (meta.data_version_ == status.data_version_) { status.data_size_ += meta.occupy_size_; } @@ -1456,7 +1454,7 @@ int ObPartitionStore::calc_report_status(ObReportStatus& status) return ret; } -int ObPartitionStore::get_all_table_ids(common::ObIArray& index_tables) +int ObPartitionStore::get_all_table_ids(common::ObIArray &index_tables) { int ret = OB_SUCCESS; index_tables.reset(); @@ -1467,7 +1465,7 @@ int ObPartitionStore::get_all_table_ids(common::ObIArray& index_tables LOG_WARN("not inited", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_FAIL(index_tables.push_back(table_store->get_table_id()))) { LOG_WARN("failed to add merge index table ids", K(ret)); } @@ -1476,7 +1474,7 @@ int ObPartitionStore::get_all_table_ids(common::ObIArray& index_tables return ret; } -int ObPartitionStore::get_all_table_stats(common::ObIArray& index_tables) +int ObPartitionStore::get_all_table_stats(common::ObIArray &index_tables) { int ret = OB_SUCCESS; index_tables.reset(); @@ -1488,7 +1486,7 @@ int ObPartitionStore::get_all_table_stats(common::ObIArray& inde } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { TableStoreStat stat; - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; stat.index_id_ = table_store->get_table_id(); stat.has_dropped_flag_ = table_store->is_dropped_schema(); if (OB_FAIL(index_tables.push_back(stat))) { @@ -1499,10 +1497,10 @@ int ObPartitionStore::get_all_table_stats(common::ObIArray& inde return ret; } -int ObPartitionStore::get_reference_tables(int64_t table_id, ObTablesHandle& handle) +int ObPartitionStore::get_reference_tables(int64_t table_id, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { @@ -1521,7 +1519,7 @@ int ObPartitionStore::get_reference_tables(int64_t table_id, ObTablesHandle& han int ObPartitionStore::get_merge_table_ids(const ObMergeType merge_type, const bool using_remote_memstore, const bool is_in_dest_split, const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, - common::ObVersion& frozen_version, common::ObIArray& index_tables, bool& need_merge) + common::ObVersion &frozen_version, common::ObIArray &index_tables, bool &need_merge) { int ret = OB_SUCCESS; bool is_complete = true; @@ -1585,8 +1583,8 @@ int ObPartitionStore::get_merge_table_ids(const ObMergeType merge_type, const bo return ret; } -int ObPartitionStore::get_major_merge_table_ids(const int64_t save_slave_read_version, common::ObVersion& merge_version, - common::ObIArray& index_tables, bool& need_merge) +int ObPartitionStore::get_major_merge_table_ids(const int64_t save_slave_read_version, common::ObVersion &merge_version, + common::ObIArray &index_tables, bool &need_merge) { int ret = OB_SUCCESS; bool can_merge = false; @@ -1603,7 +1601,7 @@ int ObPartitionStore::get_major_merge_table_ids(const int64_t save_slave_read_ve } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { bool tmp_need_merge = false; - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_FAIL( check_need_major_merge(table_store, save_slave_read_version, merge_version, tmp_need_merge, can_merge))) { LOG_WARN("failed to check_need_major_merge", K(ret)); @@ -1632,7 +1630,7 @@ int ObPartitionStore::get_major_merge_table_ids(const int64_t save_slave_read_ve } int ObPartitionStore::get_minor_merge_table_ids( - const bool using_remote_memstore, const ObMergeType merge_type, common::ObIArray& index_tables) + const bool using_remote_memstore, const ObMergeType merge_type, common::ObIArray &index_tables) { int ret = OB_SUCCESS; index_tables.reset(); @@ -1644,7 +1642,7 @@ int ObPartitionStore::get_minor_merge_table_ids( bool need_merge = false; for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_FAIL(check_need_minor_merge(table_store->get_table_id(), need_merge))) { LOG_WARN("Failed to check need mini minor merge", K(ret), KPC(table_store)); } else if (!need_merge) { @@ -1661,8 +1659,8 @@ int ObPartitionStore::get_minor_merge_table_ids( } int ObPartitionStore::get_mini_merge_table_ids(const int64_t save_slave_read_version, const ObMergeType merge_type, - const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, common::ObIArray& index_tables, - bool& need_merge) + const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, common::ObIArray &index_tables, + bool &need_merge) { int ret = OB_SUCCESS; bool can_merge = false; @@ -1676,7 +1674,7 @@ int ObPartitionStore::get_mini_merge_table_ids(const int64_t save_slave_read_ver LOG_DEBUG("has no memtable, cannot get minor merge version", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_FAIL(check_need_mini_merge(table_store, merge_type, save_slave_read_version, @@ -1700,7 +1698,7 @@ int ObPartitionStore::get_mini_merge_table_ids(const int64_t save_slave_read_ver return ret; } -int ObPartitionStore::get_migrate_table_ids(common::ObIArray& table_ids) +int ObPartitionStore::get_migrate_table_ids(common::ObIArray &table_ids) { int ret = OB_SUCCESS; @@ -1710,7 +1708,7 @@ int ObPartitionStore::get_migrate_table_ids(common::ObIArray& table_id LOG_WARN("not inited", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table id should not be null here", K(ret)); @@ -1723,7 +1721,7 @@ int ObPartitionStore::get_migrate_table_ids(common::ObIArray& table_id return ret; } -int ObPartitionStore::is_physical_split_finished(bool& is_physical_split_finish) +int ObPartitionStore::is_physical_split_finished(bool &is_physical_split_finish) { int ret = OB_SUCCESS; is_physical_split_finish = true; @@ -1735,7 +1733,7 @@ int ObPartitionStore::is_physical_split_finished(bool& is_physical_split_finish) LOG_WARN("not inited", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* multi_version_table_store = it->second; + ObMultiVersionTableStore *multi_version_table_store = it->second; if (OB_ISNULL(multi_version_table_store)) { ret = OB_ERR_SYS; @@ -1757,11 +1755,11 @@ int ObPartitionStore::is_physical_split_finished(bool& is_physical_split_finish) return ret; } -int ObPartitionStore::get_physical_split_info(ObVirtualPartitionSplitInfo& split_info) +int ObPartitionStore::get_physical_split_info(ObVirtualPartitionSplitInfo &split_info) { int ret = OB_SUCCESS; TCRLockGuard lock_guard(lock_); - ObMultiVersionTableStore* data_table_store = get_data_table_store(); + ObMultiVersionTableStore *data_table_store = get_data_table_store(); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1781,10 +1779,10 @@ int ObPartitionStore::get_physical_split_info(ObVirtualPartitionSplitInfo& split } int ObPartitionStore::check_need_split( - const int64_t& index_id, common::ObVersion& split_version, bool& need_split, bool& need_minor_split) + const int64_t &index_id, common::ObVersion &split_version, bool &need_split, bool &need_minor_split) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { @@ -1801,7 +1799,7 @@ int ObPartitionStore::check_need_split( return ret; } -int ObPartitionStore::check_can_migrate(bool& can_migrate) +int ObPartitionStore::check_can_migrate(bool &can_migrate) { int ret = OB_SUCCESS; can_migrate = true; @@ -1812,7 +1810,7 @@ int ObPartitionStore::check_can_migrate(bool& can_migrate) LOG_WARN("not inited", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* multi_version_table_store = it->second; + ObMultiVersionTableStore *multi_version_table_store = it->second; if (OB_ISNULL(multi_version_table_store)) { ret = OB_ERR_SYS; @@ -1831,7 +1829,7 @@ int ObPartitionStore::check_can_migrate(bool& can_migrate) } int ObPartitionStore::get_split_table_ids( - common::ObVersion& split_version, bool is_major_split, common::ObIArray& index_tables) + common::ObVersion &split_version, bool is_major_split, common::ObIArray &index_tables) { int ret = OB_SUCCESS; bool need_split = false; @@ -1851,7 +1849,7 @@ int ObPartitionStore::get_split_table_ids( LOG_INFO("store is not complete, needs to wait", K_(pkey)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_UNEXPECTED; } else if (OB_FAIL(table_store->check_need_split(split_version, need_split, need_minor_split))) { @@ -1871,13 +1869,13 @@ int ObPartitionStore::get_split_table_ids( return ret; } -int ObPartitionStore::check_need_major_merge(ObMultiVersionTableStore* table_store, - const int64_t save_slave_read_version, ObVersion& merge_version, bool& need_merge, bool& can_merge) +int ObPartitionStore::check_need_major_merge(ObMultiVersionTableStore *table_store, + const int64_t save_slave_read_version, ObVersion &merge_version, bool &need_merge, bool &can_merge) { int ret = OB_SUCCESS; ObTablesHandle handle; - ObITable* latest_major_sstable = NULL; - ObITable* latest_minor_sstable = NULL; + ObITable *latest_major_sstable = NULL; + ObITable *latest_minor_sstable = NULL; ObFreezeInfoSnapshotMgr::FreezeInfoLite freeze_info; common::ObVersion major_sstable_version; common::ObVersion split_version; @@ -1898,7 +1896,7 @@ int ObPartitionStore::check_need_major_merge(ObMultiVersionTableStore* table_sto // find max major sstable for (int64_t i = 0; OB_SUCC(ret) && i < handle.get_count(); ++i) { - ObITable* tmp = handle.get_table(i); + ObITable *tmp = handle.get_table(i); if (OB_ISNULL(tmp)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); @@ -1953,15 +1951,15 @@ int ObPartitionStore::check_need_major_merge(ObMultiVersionTableStore* table_sto return ret; } -int ObPartitionStore::check_need_mini_merge(ObMultiVersionTableStore* table_store, const ObMergeType merge_type, +int ObPartitionStore::check_need_mini_merge(ObMultiVersionTableStore *table_store, const ObMergeType merge_type, const int64_t safe_slave_read_version, const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, - bool& need_merge, bool& can_merge) + bool &need_merge, bool &can_merge) { int ret = OB_SUCCESS; ObTablesHandle handle; - ObITable* latest_sstable = nullptr; - ObMemtable* first_frozen_memtable = nullptr; - ObMemtable* last_frozen_memtable = nullptr; + ObITable *latest_sstable = nullptr; + ObMemtable *first_frozen_memtable = nullptr; + ObMemtable *last_frozen_memtable = nullptr; ObGetMergeTablesParam param; ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite freeze_info; @@ -1982,7 +1980,7 @@ int ObPartitionStore::check_need_mini_merge(ObMultiVersionTableStore* table_stor LOG_WARN("failed to get_latest_tables", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < handle.get_count(); ++i) { - ObITable* tmp = handle.get_table(i); + ObITable *tmp = handle.get_table(i); if (OB_ISNULL(tmp)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); @@ -1993,9 +1991,9 @@ int ObPartitionStore::check_need_mini_merge(ObMultiVersionTableStore* table_stor latest_sstable = tmp; } else if (tmp->is_frozen_memtable()) { if (OB_ISNULL(first_frozen_memtable)) { - first_frozen_memtable = static_cast(tmp); + first_frozen_memtable = static_cast(tmp); } - last_frozen_memtable = static_cast(tmp); + last_frozen_memtable = static_cast(tmp); } } @@ -2065,10 +2063,10 @@ int ObPartitionStore::check_need_mini_merge(ObMultiVersionTableStore* table_stor return ret; } -int ObPartitionStore::check_need_minor_merge(const uint64_t table_id, bool& need_merge) +int ObPartitionStore::check_need_minor_merge(const uint64_t table_id, bool &need_merge) { int ret = OB_SUCCESS; - share::schema::ObMultiVersionSchemaService& schema_service = + share::schema::ObMultiVersionSchemaService &schema_service = share::schema::ObMultiVersionSchemaService::get_instance(); ObTablesHandle handle; bool is_exist = true; @@ -2085,14 +2083,13 @@ int ObPartitionStore::check_need_minor_merge(const uint64_t table_id, bool& need return ret; } -int ObPartitionStore::get_merge_tables(const ObGetMergeTablesParam& param, ObGetMergeTablesResult& result) +int ObPartitionStore::get_merge_tables(const ObGetMergeTablesParam ¶m, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; int64_t min_reserved_snapshot = 0; int64_t min_merged_version = INT64_MAX; ObTableHandle handle; - int64_t backup_snapshot_version = 0; TCRLockGuard guard(lock_); ObTableHandle memtable_handle; @@ -2118,11 +2115,8 @@ int ObPartitionStore::get_merge_tables(const ObGetMergeTablesParam& param, ObGet if (OB_SUCC(ret)) { if (OB_FAIL(get_min_merged_version_(min_merged_version))) { LOG_WARN("failed to get_min_merged_version_", K(ret), K(pkey_)); - } else if (OB_FAIL(ObFreezeInfoMgrWrapper::get_instance().get_min_reserved_snapshot(pkey_, - min_merged_version, - meta_->create_schema_version_, - min_reserved_snapshot, - backup_snapshot_version))) { + } else if (OB_FAIL(ObFreezeInfoMgrWrapper::get_instance().get_min_reserved_snapshot( + pkey_, min_merged_version, meta_->create_schema_version_, min_reserved_snapshot))) { LOG_WARN("failed to get min reserved snapshot", K(ret), K(pkey_)); } else if (OB_FAIL(table_store->get_merge_tables(param, min_reserved_snapshot, result))) { LOG_WARN("failed to get merge tables", K(ret), K(param), K(*this)); @@ -2134,10 +2128,10 @@ int ObPartitionStore::get_merge_tables(const ObGetMergeTablesParam& param, ObGet return ret; } -int ObPartitionStore::get_split_tables(const bool is_major_split, const uint64_t index_id, ObTablesHandle& handle) +int ObPartitionStore::get_split_tables(const bool is_major_split, const uint64_t index_id, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { @@ -2161,10 +2155,10 @@ int ObPartitionStore::get_split_tables(const bool is_major_split, const uint64_t // for merge/backup/migrate int ObPartitionStore::get_major_sstable( - const uint64_t index_id, const common::ObVersion& merge_version, ObTablesHandle& handle) + const uint64_t index_id, const common::ObVersion &merge_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { @@ -2184,10 +2178,10 @@ int ObPartitionStore::get_major_sstable( return ret; } -int ObPartitionStore::get_last_major_sstable(const uint64_t index_id, ObTableHandle& handle) +int ObPartitionStore::get_last_major_sstable(const uint64_t index_id, ObTableHandle &handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { @@ -2211,7 +2205,7 @@ int ObPartitionStore::get_last_major_sstable(const uint64_t index_id, ObTableHan return ret; } -int ObPartitionStore::get_last_all_major_sstable(ObTablesHandle& handle) +int ObPartitionStore::get_last_all_major_sstable(ObTablesHandle &handle) { int ret = OB_SUCCESS; TCRLockGuard guard(lock_); @@ -2222,7 +2216,7 @@ int ObPartitionStore::get_last_all_major_sstable(ObTablesHandle& handle) for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { ObTableHandle tmp_handle; bool is_ready_for_read = false; - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; LOG_ERROR("table store must not null", K(ret)); @@ -2247,8 +2241,7 @@ int ObPartitionStore::remove_old_table(const int64_t frozen_version) int ret = OB_SUCCESS; int64_t multi_version_start = 0; const bool is_in_dest_split = false; - int64_t backup_snapshot_verison = 0; - ObSEArray stores; + ObSEArray stores; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -2256,7 +2249,7 @@ int ObPartitionStore::remove_old_table(const int64_t frozen_version) } else if (is_removed_) { ret = OB_PARTITION_IS_REMOVED; LOG_WARN("the partition has been removed, ", K(ret)); - } else if (OB_FAIL(get_kept_multi_version_start(is_in_dest_split, multi_version_start, backup_snapshot_verison))) { + } else if (OB_FAIL(get_kept_multi_version_start(is_in_dest_split, multi_version_start))) { LOG_WARN("failed to get_kept_multi_version_start", K(ret)); } else { int64_t kept_major_num = GCONF.max_kept_major_version_number; @@ -2267,7 +2260,7 @@ int ObPartitionStore::remove_old_table(const int64_t frozen_version) { TCRLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; LOG_ERROR("table_store must not null", K(ret)); @@ -2277,8 +2270,7 @@ int ObPartitionStore::remove_old_table(const int64_t frozen_version) } } for (int64_t i = 0; OB_SUCC(ret) && i < stores.count(); ++i) { - if (OB_FAIL(remove_old_table_( - kept_min_version, multi_version_start, kept_major_num, backup_snapshot_verison, *stores.at(i)))) { + if (OB_FAIL(remove_old_table_(kept_min_version, multi_version_start, kept_major_num, *stores.at(i)))) { LOG_WARN("faile to remove_old_table_", K(ret), K(pkey_)); } } @@ -2287,8 +2279,8 @@ int ObPartitionStore::remove_old_table(const int64_t frozen_version) return ret; } -int ObPartitionStore::remove_old_table_(const common::ObVersion& kept_min_version, const int64_t multi_version_start, - const int64_t kept_major_num, const int64_t backup_snapshot_version, ObMultiVersionTableStore& table_store) +int ObPartitionStore::remove_old_table_(const common::ObVersion &kept_min_version, const int64_t multi_version_start, + const int64_t kept_major_num, ObMultiVersionTableStore &table_store) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -2301,12 +2293,12 @@ int ObPartitionStore::remove_old_table_(const common::ObVersion& kept_min_versio ret = OB_NOT_INIT; LOG_WARN("not inited", K(ret)); } else if (OB_FAIL(table_store.need_remove_old_table( - kept_min_version, multi_version_start, backup_snapshot_version, real_kept_major_num, need_remove))) { + kept_min_version, multi_version_start, real_kept_major_num, need_remove))) { LOG_WARN("failed to need_remove_old_table", K(ret)); } if (OB_SUCC(ret) && need_remove) { - ObTableStore* new_table_store = NULL; + ObTableStore *new_table_store = NULL; AddTableParam param; param.table_ = NULL; @@ -2315,7 +2307,6 @@ int ObPartitionStore::remove_old_table_(const common::ObVersion& kept_min_versio param.in_slog_trans_ = false; param.need_prewarm_ = true; param.is_daily_merge_ = false; - param.backup_snapshot_version_ = backup_snapshot_version; if (param.multi_version_start_ < meta_->multi_version_start_) { ret = OB_INVALID_ARGUMENT; @@ -2382,7 +2373,7 @@ int ObPartitionStore::retire_prewarm_store(const bool is_disk_full) } for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; LOG_ERROR("table_store must not null", K(ret)); @@ -2410,8 +2401,8 @@ int64_t ObPartitionStore::get_serialize_size() serialize_size += meta_->get_serialize_size(); serialize_size += serialization::encoded_length_i64(table_store_count); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCCESS == tmp_ret && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* multi_table_store = it->second; - ObTableStore* table_store = NULL; + ObMultiVersionTableStore *multi_table_store = it->second; + ObTableStore *table_store = NULL; if (OB_ISNULL(multi_table_store)) { tmp_ret = OB_ERR_SYS; @@ -2432,7 +2423,7 @@ int64_t ObPartitionStore::get_serialize_size() return serialize_size; } -int ObPartitionStore::serialize(common::ObIAllocator& allocator, char*& new_buf, int64_t& serialize_size) +int ObPartitionStore::serialize(common::ObIAllocator &allocator, char *&new_buf, int64_t &serialize_size) { int ret = OB_SUCCESS; int64_t need_size = 0; @@ -2447,7 +2438,7 @@ int ObPartitionStore::serialize(common::ObIAllocator& allocator, char*& new_buf, } else if (0 >= (need_size = get_serialize_size())) { ret = OB_ERR_SYS; LOG_WARN("failed to get_serialize_need_size", K(ret)); - } else if (OB_ISNULL(new_buf = static_cast(allocator.alloc(need_size)))) { + } else if (OB_ISNULL(new_buf = static_cast(allocator.alloc(need_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc buf", K(ret), K(need_size)); } else if (OB_FAIL(serialization::encode_i64(new_buf, need_size, serialize_size, MAGIC_NUM_2))) { @@ -2464,8 +2455,8 @@ int ObPartitionStore::serialize(common::ObIAllocator& allocator, char*& new_buf, LOG_WARN("failed to encode table count", K(ret)); } for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* multi_table_store = it->second; - ObTableStore* table_store = NULL; + ObMultiVersionTableStore *multi_table_store = it->second; + ObTableStore *table_store = NULL; if (OB_ISNULL(multi_table_store)) { ret = OB_ERR_SYS; @@ -2504,9 +2495,9 @@ int ObPartitionStore::serialize(common::ObIAllocator& allocator, char*& new_buf, return ret; } -int ObPartitionStore::deserialize(ObIPartitionGroup* pg, ObPGMemtableMgr* pg_memtable_mgr, - const ObReplicaType replica_type, const char* buf, const int64_t buf_len, int64_t& pos, bool& is_old_meta, - ObPartitionStoreMeta& old_meta) +int ObPartitionStore::deserialize(ObIPartitionGroup *pg, ObPGMemtableMgr *pg_memtable_mgr, + const ObReplicaType replica_type, const char *buf, const int64_t buf_len, int64_t &pos, bool &is_old_meta, + ObPartitionStoreMeta &old_meta) { int ret = OB_SUCCESS; int64_t magic_num = 0; @@ -2581,7 +2572,7 @@ int ObPartitionStore::deserialize(ObIPartitionGroup* pg, ObPGMemtableMgr* pg_mem return ret; } -int ObPartitionStore::write_create_partition_store_log(const ObPGPartitionStoreMeta& meta) +int ObPartitionStore::write_create_partition_store_log(const ObPGPartitionStoreMeta &meta) { int ret = OB_SUCCESS; ObCreatePGPartitionStoreLogEntry log_entry; @@ -2604,7 +2595,7 @@ int ObPartitionStore::write_create_partition_store_log(const ObPGPartitionStoreM return ret; } -int ObPartitionStore::write_update_partition_meta_trans(const ObPGPartitionStoreMeta& meta, const LogCommand& cmd) +int ObPartitionStore::write_update_partition_meta_trans(const ObPGPartitionStoreMeta &meta, const LogCommand &cmd) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -2644,7 +2635,7 @@ int ObPartitionStore::write_update_partition_meta_trans(const ObPGPartitionStore return ret; } -int ObPartitionStore::write_modify_table_store_log(ObTableStore& table_store, const int64_t multi_version_start) +int ObPartitionStore::write_modify_table_store_log(ObTableStore &table_store, const int64_t multi_version_start) { int ret = OB_SUCCESS; ObModifyTableStoreLogEntry log_entry(table_store); @@ -2671,7 +2662,7 @@ int ObPartitionStore::write_modify_table_store_log(ObTableStore& table_store, co return ret; } -int ObPartitionStore::write_drop_index_trans(const common::ObPartitionKey& pkey, const uint64_t index_id) +int ObPartitionStore::write_drop_index_trans(const common::ObPartitionKey &pkey, const uint64_t index_id) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -2711,14 +2702,14 @@ int ObPartitionStore::write_drop_index_trans(const common::ObPartitionKey& pkey, return ret; } -int ObPartitionStore::get_effective_tables(const uint64_t table_id, ObTablesHandle& handle, bool& is_ready_for_read) +int ObPartitionStore::get_effective_tables(const uint64_t table_id, ObTablesHandle &handle, bool &is_ready_for_read) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; handle.reset(); ObTableHandle memtable_handle; - memtable::ObMemtable* memtable = NULL; - ObITable* last_table = NULL; + memtable::ObMemtable *memtable = NULL; + ObITable *last_table = NULL; is_ready_for_read = false; TCRLockGuard guard(lock_); @@ -2774,12 +2765,12 @@ int ObPartitionStore::get_effective_tables(const uint64_t table_id, ObTablesHand return ret; } -int ObPartitionStore::get_gc_sstables(const uint64_t table_id, ObTablesHandle& handle) +int ObPartitionStore::get_gc_sstables(const uint64_t table_id, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; handle.reset(); - ObITable* last_table = NULL; + ObITable *last_table = NULL; TCRLockGuard guard(lock_); @@ -2807,10 +2798,10 @@ int ObPartitionStore::get_gc_sstables(const uint64_t table_id, ObTablesHandle& h return ret; } -int ObPartitionStore::get_replay_tables(const uint64_t table_id, ObIArray& replay_tables) +int ObPartitionStore::get_replay_tables(const uint64_t table_id, ObIArray &replay_tables) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; replay_tables.reset(); TCRLockGuard guard(lock_); @@ -2840,7 +2831,7 @@ int ObPartitionStore::get_replay_tables(const uint64_t table_id, ObIArraybegin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; LOG_ERROR("table store is null", K(ret)); @@ -2909,7 +2900,7 @@ int ObPartitionStore::finish_replay() return ret; } -int ObPartitionStore::get_meta(ObPGPartitionStoreMeta& meta) +int ObPartitionStore::get_meta(ObPGPartitionStoreMeta &meta) { int ret = OB_SUCCESS; @@ -2923,7 +2914,7 @@ int ObPartitionStore::get_meta(ObPGPartitionStoreMeta& meta) return ret; } -int ObPartitionStore::check_need_report(const common::ObVersion& version, bool& need_report) +int ObPartitionStore::check_need_report(const common::ObVersion &version, bool &need_report) { int ret = OB_SUCCESS; TCRLockGuard guard(lock_); @@ -2936,7 +2927,7 @@ int ObPartitionStore::check_need_report(const common::ObVersion& version, bool& return ret; } -int ObPartitionStore::check_major_merge_finished(const common::ObVersion& version, bool& finished) +int ObPartitionStore::check_major_merge_finished(const common::ObVersion &version, bool &finished) { int ret = OB_SUCCESS; ObTablesHandle tables_handle; @@ -2950,7 +2941,7 @@ int ObPartitionStore::check_major_merge_finished(const common::ObVersion& versio } else { finished = true; for (int64_t i = 0; OB_SUCC(ret) && i < tables_handle.get_count() && finished; ++i) { - ObITable* table = tables_handle.get_tables().at(i); + ObITable *table = tables_handle.get_tables().at(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; STORAGE_LOG(WARN, "error sys, table must not be NULL", K(ret)); @@ -2963,10 +2954,10 @@ int ObPartitionStore::check_major_merge_finished(const common::ObVersion& versio } int ObPartitionStore::write_report_status( - const ObReportStatus& status, const uint64_t data_table_id, const bool write_slog) + const ObReportStatus &status, const uint64_t data_table_id, const bool write_slog) { int ret = OB_SUCCESS; - ObPGPartitionStoreMeta& meta = get_next_meta(); + ObPGPartitionStoreMeta &meta = get_next_meta(); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -2993,7 +2984,7 @@ int ObPartitionStore::write_report_status( int ObPartitionStore::update_multi_version_start(const int64_t multi_version_start) { int ret = OB_SUCCESS; - ObPGPartitionStoreMeta& meta = get_next_meta(); + ObPGPartitionStoreMeta &meta = get_next_meta(); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -3038,10 +3029,10 @@ int ObPartitionStore::try_update_report_status(const uint64_t data_table_id, con return ret; } -int ObPartitionStore::check_ready_for_read(const uint64_t table_id, bool& is_ready) +int ObPartitionStore::check_ready_for_read(const uint64_t table_id, bool &is_ready) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); is_ready = false; @@ -3060,7 +3051,7 @@ int ObPartitionStore::check_ready_for_read(const uint64_t table_id, bool& is_rea return ret; } -int ObPartitionStore::replay_modify_table_store(const ObModifyTableStoreLogEntry& log_entry) +int ObPartitionStore::replay_modify_table_store(const ObModifyTableStoreLogEntry &log_entry) { int ret = OB_SUCCESS; TCWLockGuard guard(lock_); @@ -3082,10 +3073,10 @@ int ObPartitionStore::replay_modify_table_store(const ObModifyTableStoreLogEntry return ret; } -int ObPartitionStore::set_table_store(const ObTableStore& table_store) +int ObPartitionStore::set_table_store(const ObTableStore &table_store) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* multi_table_store = NULL; + ObMultiVersionTableStore *multi_table_store = NULL; const uint64_t table_id = table_store.get_table_id(); int64_t table_count = 0; @@ -3130,7 +3121,7 @@ int64_t ObPartitionStore::get_multi_version_start() return meta_->multi_version_start_; } -int ObPartitionStore::get_partition_store_info(ObPartitionStoreInfo& info) +int ObPartitionStore::get_partition_store_info(ObPartitionStoreInfo &info) { int ret = OB_SUCCESS; TCRLockGuard guard(lock_); @@ -3146,7 +3137,7 @@ int ObPartitionStore::get_partition_store_info(ObPartitionStoreInfo& info) return ret; } -int ObPartitionStore::get_first_frozen_memtable(ObTableHandle& handle) +int ObPartitionStore::get_first_frozen_memtable(ObTableHandle &handle) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -3160,15 +3151,15 @@ int ObPartitionStore::get_first_frozen_memtable(ObTableHandle& handle) return ret; } -ObMultiVersionTableStore* ObPartitionStore::alloc_multi_version_table_store(const uint64_t tenant_id) +ObMultiVersionTableStore *ObPartitionStore::alloc_multi_version_table_store(const uint64_t tenant_id) { ObMemAttr attr(tenant_id, ObModIds::OB_PARTITION_STORE, ObCtxIds::STORAGE_LONG_TERM_META_CTX_ID); - ObMultiVersionTableStore* store = OB_NEW_ALIGN32(ObMultiVersionTableStore, attr); + ObMultiVersionTableStore *store = OB_NEW_ALIGN32(ObMultiVersionTableStore, attr); LOG_INFO("alloc_multi_version_table_store", KP(store), K(lbt())); return store; } -void ObPartitionStore::free_multi_version_table_store(ObMultiVersionTableStore*& table_store) +void ObPartitionStore::free_multi_version_table_store(ObMultiVersionTableStore *&table_store) { if (NULL != table_store) { LOG_INFO("free_multi_version_table_store", KP(table_store), K(lbt())); @@ -3177,8 +3168,7 @@ void ObPartitionStore::free_multi_version_table_store(ObMultiVersionTableStore*& } } -int ObPartitionStore::get_kept_multi_version_start( - const bool is_in_dest_split, int64_t& multi_version_start, int64_t& backup_snapshot_version) +int ObPartitionStore::get_kept_multi_version_start(const bool is_in_dest_split, int64_t &multi_version_start) { int ret = OB_SUCCESS; multi_version_start = 0; @@ -3209,11 +3199,8 @@ int ObPartitionStore::get_kept_multi_version_start( } } if (OB_SUCC(ret)) { - if (OB_FAIL(ObFreezeInfoMgrWrapper::get_instance().get_min_reserved_snapshot(pkey_, - min_merged_version, - meta_->create_schema_version_, - min_reserved_snapshot, - backup_snapshot_version))) { + if (OB_FAIL(ObFreezeInfoMgrWrapper::get_instance().get_min_reserved_snapshot( + pkey_, min_merged_version, meta_->create_schema_version_, min_reserved_snapshot))) { LOG_WARN("failed to get_kept_multi_version_start", K(ret), K(pkey_)); } } @@ -3231,8 +3218,8 @@ int ObPartitionStore::get_kept_multi_version_start( return ret; } -int ObPartitionStore::check_all_merged(memtable::ObMemtable& memtable, const int64_t schema_version, - const bool is_physical_restore, bool& is_all_merged, bool& can_release) +int ObPartitionStore::check_all_merged(memtable::ObMemtable &memtable, const int64_t schema_version, + const bool is_physical_restore, bool &is_all_merged, bool &can_release) { int ret = OB_SUCCESS; is_all_merged = false; @@ -3282,7 +3269,7 @@ int ObPartitionStore::remove_uncontinues_inc_tables(const uint64_t table_id) { int ret = OB_SUCCESS; ObTablesHandle handle; - ObMultiVersionTableStore* multi_table_store = NULL; + ObMultiVersionTableStore *multi_table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "not inited", K(ret)); @@ -3305,13 +3292,13 @@ int ObPartitionStore::remove_uncontinues_inc_tables(const uint64_t table_id) return ret; } -int ObPartitionStore::update_split_table_store(int64_t table_id, bool is_major_split, ObTablesHandle& handle) +int ObPartitionStore::update_split_table_store(int64_t table_id, bool is_major_split, ObTablesHandle &handle) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; - ObMultiVersionTableStore* multi_version_store = NULL; + ObMultiVersionTableStore *multi_version_store = NULL; bool need_update = false; - ObTableStore* new_table_store = NULL; + ObTableStore *new_table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -3356,7 +3343,7 @@ int ObPartitionStore::update_split_table_store(int64_t table_id, bool is_major_s return ret; } -int ObPartitionStore::get_create_schema_version(int64_t& create_schema_version) +int ObPartitionStore::get_create_schema_version(int64_t &create_schema_version) { int ret = OB_SUCCESS; TCRLockGuard lock_guard(lock_); @@ -3370,14 +3357,14 @@ int ObPartitionStore::get_create_schema_version(int64_t& create_schema_version) return ret; } -int ObPartitionStore::inner_remove_uncontinues_inc_tables(ObMultiVersionTableStore* multi_table_store) +int ObPartitionStore::inner_remove_uncontinues_inc_tables(ObMultiVersionTableStore *multi_table_store) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; const int64_t max_kept_major_version_number = 0; const bool in_slog_trans = false; - ObTableStore* new_table_store = NULL; + ObTableStore *new_table_store = NULL; bool is_equal = true; bool need_abort_slog = false; int64_t lsn = 0; @@ -3452,7 +3439,7 @@ int ObPartitionStore::inner_remove_uncontinues_inc_tables(ObMultiVersionTableSto return ret; } -int ObPartitionStore::get_report_status(ObReportStatus& status) +int ObPartitionStore::get_report_status(ObReportStatus &status) { int ret = OB_SUCCESS; TCRLockGuard lock_guard(lock_); @@ -3472,13 +3459,13 @@ int64_t ObPartitionStore::get_readable_ts_() const } int ObPartitionStore::get_major_frozen_versions( - const ObVersion& data_version, int64_t& publish_version, int64_t& schema_version) + const ObVersion &data_version, int64_t &publish_version, int64_t &schema_version) { int ret = OB_SUCCESS; ObTablesHandle handle; schema_version = -1; publish_version = -1; - ObITable* table = NULL; + ObITable *table = NULL; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("partition store is not inited", K(ret)); @@ -3501,7 +3488,7 @@ int ObPartitionStore::get_major_frozen_versions( return ret; } -int ObPartitionStore::get_min_sstable_version(int64_t& min_sstable_snapshot_version) +int ObPartitionStore::get_min_sstable_version(int64_t &min_sstable_snapshot_version) { int ret = OB_SUCCESS; ObTablesHandle handle; @@ -3512,7 +3499,7 @@ int ObPartitionStore::get_min_sstable_version(int64_t& min_sstable_snapshot_vers LOG_WARN("failed to get read tables", K(ret), K_(pkey)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < handle.get_count(); i++) { - ObITable* table = handle.get_table(i); + ObITable *table = handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_WARN("table should not be null", K(ret)); @@ -3537,12 +3524,12 @@ int64_t ObPartitionStore::get_table_store_cnt() const return store_map_->size(); } -int ObPartitionStore::get_data_table_latest_sstables(ObTablesHandle& handle) +int ObPartitionStore::get_data_table_latest_sstables(ObTablesHandle &handle) { int ret = OB_SUCCESS; TCRLockGuard lock_guard(lock_); - ObMultiVersionTableStore* data_table_store = nullptr; - ObTableStore* latest_table_store = nullptr; + ObMultiVersionTableStore *data_table_store = nullptr; + ObTableStore *latest_table_store = nullptr; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("partition store is not inited", K(ret)); @@ -3559,10 +3546,10 @@ int ObPartitionStore::get_data_table_latest_sstables(ObTablesHandle& handle) } int ObPartitionStore::set_replay_sstables( - const uint64_t table_id, const bool is_replay_old, ObIArray& sstables) + const uint64_t table_id, const bool is_replay_old, ObIArray &sstables) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -3588,12 +3575,12 @@ int ObPartitionStore::set_replay_sstables( return ret; } -int ObPartitionStore::get_max_major_sstable_snapshot(int64_t& max_snapshot_version) +int ObPartitionStore::get_max_major_sstable_snapshot(int64_t &max_snapshot_version) { int ret = OB_SUCCESS; max_snapshot_version = 0; int64_t snapshot_version = 0; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { @@ -3611,14 +3598,14 @@ int ObPartitionStore::get_max_major_sstable_snapshot(int64_t& max_snapshot_versi return ret; } -int ObPartitionStore::get_min_max_major_version(int64_t& min_version, int64_t& max_version) +int ObPartitionStore::get_min_max_major_version(int64_t &min_version, int64_t &max_version) { int ret = OB_SUCCESS; min_version = INT64_MAX; max_version = INT64_MIN; int64_t tmp_min_version = 0; int64_t tmp_max_version = 0; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { table_store = it->second; @@ -3635,7 +3622,7 @@ int ObPartitionStore::get_min_max_major_version(int64_t& min_version, int64_t& m return ret; } -int ObPartitionStore::check_store_complete_(bool& is_complete) +int ObPartitionStore::check_store_complete_(bool &is_complete) { int ret = OB_SUCCESS; is_complete = true; @@ -3645,7 +3632,7 @@ int ObPartitionStore::check_store_complete_(bool& is_complete) LOG_WARN("not inited", K(ret)); } else { for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* multi_version_table_store = it->second; + ObMultiVersionTableStore *multi_version_table_store = it->second; if (OB_ISNULL(multi_version_table_store)) { ret = OB_ERR_SYS; @@ -3664,15 +3651,15 @@ int ObPartitionStore::check_store_complete_(bool& is_complete) } // lock_ must be held before calling this method -int ObPartitionStore::get_min_merged_version_(int64_t& min_merged_version) +int ObPartitionStore::get_min_merged_version_(int64_t &min_merged_version) { int ret = OB_SUCCESS; ObTableHandle tmp_handle; min_merged_version = -1; int64_t tmp_min_merged_version = INT64_MAX; for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; - ObSSTable* sstable = nullptr; + ObMultiVersionTableStore *table_store = it->second; + ObSSTable *sstable = nullptr; tmp_handle.reset(); if (OB_ISNULL(table_store)) { ret = OB_ERR_SYS; @@ -3698,10 +3685,10 @@ int ObPartitionStore::get_min_merged_version_(int64_t& min_merged_version) return ret; } -int ObPartitionStore::get_latest_minor_sstables(const int64_t index_id, ObTablesHandle& handle) +int ObPartitionStore::get_latest_minor_sstables(const int64_t index_id, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; handle.reset(); if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -3727,7 +3714,7 @@ int ObPartitionStore::get_latest_minor_sstables(const int64_t index_id, ObTables return ret; } -int ObPartitionStore::physical_flashback(const int64_t flashback_scn, ObVersion& data_version) +int ObPartitionStore::physical_flashback(const int64_t flashback_scn, ObVersion &data_version) { int ret = OB_SUCCESS; ObArray table_ids; @@ -3744,7 +3731,7 @@ int ObPartitionStore::physical_flashback(const int64_t flashback_scn, ObVersion& } else { for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) { const uint64_t table_id = table_ids.at(i); - ObMultiVersionTableStore* multi_table_store = NULL; + ObMultiVersionTableStore *multi_table_store = NULL; const bool is_data_table = table_id == pkey_.get_table_id(); if (OB_FAIL(store_map_->get(table_id, multi_table_store))) { if (OB_HASH_NOT_EXIST != ret) { @@ -3788,14 +3775,14 @@ int ObPartitionStore::physical_flashback(const int64_t flashback_scn, ObVersion& } int ObPartitionStore::get_mark_deletion_tables( - const uint64_t index_id, const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle& handle) + const uint64_t index_id, const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; if (IS_NOT_INIT) { ret = OB_NOT_INIT; LOG_WARN("ob_partition_store is not inited", K(ret)); } else { - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; TCRLockGuard lock_guard(lock_); if (OB_FAIL(store_map_->get(index_id, table_store))) { LOG_WARN("failed to multi version table store", K(ret), K(index_id), K_(pkey)); @@ -3806,7 +3793,7 @@ int ObPartitionStore::get_mark_deletion_tables( return ret; } -int ObPartitionStore::get_all_latest_minor_sstables(ObTablesHandle& handle) +int ObPartitionStore::get_all_latest_minor_sstables(ObTablesHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -3816,7 +3803,7 @@ int ObPartitionStore::get_all_latest_minor_sstables(ObTablesHandle& handle) } else { TCRLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; const int64_t index_id = it->first; if (OB_ISNULL(table_store)) { ret = OB_ERR_UNEXPECTED; @@ -3829,13 +3816,13 @@ int ObPartitionStore::get_all_latest_minor_sstables(ObTablesHandle& handle) return ret; } -int ObPartitionStore::scan_trans_table(const ObTableIterParam& iter_param, ObTableAccessContext& access_context, - const ObExtStoreRange& whole_range, ObStoreRowIterator*& row_iter) +int ObPartitionStore::scan_trans_table(const ObTableIterParam &iter_param, ObTableAccessContext &access_context, + const ObExtStoreRange &whole_range, ObStoreRowIterator *&row_iter) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* data_table_store = nullptr; + ObMultiVersionTableStore *data_table_store = nullptr; ObTableHandle handle; - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; row_iter = NULL; TCRLockGuard lock_guard(lock_); @@ -3862,21 +3849,21 @@ int ObPartitionStore::scan_trans_table(const ObTableIterParam& iter_param, ObTab return ret; } -int ObPartitionStore::check_store_complete(bool& is_complete) +int ObPartitionStore::check_store_complete(bool &is_complete) { TCRLockGuard lock_guard(lock_); return check_store_complete_(is_complete); } int ObPartitionStore::inner_physical_flashback( - const bool is_data_table, const int64_t flashback_scn, ObMultiVersionTableStore* multi_table_store) + const bool is_data_table, const int64_t flashback_scn, ObMultiVersionTableStore *multi_table_store) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; const int64_t max_kept_major_version_number = 0; const bool in_slog_trans = false; - ObTableStore* new_table_store = NULL; + ObTableStore *new_table_store = NULL; bool is_equal = true; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -3911,7 +3898,7 @@ int ObPartitionStore::inner_physical_flashback( meta_->multi_version_start_ = 0; } else if (!is_equal) { TCWLockGuard guard(lock_); - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; if (OB_FAIL(multi_table_store->enable_table_store(param.need_prewarm_, *new_table_store))) { LOG_WARN("failed to enable table store", K(ret), K(param)); } else if (OB_FAIL(major_sstables_handle.get_first_sstable(sstable))) { @@ -3937,12 +3924,12 @@ int ObPartitionStore::inner_physical_flashback( return ret; } -int ObPartitionStore::get_trans_table_end_log_ts_and_timestamp(int64_t& end_log_ts, int64_t& timestamp) +int ObPartitionStore::get_trans_table_end_log_ts_and_timestamp(int64_t &end_log_ts, int64_t ×tamp) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; ObTableHandle handle; - ObSSTable* table = nullptr; + ObSSTable *table = nullptr; TCRLockGuard lock_guard(lock_); if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -3973,7 +3960,7 @@ int ObPartitionStore::clear_complement_minor_sstable() } else { TCWLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; const int64_t index_id = it->first; if (OB_ISNULL(table_store)) { ret = OB_ERR_UNEXPECTED; @@ -3986,7 +3973,7 @@ int ObPartitionStore::clear_complement_minor_sstable() return ret; } -int ObPartitionStore::get_min_schema_version(int64_t& min_schema_version) +int ObPartitionStore::get_min_schema_version(int64_t &min_schema_version) { int ret = OB_SUCCESS; int64_t tmp_schema_version = 0; @@ -3997,7 +3984,7 @@ int ObPartitionStore::get_min_schema_version(int64_t& min_schema_version) } else { TCRLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; const int64_t index_id = it->first; if (OB_ISNULL(table_store)) { ret = OB_ERR_UNEXPECTED; @@ -4012,12 +3999,12 @@ int ObPartitionStore::get_min_schema_version(int64_t& min_schema_version) return ret; } -int ObPartitionStore::get_physical_flashback_publish_version(const int64_t flashback_scn, int64_t& publish_version) +int ObPartitionStore::get_physical_flashback_publish_version(const int64_t flashback_scn, int64_t &publish_version) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* multi_table_store = NULL; + ObMultiVersionTableStore *multi_table_store = NULL; ObTablesHandle table_handle; - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; publish_version = 0; if (IS_NOT_INIT) { @@ -4054,9 +4041,7 @@ int ObPartitionStore::remove_unneed_store_within_trans(const TableStoreMap &new_ int ret = OB_SUCCESS; ObMultiVersionTableStore *table_store = nullptr; TCRLockGuard lock_guard(lock_); - for (TableStoreMap::iterator it = store_map_->begin(); - OB_SUCC(ret) && it != store_map_->end(); - ++it) { + for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { const int64_t index_id = it->second->get_table_id(); if (OB_SUCC(new_store_map.get(index_id, table_store))) { // exist in new table store map @@ -4064,8 +4049,8 @@ int ObPartitionStore::remove_unneed_store_within_trans(const TableStoreMap &new_ LOG_WARN("Failed to get table store", K(ret), K(index_id)); } else { int64_t subcmd = ObIRedoModule::gen_subcmd(OB_REDO_LOG_PARTITION, REDO_LOG_DROP_INDEX_SSTABLE_OF_STORE); - const ObStorageLogAttribute log_attr(pg_memtable_mgr_->get_pkey().get_tenant_id(), - pg_->get_pg_storage().get_storage_file()->get_file_id()); + const ObStorageLogAttribute log_attr( + pg_memtable_mgr_->get_pkey().get_tenant_id(), pg_->get_pg_storage().get_storage_file()->get_file_id()); ObDropIndexSSTableLogEntry log_entry; log_entry.pkey_ = meta_->pkey_; log_entry.index_id_ = index_id; @@ -4091,7 +4076,7 @@ void ObPartitionStore::replace_store_map(TableStoreMap &store_map) destroy_store_map(cur_store_map); } -int ObPartitionStore::create_new_store_map_(TableStoreMap*& new_store_map) +int ObPartitionStore::create_new_store_map_(TableStoreMap *&new_store_map) { int ret = OB_SUCCESS; new_store_map = nullptr; @@ -4111,8 +4096,8 @@ int ObPartitionStore::create_new_store_map_(TableStoreMap*& new_store_map) } // !!!Attention!!! this function only used in migration -int ObPartitionStore::prepare_new_store_map(const ObTablesHandle& sstables, const int64_t max_kept_major_version_number, - const bool need_reuse_local_minor, TableStoreMap*& new_store_map) +int ObPartitionStore::prepare_new_store_map(const ObTablesHandle &sstables, const int64_t max_kept_major_version_number, + const bool need_reuse_local_minor, TableStoreMap *&new_store_map) { int ret = OB_SUCCESS; ObTablesHandle tmp_handle; @@ -4139,9 +4124,9 @@ int ObPartitionStore::prepare_new_store_map(const ObTablesHandle& sstables, cons } else { ObTablesHandle index_handle; for (int64_t i = 0; OB_SUCC(ret) && i <= tmp_handle.get_count(); ++i) { - ObMultiVersionTableStore* multi_version_table_store = nullptr; - ObITable* last_table = 0 == i ? nullptr : tmp_handle.get_table(i - 1); - ObITable* cur_table = i < tmp_handle.get_count() ? tmp_handle.get_table(i) : nullptr; + ObMultiVersionTableStore *multi_version_table_store = nullptr; + ObITable *last_table = 0 == i ? nullptr : tmp_handle.get_table(i - 1); + ObITable *cur_table = i < tmp_handle.get_count() ? tmp_handle.get_table(i) : nullptr; bool added = false; if (i > 0 && OB_ISNULL(last_table)) { ret = OB_ERR_SYS; @@ -4173,7 +4158,7 @@ int ObPartitionStore::prepare_new_store_map(const ObTablesHandle& sstables, cons } } if (OB_SUCC(ret) && !index_handle.empty()) { - ObMultiVersionTableStore* multi_version_table_store = nullptr; + ObMultiVersionTableStore *multi_version_table_store = nullptr; if (OB_FAIL(prepare_new_table_store_( index_handle, max_kept_major_version_number, need_reuse_local_minor, multi_version_table_store))) { LOG_WARN("failed to prepare new table store", K(ret), K(index_handle)); @@ -4197,10 +4182,10 @@ int ObPartitionStore::prepare_new_store_map(const ObTablesHandle& sstables, cons return ret; } -int ObPartitionStore::get_table_schema_version(const uint64_t table_id, int64_t& schema_version) +int ObPartitionStore::get_table_schema_version(const uint64_t table_id, int64_t &schema_version) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; TCRLockGuard lock_guard(lock_); if (OB_FAIL(store_map_->get(table_id, table_store))) { LOG_WARN("failed to get table store", K(ret), K(table_id)); @@ -4214,7 +4199,7 @@ int ObPartitionStore::get_table_schema_version(const uint64_t table_id, int64_t& } int ObPartitionStore::get_remote_table_info_( - const ObTablesHandle& index_handle, const bool need_reuse_local_minor, ObMigrateRemoteTableInfo& remote_table_info) + const ObTablesHandle &index_handle, const bool need_reuse_local_minor, ObMigrateRemoteTableInfo &remote_table_info) { int ret = OB_SUCCESS; if (need_reuse_local_minor) { @@ -4224,7 +4209,7 @@ int ObPartitionStore::get_remote_table_info_( remote_table_info.reset(); remote_table_info.need_reuse_local_minor_ = false; for (int64_t i = 0; OB_SUCC(ret) && i < index_handle.get_count(); ++i) { - const ObITable* table = index_handle.get_table(i); + const ObITable *table = index_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_WARN("table should not be null", K(ret)); @@ -4239,9 +4224,9 @@ int ObPartitionStore::get_remote_table_info_( } // !!!Attention!!! this function only used in migration -int ObPartitionStore::prepare_new_table_store_(ObTablesHandle& index_handle, +int ObPartitionStore::prepare_new_table_store_(ObTablesHandle &index_handle, const int64_t max_kept_major_version_number, const bool need_reuse_local_minor, - ObMultiVersionTableStore*& multi_version_table_store) + ObMultiVersionTableStore *&multi_version_table_store) { int ret = OB_SUCCESS; multi_version_table_store = nullptr; @@ -4263,8 +4248,7 @@ int ObPartitionStore::prepare_new_table_store_(ObTablesHandle& index_handle, // do nothing // no need get kept multi version start } else if (OB_FAIL(get_kept_multi_version_start(false, /*is_split*/ - param.multi_version_start_, - param.backup_snapshot_version_))) { + param.multi_version_start_))) { LOG_WARN("failed to get_kept_multi_version_start", K(ret), K(param)); } @@ -4281,8 +4265,8 @@ int ObPartitionStore::prepare_new_table_store_(ObTablesHandle& index_handle, } else { bool is_equal = false; const bool need_prewarm = false; - ObMultiVersionTableStore* cur_mv_table_store = nullptr; - ObTableStore* new_table_store = nullptr; + ObMultiVersionTableStore *cur_mv_table_store = nullptr; + ObTableStore *new_table_store = nullptr; { TCRLockGuard lock_guard(lock_); if (OB_FAIL(store_map_->get(index_id, cur_mv_table_store))) { @@ -4293,7 +4277,7 @@ int ObPartitionStore::prepare_new_table_store_(ObTablesHandle& index_handle, } else if (OB_FAIL(cur_mv_table_store->get_needed_local_tables_for_migrate(remote_table_info, tables_handle))) { LOG_WARN("failed to get_major_sstables_after_start", K(ret), K(index_id), K(pkey_)); } else { - ObITable* table = nullptr; + ObITable *table = nullptr; for (int64_t i = 0; OB_SUCC(ret) && i < index_handle.get_count(); i++) { if (OB_ISNULL(table = index_handle.get_table(i))) { ret = OB_ERR_SYS; @@ -4301,7 +4285,7 @@ int ObPartitionStore::prepare_new_table_store_(ObTablesHandle& index_handle, } else if (table->is_complement_minor_sstable()) { // table ref is holded by index_handle // migrate complement_minor_sstable should ignore data - param.complement_minor_sstable_ = static_cast(table); + param.complement_minor_sstable_ = static_cast(table); } else if (OB_FAIL(tables_handle.add_table(table))) { LOG_WARN("Failed to add table to new table handle", K(ret), KPC(table), K(tables_handle)); } @@ -4338,12 +4322,12 @@ int ObPartitionStore::prepare_new_table_store_(ObTablesHandle& index_handle, return ret; } -int ObPartitionStore::get_trans_table_status(ObTransTableStatus& status) +int ObPartitionStore::get_trans_table_status(ObTransTableStatus &status) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* data_table_store = nullptr; + ObMultiVersionTableStore *data_table_store = nullptr; ObTableHandle handle; - ObSSTable* sstable = NULL; + ObSSTable *sstable = NULL; TCRLockGuard lock_guard(lock_); if (IS_NOT_INIT) { ret = OB_NOT_INIT; @@ -4369,10 +4353,10 @@ int ObPartitionStore::get_trans_table_status(ObTransTableStatus& status) return ret; } -int ObPartitionStore::get_latest_table_count(const int64_t table_id, int64_t& table_count) +int ObPartitionStore::get_latest_table_count(const int64_t table_id, int64_t &table_count) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { @@ -4389,10 +4373,10 @@ int ObPartitionStore::get_latest_table_count(const int64_t table_id, int64_t& ta return ret; } -int ObPartitionStore::get_migrate_tables(const uint64_t table_id, ObTablesHandle& handle, bool& is_ready_for_read) +int ObPartitionStore::get_migrate_tables(const uint64_t table_id, ObTablesHandle &handle, bool &is_ready_for_read) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; handle.reset(); is_ready_for_read = false; @@ -4424,7 +4408,7 @@ int ObPartitionStore::get_migrate_tables(const uint64_t table_id, ObTablesHandle } int ObPartitionStore::get_restore_point_tables(const int64_t snapshot_version, const int64_t publish_version, - ObRecoveryPointSchemaFilter& schema_filter, ObTablesHandle& handle, bool& is_ready) + ObRecoveryPointSchemaFilter &schema_filter, ObTablesHandle &handle, bool &is_ready) { int ret = OB_SUCCESS; is_ready = true; @@ -4444,7 +4428,7 @@ int ObPartitionStore::get_restore_point_tables(const int64_t snapshot_version, c } int ObPartitionStore::filter_read_sstables( - const ObTablesHandle& tmp_handle, const int64_t snapshot_version, ObTablesHandle& handle, bool& is_ready) + const ObTablesHandle &tmp_handle, const int64_t snapshot_version, ObTablesHandle &handle, bool &is_ready) { int ret = OB_SUCCESS; handle.reset(); @@ -4466,7 +4450,7 @@ int ObPartitionStore::filter_read_sstables( int ObPartitionStore::set_drop_schema_info(const int64_t index_id, const int64_t schema_version) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -4483,10 +4467,10 @@ int ObPartitionStore::set_drop_schema_info(const int64_t index_id, const int64_t } int ObPartitionStore::get_drop_schema_info( - const int64_t index_id, int64_t& drop_schema_version, int64_t& drop_schema_refreshed_ts) + const int64_t index_id, int64_t &drop_schema_version, int64_t &drop_schema_refreshed_ts) { int ret = OB_SUCCESS; - ObMultiVersionTableStore* table_store = nullptr; + ObMultiVersionTableStore *table_store = nullptr; TCRLockGuard guard(lock_); if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -4503,7 +4487,7 @@ int ObPartitionStore::get_drop_schema_info( } int ObPartitionStore::get_restore_point_trans_tables_( - const int64_t snapshot_version, ObTablesHandle& handle, bool& is_ready) + const int64_t snapshot_version, ObTablesHandle &handle, bool &is_ready) { int ret = OB_SUCCESS; ObTablesHandle tmp_handles; @@ -4518,7 +4502,7 @@ int ObPartitionStore::get_restore_point_trans_tables_( is_ready = false; } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_handles.get_count(); ++i) { - ObITable* table = tmp_handles.get_table(i); + ObITable *table = tmp_handles.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be NULL", K(ret), KP(table)); @@ -4535,7 +4519,7 @@ int ObPartitionStore::get_restore_point_trans_tables_( } int ObPartitionStore::get_restore_point_normal_tables_(const int64_t snapshot_version, const int64_t publish_version, - ObRecoveryPointSchemaFilter& schema_filter, ObTablesHandle& handle, bool& is_ready) + ObRecoveryPointSchemaFilter &schema_filter, ObTablesHandle &handle, bool &is_ready) { int ret = OB_SUCCESS; is_ready = true; @@ -4550,7 +4534,7 @@ int ObPartitionStore::get_restore_point_normal_tables_(const int64_t snapshot_ve ObArray index_tables; TCRLockGuard lock_guard(lock_); for (TableStoreMap::iterator it = store_map_->begin(); OB_SUCC(ret) && it != store_map_->end(); ++it) { - ObMultiVersionTableStore* table_store = it->second; + ObMultiVersionTableStore *table_store = it->second; const uint64_t index_id = table_store->get_table_id(); if (OB_FAIL(index_tables.push_back(table_store->get_table_id()))) { LOG_WARN("failed to add merge index table ids", K(ret)); @@ -4567,7 +4551,7 @@ int ObPartitionStore::get_restore_point_normal_tables_(const int64_t snapshot_ve const uint64_t index_id = index_tables.at(i); ObTablesHandle tmp_handle; ObTablesHandle new_handle; - ObMultiVersionTableStore* table_store = NULL; + ObMultiVersionTableStore *table_store = NULL; if (OB_FAIL(store_map_->get(index_id, table_store))) { LOG_WARN("failed to get table store", K(ret), K(index_id)); } else if (OB_ISNULL(table_store)) { diff --git a/src/storage/ob_partition_store.h b/src/storage/ob_partition_store.h index 91454c4a5464caee6291ba8500ebd6fef052fbb5..3b05d81efdef318fdb3f842d79c49142c80b2bf0 100644 --- a/src/storage/ob_partition_store.h +++ b/src/storage/ob_partition_store.h @@ -66,8 +66,8 @@ class ObPartitionStore { friend class ObPartitionStorage; public: - typedef common::hash::ObCuckooHashMap TableStoreMap; - typedef TableStoreMap* TableStoreMapPtr; + typedef common::hash::ObCuckooHashMap TableStoreMap; + typedef TableStoreMap *TableStoreMapPtr; static const int64_t TABLE_STORE_BUCKET_NUM = 2; static const int64_t MAX_KETP_VERSION_SHIFT_NUM = 6L; static const int64_t MAX_KETP_VERSION_NUM = 1LL << MAX_KETP_VERSION_SHIFT_NUM; @@ -84,237 +84,236 @@ public: common::ObReplicaType get_replica_type() const; // common::ObReplicaProperty get_replica_property() const; - int get_read_tables(const uint64_t table_id, const int64_t snapshot_version, ObTablesHandle& handle, + int get_read_tables(const uint64_t table_id, const int64_t snapshot_version, ObTablesHandle &handle, const bool allow_not_ready = false, const bool need_safety_check = false, const bool reset_handle = true, const bool print_dropped_alert = true); template - int get_read_tables(const T1 table_id, const T2 snapshot_version, ObTablesHandle& handle, - ObTablesHandle* main_table_major_sstable_handle = NULL) = delete; - int get_read_frozen_tables(const uint64_t table_id, const common::ObVersion& frozen_version, ObTablesHandle& handle, + int get_read_tables(const T1 table_id, const T2 snapshot_version, ObTablesHandle &handle, + ObTablesHandle *main_table_major_sstable_handle = NULL) = delete; + int get_read_frozen_tables(const uint64_t table_id, const common::ObVersion &frozen_version, ObTablesHandle &handle, const bool reset_handle = true); - int get_sample_read_tables(const common::SampleInfo& sample_info, const uint64_t table_id, ObTablesHandle& handle, + int get_sample_read_tables(const common::SampleInfo &sample_info, const uint64_t table_id, ObTablesHandle &handle, const bool reset_handle = true); - int get_effective_tables(const uint64_t table_id, ObTablesHandle& handle, bool& is_ready_for_read); - int get_gc_sstables(const uint64_t table_id, ObTablesHandle& handle); + int get_effective_tables(const uint64_t table_id, ObTablesHandle &handle, bool &is_ready_for_read); + int get_gc_sstables(const uint64_t table_id, ObTablesHandle &handle); - int get_all_tables(ObTablesHandle& handle); - int get_active_memtable(ObTableHandle& handle); - int get_memtables(ObTablesHandle& handle, const bool reset_handle = true); + int get_all_tables(ObTablesHandle &handle); + int get_active_memtable(ObTableHandle &handle); + int get_memtables(ObTablesHandle &handle, const bool reset_handle = true); bool has_memtable(); bool has_active_memtable(); - int has_major_sstable(const uint64_t index_table_id, bool& has_major); + int has_major_sstable(const uint64_t index_table_id, bool &has_major); bool is_freezing() const { return ATOMIC_LOAD(&is_freezing_); } - int fill_checksum(const uint64_t index_id, const int sstable_type, share::ObSSTableChecksumItem& checksum); + int fill_checksum(const uint64_t index_id, const int sstable_type, share::ObSSTableChecksumItem &checksum); - int get_all_table_ids(common::ObIArray& index_tables); - int get_all_table_stats(common::ObIArray& index_tables); - int get_reference_tables(int64_t table_id, ObTablesHandle& handle); + int get_all_table_ids(common::ObIArray &index_tables); + int get_all_table_stats(common::ObIArray &index_tables); + int get_reference_tables(int64_t table_id, ObTablesHandle &handle); int get_merge_table_ids(const ObMergeType merge_type, const bool using_remote_memstore, const bool is_in_dest_split, - const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, common::ObVersion& merge_version, - common::ObIArray& index_tables, bool& need_merge); - int is_physical_split_finished(bool& is_finish); - int get_physical_split_info(ObVirtualPartitionSplitInfo& split_info); + const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, common::ObVersion &merge_version, + common::ObIArray &index_tables, bool &need_merge); + int is_physical_split_finished(bool &is_finish); + int get_physical_split_info(ObVirtualPartitionSplitInfo &split_info); int check_need_split( - const int64_t& index_id, common::ObVersion& split_version, bool& need_split, bool& need_minor_split); - int check_can_migrate(bool& can_migrate); + const int64_t &index_id, common::ObVersion &split_version, bool &need_split, bool &need_minor_split); + int check_can_migrate(bool &can_migrate); int get_split_table_ids( - common::ObVersion& split_version, bool is_minor_split, common::ObIArray& index_tables); + common::ObVersion &split_version, bool is_minor_split, common::ObIArray &index_tables); - int get_merge_tables(const ObGetMergeTablesParam& param, ObGetMergeTablesResult& result); - int get_split_tables(const bool is_major_split, const uint64_t index_id, ObTablesHandle& handle); + int get_merge_tables(const ObGetMergeTablesParam ¶m, ObGetMergeTablesResult &result); + int get_split_tables(const bool is_major_split, const uint64_t index_id, ObTablesHandle &handle); // for merge/backup/migrate - int get_major_sstable(const uint64_t index_id, const common::ObVersion& merge_version, ObTablesHandle& handle); - int get_last_major_sstable(const uint64_t index_id, ObTableHandle& handle); - int get_last_all_major_sstable(ObTablesHandle& handle); - int get_data_table_latest_sstables(ObTablesHandle& handle); + int get_major_sstable(const uint64_t index_id, const common::ObVersion &merge_version, ObTablesHandle &handle); + int get_last_major_sstable(const uint64_t index_id, ObTableHandle &handle); + int get_last_all_major_sstable(ObTablesHandle &handle); + int get_data_table_latest_sstables(ObTablesHandle &handle); - int get_migrate_table_ids(common::ObIArray& table_ids); + int get_migrate_table_ids(common::ObIArray &table_ids); OB_INLINE common::ObPartitionKey get_partition_key() const; - int get_meta(ObPGPartitionStoreMeta& meta); + int get_meta(ObPGPartitionStoreMeta &meta); - int check_ready_for_read(const uint64_t table_id, bool& is_raedy); - int check_major_merge_finished(const common::ObVersion& version, bool& finished); - int check_need_report(const common::ObVersion& version, bool& need_report); - int check_all_merged(memtable::ObMemtable& memtable, const int64_t schema_version, const bool is_physical_restore, - bool& is_all_merged, bool& can_release); + int check_ready_for_read(const uint64_t table_id, bool &is_raedy); + int check_major_merge_finished(const common::ObVersion &version, bool &finished); + int check_need_report(const common::ObVersion &version, bool &need_report); + int check_all_merged(memtable::ObMemtable &memtable, const int64_t schema_version, const bool is_physical_restore, + bool &is_all_merged, bool &can_release); int64_t get_multi_version_start(); - int get_replay_tables(const uint64_t table_id, ObIArray& replay_tables); - int set_replay_sstables(const uint64_t table_id, const bool is_replay_old, ObIArray& sstables); - - int get_first_frozen_memtable(ObTableHandle& handle); - int check_table_store_exist(const uint64_t index_id, bool& exist); - int get_major_frozen_versions(const ObVersion& data_version, int64_t& publish_version, int64_t& schema_version); - int get_create_schema_version(int64_t& create_schema_version); - int get_min_sstable_version(int64_t& min_sstable_snapshot_version); - int get_min_max_major_version(int64_t& min_version, int64_t& max_version); - int get_latest_minor_sstables(const int64_t index_id, ObTablesHandle& handle); - int get_all_latest_minor_sstables(ObTablesHandle& handle); - int scan_trans_table(const ObTableIterParam& iter_param, ObTableAccessContext& access_context, - const ObExtStoreRange& whole_range, ObStoreRowIterator*& row_iter); - int get_max_major_sstable_snapshot(int64_t& max_snapshot_version); - int physical_flashback(const int64_t flashback_scn, ObVersion& data_version); - int check_store_complete(bool& is_complete); + int get_replay_tables(const uint64_t table_id, ObIArray &replay_tables); + int set_replay_sstables(const uint64_t table_id, const bool is_replay_old, ObIArray &sstables); + + int get_first_frozen_memtable(ObTableHandle &handle); + int check_table_store_exist(const uint64_t index_id, bool &exist); + int get_major_frozen_versions(const ObVersion &data_version, int64_t &publish_version, int64_t &schema_version); + int get_create_schema_version(int64_t &create_schema_version); + int get_min_sstable_version(int64_t &min_sstable_snapshot_version); + int get_min_max_major_version(int64_t &min_version, int64_t &max_version); + int get_latest_minor_sstables(const int64_t index_id, ObTablesHandle &handle); + int get_all_latest_minor_sstables(ObTablesHandle &handle); + int scan_trans_table(const ObTableIterParam &iter_param, ObTableAccessContext &access_context, + const ObExtStoreRange &whole_range, ObStoreRowIterator *&row_iter); + int get_max_major_sstable_snapshot(int64_t &max_snapshot_version); + int physical_flashback(const int64_t flashback_scn, ObVersion &data_version); + int check_store_complete(bool &is_complete); int get_mark_deletion_tables( - const uint64_t index_id, const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle& handle); - int get_trans_table_end_log_ts_and_timestamp(int64_t& end_log_ts, int64_t& timestamp); + const uint64_t index_id, const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle &handle); + int get_trans_table_end_log_ts_and_timestamp(int64_t &end_log_ts, int64_t ×tamp); int clear_complement_minor_sstable(); int64_t get_table_store_cnt() const; - int get_physical_flashback_publish_version(const int64_t flashback_scn, int64_t& publish_version); - int get_min_schema_version(int64_t& min_schema_version); + int get_physical_flashback_publish_version(const int64_t flashback_scn, int64_t &publish_version); + int get_min_schema_version(int64_t &min_schema_version); int get_restore_point_tables(const int64_t snapshot_version, const int64_t publish_version, - ObRecoveryPointSchemaFilter& schema_filter, ObTablesHandle& handle, bool& is_ready); - int get_latest_table_count(const int64_t table_id, int64_t& table_count); + ObRecoveryPointSchemaFilter &schema_filter, ObTablesHandle &handle, bool &is_ready); + int get_latest_table_count(const int64_t table_id, int64_t &table_count); - int get_table_schema_version(const uint64_t table_id, int64_t& schema_version); - int get_trans_table_status(ObTransTableStatus& status); - int get_migrate_tables(const uint64_t table_id, ObTablesHandle& handle, bool& is_ready_for_read); + int get_table_schema_version(const uint64_t table_id, int64_t &schema_version); + int get_trans_table_status(ObTransTableStatus &status); + int get_migrate_tables(const uint64_t table_id, ObTablesHandle &handle, bool &is_ready_for_read); int set_drop_schema_info(const int64_t index_id, const int64_t schema_version); - int get_drop_schema_info(const int64_t index_id, int64_t& drop_schema_version, int64_t& drop_schema_refreshed_ts); + int get_drop_schema_info(const int64_t index_id, int64_t &drop_schema_version, int64_t &drop_schema_refreshed_ts); TO_STRING_KV(K_(is_inited), K_(log_seq_num), "meta", *meta_); private: - int create_partition_store(const ObPGPartitionStoreMeta& meta, const bool write_slog, ObIPartitionGroup* pg, - ObFreezeInfoSnapshotMgr& freeze_info_mgr, ObPGMemtableMgr* pg_memtable_mgr); - int init(const ObPGPartitionStoreMeta& meta, ObIPartitionGroup* pg, ObFreezeInfoSnapshotMgr& freeze_info_mgr); - int create_multi_version_store(const uint64_t table_id, ObMultiVersionTableStore*& table_store); + int create_partition_store(const ObPGPartitionStoreMeta &meta, const bool write_slog, ObIPartitionGroup *pg, + ObFreezeInfoSnapshotMgr &freeze_info_mgr, ObPGMemtableMgr *pg_memtable_mgr); + int init(const ObPGPartitionStoreMeta &meta, ObIPartitionGroup *pg, ObFreezeInfoSnapshotMgr &freeze_info_mgr); + int create_multi_version_store(const uint64_t table_id, ObMultiVersionTableStore *&table_store); int create_multi_version_store( - const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore*& table_store); + const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore *&table_store); int create_multi_version_store_( - const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore*& table_store); - int get_all_tables_unlock(ObTablesHandle& handle); - int get_major_merge_table_ids(const int64_t save_slave_read_version, common::ObVersion& merge_version, - common::ObIArray& index_tables, bool& need_merge); + const uint64_t table_id, const int64_t schema_version, ObMultiVersionTableStore *&table_store); + int get_all_tables_unlock(ObTablesHandle &handle); + int get_major_merge_table_ids(const int64_t save_slave_read_version, common::ObVersion &merge_version, + common::ObIArray &index_tables, bool &need_merge); int get_minor_merge_table_ids( - const bool using_remote_memstore, const ObMergeType merge_type, common::ObIArray& index_tables); + const bool using_remote_memstore, const ObMergeType merge_type, common::ObIArray &index_tables); int get_mini_merge_table_ids(const int64_t save_slave_read_version, const ObMergeType merge_type, const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, - common::ObIArray& index_tables, bool& need_merge); - int check_need_mini_merge(ObMultiVersionTableStore* table_store, const ObMergeType merge_type, + common::ObIArray &index_tables, bool &need_merge); + int check_need_mini_merge(ObMultiVersionTableStore *table_store, const ObMergeType merge_type, const int64_t save_slave_read_version, const int64_t trans_table_end_log_ts, const int64_t trans_table_timestamp, - bool& need_merge, bool& can_merge); - int check_need_minor_merge(const uint64_t table_id, bool& need_merge); - int check_need_major_merge(ObMultiVersionTableStore* table_store, const int64_t save_slave_read_version, - common::ObVersion& merge_version, bool& need_merge, bool& can_merge); - int push_frozen_memtable_per_table_(memtable::ObMemtable* frozen_memtable); - int check_all_tables_merged(const memtable::ObMemtable& memtable, - const common::ObIArray& index_status, - const common::ObIArray& deleted_index_ids, bool& all_merged, bool& can_release); - int check_skip_check_index_merge_status(const share::schema::ObIndexTableStat& index_stat, - const common::ObIArray& deleted_index_ids, bool& need_skip); + bool &need_merge, bool &can_merge); + int check_need_minor_merge(const uint64_t table_id, bool &need_merge); + int check_need_major_merge(ObMultiVersionTableStore *table_store, const int64_t save_slave_read_version, + common::ObVersion &merge_version, bool &need_merge, bool &can_merge); + int push_frozen_memtable_per_table_(memtable::ObMemtable *frozen_memtable); + int check_all_tables_merged(const memtable::ObMemtable &memtable, + const common::ObIArray &index_status, + const common::ObIArray &deleted_index_ids, bool &all_merged, bool &can_release); + int check_skip_check_index_merge_status(const share::schema::ObIndexTableStat &index_stat, + const common::ObIArray &deleted_index_ids, bool &need_skip); int do_add_sstable( - AddTableParam& param, const ObMigrateStatus& migarte_status, const bool is_in_source_split = false); + AddTableParam ¶m, const ObMigrateStatus &migarte_status, const bool is_in_source_split = false); int begin_transaction(bool in_slog_trans, bool write_slog); int end_transaction(bool in_slog_trans, bool write_slog, bool is_success); - int write_create_partition_store_log(const ObPGPartitionStoreMeta& meta); - int write_update_partition_meta_trans(const ObPGPartitionStoreMeta& meta, const LogCommand& cmd); - int write_modify_table_store_log(ObTableStore& table_store, const int64_t multi_version_start); - int write_drop_index_trans(const common::ObPartitionKey& pkey, const uint64_t index_id); + int write_create_partition_store_log(const ObPGPartitionStoreMeta &meta); + int write_update_partition_meta_trans(const ObPGPartitionStoreMeta &meta, const LogCommand &cmd); + int write_modify_table_store_log(ObTableStore &table_store, const int64_t multi_version_start); + int write_drop_index_trans(const common::ObPartitionKey &pkey, const uint64_t index_id); int check_new_table_store( - ObTableStore& new_table_store, const ObMigrateStatus migrate_status, const bool is_in_source_split = false); - ObPGPartitionStoreMeta& get_next_meta(); + ObTableStore &new_table_store, const ObMigrateStatus migrate_status, const bool is_in_source_split = false); + ObPGPartitionStoreMeta &get_next_meta(); void switch_meta(); int64_t get_serialize_size(); - int has_major_sstable_nolock(const uint64_t index_table_id, bool& has_major); - int write_report_status(const ObReportStatus& status, const uint64_t data_table_id, const bool write_slog); - int remove_old_table_(const common::ObVersion& kept_min_version, const int64_t multi_version_start, - const int64_t kept_major_num, const int64_t backup_snapshot_version, ObMultiVersionTableStore& table_store); + int has_major_sstable_nolock(const uint64_t index_table_id, bool &has_major); + int write_report_status(const ObReportStatus &status, const uint64_t data_table_id, const bool write_slog); + int remove_old_table_(const common::ObVersion &kept_min_version, const int64_t multi_version_start, + const int64_t kept_major_num, ObMultiVersionTableStore &table_store); int get_index_status(const int64_t schema_version, const bool is_physical_restore, - common::ObIArray& index_status, common::ObIArray& deleted_index_ids); - int release_head_memtable(memtable::ObMemtable* memtable); - int check_table_store_exist_nolock(const uint64_t index_id, bool& exist, ObMultiVersionTableStore*& got_table_store); + common::ObIArray &index_status, common::ObIArray &deleted_index_ids); + int release_head_memtable(memtable::ObMemtable *memtable); + int check_table_store_exist_nolock(const uint64_t index_id, bool &exist, ObMultiVersionTableStore *&got_table_store); int check_table_store_exist_with_lock( - const uint64_t index_id, bool& exist, ObMultiVersionTableStore*& got_table_store); - int set_table_store(const ObTableStore& table_store); + const uint64_t index_id, bool &exist, ObMultiVersionTableStore *&got_table_store); + int set_table_store(const ObTableStore &table_store); void clear_sstores_no_lock(); - static ObMultiVersionTableStore* alloc_multi_version_table_store(const uint64_t tenant_id); - static void free_multi_version_table_store(ObMultiVersionTableStore*& table_store); - OB_INLINE ObMultiVersionTableStore* get_data_table_store(); - int create_table_store_if_need(const uint64_t table_id, bool& is_created); - int get_kept_multi_version_start( - const bool is_in_dest_split, int64_t& multi_version_start, int64_t& backup_snapshot_version); - int inner_remove_uncontinues_inc_tables(ObMultiVersionTableStore* multi_table_store); + static ObMultiVersionTableStore *alloc_multi_version_table_store(const uint64_t tenant_id); + static void free_multi_version_table_store(ObMultiVersionTableStore *&table_store); + OB_INLINE ObMultiVersionTableStore *get_data_table_store(); + int create_table_store_if_need(const uint64_t table_id, bool &is_created); + int inner_remove_uncontinues_inc_tables(ObMultiVersionTableStore *multi_table_store); + int get_kept_multi_version_start(const bool is_in_dest_split, int64_t &multi_version_start); int set_removed(); - void set_replica_type(const common::ObReplicaType& replica_type); + void set_replica_type(const common::ObReplicaType &replica_type); int create_index_table_store(const uint64_t table_id, const int64_t schema_version); - int add_sstable(storage::ObSSTable* table, const int64_t max_kept_major_version_number, const bool in_slog_trans, - const ObMigrateStatus& migrate_status, const bool is_in_dest_split, const int64_t schema_version = 0); - int add_sstable_for_merge(storage::ObSSTable* table, const int64_t max_kept_major_version_number, - const ObMigrateStatus& migrate_status, const bool is_in_restore, const bool is_in_source_split, - const bool is_in_dest_split, storage::ObSSTable* complement_minor_sstable); - int set_reference_tables(const uint64_t table_id, ObTablesHandle& handle); + int add_sstable(storage::ObSSTable *table, const int64_t max_kept_major_version_number, const bool in_slog_trans, + const ObMigrateStatus &migrate_status, const bool is_in_dest_split, const int64_t schema_version = 0); + int add_sstable_for_merge(storage::ObSSTable *table, const int64_t max_kept_major_version_number, + const ObMigrateStatus &migrate_status, const bool is_in_restore, const bool is_in_source_split, + const bool is_in_dest_split, storage::ObSSTable *complement_minor_sstable); + int set_reference_tables(const uint64_t table_id, ObTablesHandle &handle); int halt_prewarm(); int retire_prewarm_store(const bool is_disk_full); - int get_active_protection_clock(int64_t& active_protection_clock); - int new_active_memstore(int64_t& protection_clock); - int effect_new_active_memstore(const ObSavedStorageInfoV2& info, const bool emergency); + int get_active_protection_clock(int64_t &active_protection_clock); + int new_active_memstore(int64_t &protection_clock); + int effect_new_active_memstore(const ObSavedStorageInfoV2 &info, const bool emergency); int clean_new_active_memstore(); - int complete_active_memstore(const ObSavedStorageInfoV2& info); + int complete_active_memstore(const ObSavedStorageInfoV2 &info); int drop_index(const uint64_t table_id, const bool write_slog); int set_dropped_flag(const uint64_t table_id); int remove_old_table(const int64_t frozen_version); - int serialize(common::ObIAllocator& allocator, char*& new_buf, int64_t& serialize_size); - int deserialize(ObIPartitionGroup* pg, ObPGMemtableMgr* pg_memtable_mgr, const ObReplicaType replica_type, - const char* buf, const int64_t buf_len, int64_t& pos, bool& is_old_meta, ObPartitionStoreMeta& old_meta); + int serialize(common::ObIAllocator &allocator, char *&new_buf, int64_t &serialize_size); + int deserialize(ObIPartitionGroup *pg, ObPGMemtableMgr *pg_memtable_mgr, const ObReplicaType replica_type, + const char *buf, const int64_t buf_len, int64_t &pos, bool &is_old_meta, ObPartitionStoreMeta &old_meta); - int replay_partition_meta(const ObPGPartitionStoreMeta& meta); - int replay_modify_table_store(const ObModifyTableStoreLogEntry& log_entry); + int replay_partition_meta(const ObPGPartitionStoreMeta &meta); + int replay_modify_table_store(const ObModifyTableStoreLogEntry &log_entry); int update_multi_version_start(const int64_t multi_version_start); int try_update_report_status(const uint64_t data_table_id, const bool write_slog = true); - int push_frozen_memtable_per_table(memtable::ObMemtable* frozen_memtable); - int calc_report_status(ObReportStatus& status); + int push_frozen_memtable_per_table(memtable::ObMemtable *frozen_memtable); + int calc_report_status(ObReportStatus &status); int finish_replay(); - int get_partition_store_info(ObPartitionStoreInfo& info); + int get_partition_store_info(ObPartitionStoreInfo &info); void clear_ssstores(); - int get_report_status(ObReportStatus& status); + int get_report_status(ObReportStatus &status); bool is_removed() const; int64_t get_readable_ts_() const; int remove_uncontinues_inc_tables(const uint64_t table_id); - int update_split_table_store(int64_t table_id, bool is_major_split, ObTablesHandle& handle); - int check_store_complete_(bool& is_complete); - int get_min_merged_version_(int64_t& min_merged_version); + int update_split_table_store(int64_t table_id, bool is_major_split, ObTablesHandle &handle); + int check_store_complete_(bool &is_complete); + int get_min_merged_version_(int64_t &min_merged_version); int inner_physical_flashback( - const bool is_data_table, const int64_t flashback_scn, ObMultiVersionTableStore* multi_table_store); + const bool is_data_table, const int64_t flashback_scn, ObMultiVersionTableStore *multi_table_store); int remove_unneed_store_within_trans(const TableStoreMap &new_store_map); - void replace_store_map(TableStoreMap& store_map); - int prepare_new_store_map(const ObTablesHandle& sstables, const int64_t max_kept_major_version_number, - const bool need_reuse_local_minor, TableStoreMap*& new_store_map); - int prepare_new_table_store_(ObTablesHandle& index_handle, const int64_t max_kept_major_version_number, - const bool need_reuse_local_minor, ObMultiVersionTableStore*& multi_version_table_store); - int get_remote_table_info_(const ObTablesHandle& index_handle, const bool need_reuse_local_minor, - ObMigrateRemoteTableInfo& remote_table_info); - int create_new_store_map_(TableStoreMap*& new_store_map); - static void destroy_store_map(TableStoreMap* store_map); + void replace_store_map(TableStoreMap &store_map); + int prepare_new_store_map(const ObTablesHandle &sstables, const int64_t max_kept_major_version_number, + const bool need_reuse_local_minor, TableStoreMap *&new_store_map); + int prepare_new_table_store_(ObTablesHandle &index_handle, const int64_t max_kept_major_version_number, + const bool need_reuse_local_minor, ObMultiVersionTableStore *&multi_version_table_store); + int get_remote_table_info_(const ObTablesHandle &index_handle, const bool need_reuse_local_minor, + ObMigrateRemoteTableInfo &remote_table_info); + int create_new_store_map_(TableStoreMap *&new_store_map); + static void destroy_store_map(TableStoreMap *store_map); int filter_read_sstables( - const ObTablesHandle& tmp_handle, const int64_t snapshot_version, ObTablesHandle& handle, bool& is_ready); - int get_restore_point_trans_tables_(const int64_t snapshot_version, ObTablesHandle& handle, bool& is_ready); + const ObTablesHandle &tmp_handle, const int64_t snapshot_version, ObTablesHandle &handle, bool &is_ready); + int get_restore_point_trans_tables_(const int64_t snapshot_version, ObTablesHandle &handle, bool &is_ready); int get_restore_point_normal_tables_(const int64_t snapshot_version, const int64_t publish_version, - ObRecoveryPointSchemaFilter& schema_filter, ObTablesHandle& handle, bool& is_ready); + ObRecoveryPointSchemaFilter &schema_filter, ObTablesHandle &handle, bool &is_ready); private: bool is_inited_; bool is_removed_; ObPGPartitionStoreMeta meta_buf_[2]; - ObPGPartitionStoreMeta* meta_; + ObPGPartitionStoreMeta *meta_; int64_t log_seq_num_; // abandoned in 3.0, keep it for serialization compatibility - TableStoreMap* store_map_; // main data table and index tables + TableStoreMap *store_map_; // main data table and index tables bool is_freezing_; - ObPGMemtableMgr* pg_memtable_mgr_; + ObPGMemtableMgr *pg_memtable_mgr_; mutable common::TCRWLock lock_; // protect modification of in-memory structures - ObFreezeInfoSnapshotMgr* freeze_info_mgr_; + ObFreezeInfoSnapshotMgr *freeze_info_mgr_; common::ObPartitionKey pkey_; - ObIPartitionGroup* pg_; - ObMultiVersionTableStore* cached_data_table_store_; + ObIPartitionGroup *pg_; + ObMultiVersionTableStore *cached_data_table_store_; ObLfFIFOAllocator allocator_; DISALLOW_COPY_AND_ASSIGN(ObPartitionStore); }; @@ -325,9 +324,9 @@ OB_INLINE common::ObPartitionKey ObPartitionStore::get_partition_key() const return meta_->pkey_; } -OB_INLINE ObMultiVersionTableStore* ObPartitionStore::get_data_table_store() +OB_INLINE ObMultiVersionTableStore *ObPartitionStore::get_data_table_store() { - ObMultiVersionTableStore* data_table_store = NULL; + ObMultiVersionTableStore *data_table_store = NULL; if (!is_inited_) { STORAGE_LOG(ERROR, "not inited"); diff --git a/src/storage/ob_pg_storage.cpp b/src/storage/ob_pg_storage.cpp index 08420b8d04ac66230375f8e1205446b4d873f3af..a52db7845d3b8220ef4607dd78deeb77682fc920 100644 --- a/src/storage/ob_pg_storage.cpp +++ b/src/storage/ob_pg_storage.cpp @@ -4739,6 +4739,12 @@ int ObPGStorage::set_restore_flag( ObPartitionGroupMeta& next_meta = *next_meta_ptr; if (REPLICA_RESTORE_LOG == restore_flag) { if (!is_sys_table(pkey_.get_table_id())) { + ObRole role; + if (OB_FAIL(pg_->get_role(role))) { + LOG_WARN("failed to get role", K(ret)); + } else if (ObRole::FOLLOWER == role) { + DEBUG_SYNC(FOLLOWER_BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG); + } DEBUG_SYNC(BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG); } } diff --git a/src/storage/ob_saved_storage_info_v2.cpp b/src/storage/ob_saved_storage_info_v2.cpp index 1eadeced11cb1ec92d38f96322c21fef1ecf7e3d..fce7ccedee7aab948def7bc119c5048d5bf7d83a 100644 --- a/src/storage/ob_saved_storage_info_v2.cpp +++ b/src/storage/ob_saved_storage_info_v2.cpp @@ -70,7 +70,7 @@ OB_DEF_DESERIALIZE(ObSavedStorageInfoV2) return ret; } -int ObSavedStorageInfoV2::deep_copy(const ObSavedStorageInfoV2& save_storage_info) +int ObSavedStorageInfoV2::deep_copy(const ObSavedStorageInfoV2 &save_storage_info) { int ret = OB_SUCCESS; @@ -90,7 +90,7 @@ int ObSavedStorageInfoV2::deep_copy(const ObSavedStorageInfoV2& save_storage_inf return ret; } -int ObSavedStorageInfoV2::convert(const ObSavedStorageInfo& save_storage_info) +int ObSavedStorageInfoV2::convert(const ObSavedStorageInfo &save_storage_info) { int ret = OB_SUCCESS; @@ -113,7 +113,7 @@ int ObSavedStorageInfoV2::convert(const ObSavedStorageInfo& save_storage_info) return ret; } -int ObSavedStorageInfoV2::deep_copy(const ObSavedStorageInfo& save_storage_info) +int ObSavedStorageInfoV2::deep_copy(const ObSavedStorageInfo &save_storage_info) { int ret = OB_SUCCESS; @@ -132,7 +132,7 @@ void ObSavedStorageInfoV2::reset() pg_file_id_ = OB_INVALID_DATA_FILE_ID; } -int ObSavedStorageInfoV2::set_data_info(const ObDataStorageInfo& data_storage_info) +int ObSavedStorageInfoV2::set_data_info(const ObDataStorageInfo &data_storage_info) { int ret = OB_SUCCESS; if (!data_storage_info.is_valid()) { @@ -145,8 +145,8 @@ int ObSavedStorageInfoV2::set_data_info(const ObDataStorageInfo& data_storage_in return ret; } -int ObSavedStorageInfoV2::query_log_info_with_log_id(const ObPartitionKey& pkey, const int64_t log_id, - const int64_t timeout, int64_t& accum_checksum, int64_t& submit_timestamp, int64_t& epoch_id) +int ObSavedStorageInfoV2::query_log_info_with_log_id(const ObPartitionKey &pkey, const int64_t log_id, + const int64_t timeout, int64_t &accum_checksum, int64_t &submit_timestamp, int64_t &epoch_id) { int ret = OB_SUCCESS; const int64_t start_ts = ObTimeUtility::current_time(); @@ -168,7 +168,7 @@ int ObSavedStorageInfoV2::query_log_info_with_log_id(const ObPartitionKey& pkey, } int ObSavedStorageInfoV2::get_last_replay_log_info_( - const ObPartitionKey& pkey, const int64_t timeout, ObRecoverPoint& point) + const ObPartitionKey &pkey, const int64_t timeout, ObRecoverPoint &point) { int ret = OB_SUCCESS; int64_t submit_timestamp = 0; @@ -193,8 +193,8 @@ int ObSavedStorageInfoV2::get_last_replay_log_info_( return ret; } -int ObSavedStorageInfoV2::update_last_replay_log_info_(const ObPartitionKey& pkey, const bool replica_with_data, - const ObBaseStorageInfo& old_clog_info, const int64_t timeout, const bool log_info_usable) +int ObSavedStorageInfoV2::update_last_replay_log_info_(const ObPartitionKey &pkey, const bool replica_with_data, + const ObBaseStorageInfo &old_clog_info, const int64_t timeout, const bool log_info_usable) { int ret = OB_SUCCESS; @@ -240,14 +240,14 @@ int ObSavedStorageInfoV2::update_last_replay_log_info_(const ObPartitionKey& pke return ret; } -int ObSavedStorageInfoV2::update_last_replay_log_info(const ObPartitionKey& pkey, const bool replica_with_data, - const ObBaseStorageInfo& old_clog_info, const int64_t timeout, const bool log_info_usable) +int ObSavedStorageInfoV2::update_last_replay_log_info(const ObPartitionKey &pkey, const bool replica_with_data, + const ObBaseStorageInfo &old_clog_info, const int64_t timeout, const bool log_info_usable) { return update_last_replay_log_info_(pkey, replica_with_data, old_clog_info, timeout, log_info_usable); } -int ObSavedStorageInfoV2::update_and_fetch_log_info(const ObPartitionKey& pkey, const bool replica_with_data, - const ObBaseStorageInfo& old_clog_info, const int64_t timeout, const bool log_info_usable) +int ObSavedStorageInfoV2::update_and_fetch_log_info(const ObPartitionKey &pkey, const bool replica_with_data, + const ObBaseStorageInfo &old_clog_info, const int64_t timeout, const bool log_info_usable) { int ret = OB_SUCCESS; @@ -258,17 +258,17 @@ int ObSavedStorageInfoV2::update_and_fetch_log_info(const ObPartitionKey& pkey, return ret; } -int ObSavedStorageInfoV2::clear_recover_points_for_physical_flashback(const int64_t, const ObRecoverPoint&) +int ObSavedStorageInfoV2::clear_recover_points_for_physical_flashback(const int64_t, const ObRecoverPoint &) { return OB_NOT_IMPLEMENT; } OB_SERIALIZE_MEMBER(ObRecoverPoint, snapshot_version_, recover_log_id_, checksum_, epoch_id_, submit_timestamp_, - recover_next_timestamp_); + recover_next_timestamp_, recover_next_timestamp_); OB_SERIALIZE_MEMBER(ObRecoverVec, recover_vec_); -int ObRecoverVec::add_recover_point_(const ObRecoverPoint& point) +int ObRecoverVec::add_recover_point_(const ObRecoverPoint &point) { int ret = OB_SUCCESS; @@ -282,14 +282,14 @@ int ObRecoverVec::add_recover_point_(const ObRecoverPoint& point) return ret; } -int ObRecoverVec::add_recover_point(const ObRecoverPoint& point) +int ObRecoverVec::add_recover_point(const ObRecoverPoint &point) { ObLockGuard lock_guard(lock_); return add_recover_point_(point); } -int ObRecoverVec::reboot_recover_point(const ObRecoverPoint& point) +int ObRecoverVec::reboot_recover_point(const ObRecoverPoint &point) { int ret = OB_SUCCESS; ObLockGuard lock_guard(lock_); @@ -301,7 +301,7 @@ int ObRecoverVec::reboot_recover_point(const ObRecoverPoint& point) return ret; } -int ObRecoverVec::gc_recover_points(const int64_t gc_snapshot_version, const int64_t kept_backup_version, bool& changed) +int ObRecoverVec::gc_recover_points(const int64_t gc_snapshot_version, const int64_t kept_backup_version, bool &changed) { int ret = OB_SUCCESS; changed = false; @@ -333,7 +333,7 @@ int ObRecoverVec::gc_recover_points(const int64_t gc_snapshot_version, const int return ret; } -int ObRecoverVec::clear_recover_points_for_physical_flashback(const int64_t version, const ObRecoverPoint& point) +int ObRecoverVec::clear_recover_points_for_physical_flashback(const int64_t version, const ObRecoverPoint &point) { int ret = OB_SUCCESS; int size = 0; @@ -364,7 +364,7 @@ bool ObRecoverVec::can_gc_recover_point_(const int64_t gc_snapshot_version, cons (kept_backup_version == 0 || recover_vec_[1].snapshot_version_ <= kept_backup_version); } -int ObRecoverVec::get_lower_bound_point(const int64_t snapshot_version, ObRecoverPoint& point) +int ObRecoverVec::get_lower_bound_point(const int64_t snapshot_version, ObRecoverPoint &point) { int ret = OB_SUCCESS; int64_t id = 0; @@ -383,7 +383,7 @@ int ObRecoverVec::get_lower_bound_point(const int64_t snapshot_version, ObRecove return ret; } -int ObRecoverVec::get_lower_bound_point_(const int64_t snapshot_version, int64_t& id) +int ObRecoverVec::get_lower_bound_point_(const int64_t snapshot_version, int64_t &id) { int ret = OB_SUCCESS; ObRecoverPoint tmp_point(snapshot_version, 0, 0, 0, 0); @@ -403,7 +403,7 @@ int ObRecoverVec::get_lower_bound_point_(const int64_t snapshot_version, int64_t return ret; } -int ObRecoverVec::record_major_recover_point(const int64_t prev_version, const int64_t version, bool& changed) +int ObRecoverVec::record_major_recover_point(const int64_t prev_version, const int64_t version, bool &changed) { int ret = OB_SUCCESS; int64_t id = 0; @@ -437,7 +437,7 @@ int ObRecoverVec::record_major_recover_point(const int64_t prev_version, const i return ret; } -int ObRecoverVec::assign_recover_points(const ObRecoverVec& vec) +int ObRecoverVec::assign_recover_points(const ObRecoverVec &vec) { int ret = OB_SUCCESS; ObLockGuard lock_guard(lock_); diff --git a/src/storage/ob_storage_struct.cpp b/src/storage/ob_storage_struct.cpp index 8aeeb4b220d017d7e20cb23cdc57eeaf7a848d08..17871f5334d60758bc51cff4609c0ca52f12990d 100644 --- a/src/storage/ob_storage_struct.cpp +++ b/src/storage/ob_storage_struct.cpp @@ -84,7 +84,7 @@ void ObPartitionStoreMeta::reset() create_timestamp_ = 0; } -int ObPartitionStoreMeta::deep_copy(const ObPartitionStoreMeta& meta) +int ObPartitionStoreMeta::deep_copy(const ObPartitionStoreMeta &meta) { int ret = OB_SUCCESS; @@ -138,7 +138,7 @@ bool ObPGPartitionStoreMeta::is_valid() const return pkey_.is_valid() && multi_version_start_ > 0 && create_schema_version_ >= 0 && create_timestamp_ >= 0; } -int ObPGPartitionStoreMeta::deep_copy(const ObPGPartitionStoreMeta& meta) +int ObPGPartitionStoreMeta::deep_copy(const ObPGPartitionStoreMeta &meta) { int ret = OB_SUCCESS; if (is_valid()) { @@ -156,7 +156,7 @@ int ObPGPartitionStoreMeta::deep_copy(const ObPGPartitionStoreMeta& meta) return ret; } -int ObPGPartitionStoreMeta::copy_from_old_meta(const ObPartitionStoreMeta& meta) +int ObPGPartitionStoreMeta::copy_from_old_meta(const ObPartitionStoreMeta &meta) { int ret = OB_SUCCESS; if (is_valid()) { @@ -224,7 +224,7 @@ void ObPartitionGroupMeta::reset() restore_schema_version_ = OB_INVALID_TIMESTAMP; } -int ObPartitionGroupMeta::deep_copy(const ObPartitionGroupMeta& meta) +int ObPartitionGroupMeta::deep_copy(const ObPartitionGroupMeta &meta) { int ret = OB_SUCCESS; @@ -261,7 +261,7 @@ int ObPartitionGroupMeta::deep_copy(const ObPartitionGroupMeta& meta) return ret; } -int ObPartitionGroupMeta::copy_from_store_meta(const ObPartitionStoreMeta& meta) +int ObPartitionGroupMeta::copy_from_store_meta(const ObPartitionStoreMeta &meta) { int ret = OB_SUCCESS; if (is_valid()) { @@ -288,7 +288,7 @@ int ObPartitionGroupMeta::copy_from_store_meta(const ObPartitionStoreMeta& meta) return ret; } -int ObPartitionGroupMeta::get_recover_info_for_flashback(const int64_t, ObRecoverPoint&) +int ObPartitionGroupMeta::get_recover_info_for_flashback(const int64_t, ObRecoverPoint &) { return OB_NOT_SUPPORTED; } @@ -363,7 +363,7 @@ void ObGetMergeTablesResult::reset() read_base_version_ = 0; } -int ObGetMergeTablesResult::deep_copy(const ObGetMergeTablesResult& src) +int ObGetMergeTablesResult::deep_copy(const ObGetMergeTablesResult &src) { int ret = OB_SUCCESS; if (!src.is_valid()) { @@ -396,15 +396,13 @@ AddTableParam::AddTableParam() need_prewarm_(false), is_daily_merge_(false), complement_minor_sstable_(nullptr), - backup_snapshot_version_(0), schema_version_(0) {} bool AddTableParam::is_valid() const { return (!is_daily_merge_ || (OB_NOT_NULL(table_) || OB_NOT_NULL(complement_minor_sstable_))) && - max_kept_major_version_number_ >= 0 && multi_version_start_ > ObVersionRange::MIN_VERSION && - backup_snapshot_version_ >= 0; + max_kept_major_version_number_ >= 0 && multi_version_start_ > ObVersionRange::MIN_VERSION; } ObPartitionReadableInfo::ObPartitionReadableInfo() @@ -441,7 +439,7 @@ void ObPartitionReadableInfo::reset() force_ = false; } -int ObMigrateStatusHelper::trans_replica_op(const ObReplicaOpType& op_type, ObMigrateStatus& migrate_status) +int ObMigrateStatusHelper::trans_replica_op(const ObReplicaOpType &op_type, ObMigrateStatus &migrate_status) { int ret = OB_SUCCESS; migrate_status = OB_MIGRATE_STATUS_MAX; @@ -503,7 +501,7 @@ int ObMigrateStatusHelper::trans_replica_op(const ObReplicaOpType& op_type, ObMi return ret; } -int ObMigrateStatusHelper::trans_fail_status(const ObMigrateStatus& cur_status, ObMigrateStatus& fail_status) +int ObMigrateStatusHelper::trans_fail_status(const ObMigrateStatus &cur_status, ObMigrateStatus &fail_status) { int ret = OB_SUCCESS; fail_status = OB_MIGRATE_STATUS_MAX; @@ -569,7 +567,7 @@ int ObMigrateStatusHelper::trans_fail_status(const ObMigrateStatus& cur_status, return ret; } -int ObMigrateStatusHelper::trans_reboot_status(const ObMigrateStatus& cur_status, ObMigrateStatus& reboot_status) +int ObMigrateStatusHelper::trans_reboot_status(const ObMigrateStatus &cur_status, ObMigrateStatus &reboot_status) { int ret = OB_SUCCESS; reboot_status = OB_MIGRATE_STATUS_MAX; @@ -685,7 +683,7 @@ bool ObCreatePGParam::is_valid() const restore_schema_version_ >= OB_INVALID_TIMESTAMP && migrate_status_ < ObMigrateStatus::OB_MIGRATE_STATUS_MAX; } -int ObCreatePGParam::assign(const ObCreatePGParam& param) +int ObCreatePGParam::assign(const ObCreatePGParam ¶m) { int ret = OB_SUCCESS; if (!param.is_valid()) { @@ -715,7 +713,7 @@ int ObCreatePGParam::assign(const ObCreatePGParam& param) return ret; } -int ObCreatePGParam::set_storage_info(const ObSavedStorageInfoV2& info) +int ObCreatePGParam::set_storage_info(const ObSavedStorageInfoV2 &info) { int ret = OB_SUCCESS; if (OB_FAIL(info_.deep_copy(info))) { @@ -724,7 +722,7 @@ int ObCreatePGParam::set_storage_info(const ObSavedStorageInfoV2& info) return ret; } -int ObCreatePGParam::set_split_info(const ObPartitionSplitInfo& split_info) +int ObCreatePGParam::set_split_info(const ObPartitionSplitInfo &split_info) { int ret = OB_SUCCESS; if (OB_FAIL(split_info_.assign(split_info))) { @@ -747,7 +745,7 @@ void ObCreatePartitionMeta::reset() id_hash_array_ = NULL; } -int ObCreatePartitionMeta::extract_from(const ObTableSchema& table_schema) +int ObCreatePartitionMeta::extract_from(const ObTableSchema &table_schema) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!table_schema.is_valid())) { @@ -770,9 +768,9 @@ int ObCreatePartitionMeta::extract_from(const ObTableSchema& table_schema) return ret; } -const ObColumnSchemaV2* ObCreatePartitionMeta::get_column_schema(const uint64_t column_id) const +const ObColumnSchemaV2 *ObCreatePartitionMeta::get_column_schema(const uint64_t column_id) const { - ObColumnSchemaV2* column = NULL; + ObColumnSchemaV2 *column = NULL; if (NULL != id_hash_array_) { if (OB_SUCCESS != id_hash_array_->get_refactored(ObColumnIdKey(column_id), column)) { column = NULL; @@ -796,7 +794,7 @@ int ObCreatePartitionMeta::replace_tenant_id(const uint64_t new_tenant_id) return ret; } -int ObCreatePartitionMeta::assign(const ObCreatePartitionMeta& other) +int ObCreatePartitionMeta::assign(const ObCreatePartitionMeta &other) { int ret = OB_SUCCESS; if (OB_FAIL(column_ids_.assign(other.get_store_column_ids()))) { @@ -833,12 +831,12 @@ void ObCreatePartitionParam::reset() schemas_.reset(); } -int ObCreatePartitionParam::extract_from(const obrpc::ObCreatePartitionArg& arg) +int ObCreatePartitionParam::extract_from(const obrpc::ObCreatePartitionArg &arg) { int ret = OB_SUCCESS; const int64_t table_cnt = arg.table_schemas_.count(); for (int64_t i = 0; OB_SUCC(ret) && i < table_cnt; ++i) { - const ObTableSchema& table_schema = arg.table_schemas_.at(i); + const ObTableSchema &table_schema = arg.table_schemas_.at(i); ObCreatePartitionMeta partition_schema; if (OB_FAIL(partition_schema.extract_from(table_schema))) { STORAGE_LOG(WARN, "failed to extract partition_schema", KR(ret), K(table_schema)); @@ -882,7 +880,7 @@ int ObCreatePartitionParam::replace_tenant_id(const uint64_t new_tenant_id) } else { const int64_t cnt = schemas_.count(); for (int64_t i = 0; OB_SUCC(ret) && i < cnt; ++i) { - ObCreatePartitionMeta& partition_schema = schemas_.at(i); + ObCreatePartitionMeta &partition_schema = schemas_.at(i); if (OB_FAIL(partition_schema.replace_tenant_id(new_tenant_id))) { STORAGE_LOG(WARN, "failed to replace_tenant_id of partition_scheam", KR(ret), K(*this)); } @@ -911,8 +909,8 @@ bool ObRecoveryPointSchemaFilter::is_inited() const return is_inited_; } -int ObRecoveryPointSchemaFilter::init(const int64_t tenant_id, const bool is_restore_point, const int64_t tenant_recovery_point_schema_version, - const int64_t tenant_current_schema_version) +int ObRecoveryPointSchemaFilter::init(const int64_t tenant_id, const bool is_restore_point, + const int64_t tenant_recovery_point_schema_version, const int64_t tenant_current_schema_version) { int ret = OB_SUCCESS; if (OB_UNLIKELY(is_inited_)) { @@ -928,7 +926,7 @@ int ObRecoveryPointSchemaFilter::init(const int64_t tenant_id, const bool is_res K(tenant_current_schema_version)); } else { is_schema_version_same_ = (tenant_recovery_point_schema_version == tenant_current_schema_version); - ObMultiVersionSchemaService& schema_service = ObMultiVersionSchemaService::get_instance(); + ObMultiVersionSchemaService &schema_service = ObMultiVersionSchemaService::get_instance(); if (OB_FAIL(ObBackupUtils::retry_get_tenant_schema_guard( tenant_id, schema_service, tenant_recovery_point_schema_version, recovery_point_schema_guard_))) { STORAGE_LOG(WARN, @@ -957,12 +955,12 @@ int ObRecoveryPointSchemaFilter::init(const int64_t tenant_id, const bool is_res return ret; } -int ObRecoveryPointSchemaFilter::check_partition_exist(const ObPartitionKey pkey, bool& is_exist) +int ObRecoveryPointSchemaFilter::check_partition_exist(const ObPartitionKey pkey, bool &is_exist) { int ret = OB_SUCCESS; bool check_dropped_partition = false; is_exist = false; - ObSchemaGetterGuard* schema_guard = NULL; + ObSchemaGetterGuard *schema_guard = NULL; bool is_exist_in_backup_schema = false; bool is_exist_in_delay_delete = false; bool is_exist_in_current_schema = false; @@ -1001,7 +999,7 @@ int ObRecoveryPointSchemaFilter::check_partition_exist(const ObPartitionKey pkey } int ObRecoveryPointSchemaFilter::check_partition_exist_( - const ObPartitionKey pkey, const bool check_dropped_partition, ObSchemaGetterGuard& schema_guard, bool& is_exist) + const ObPartitionKey pkey, const bool check_dropped_partition, ObSchemaGetterGuard &schema_guard, bool &is_exist) { int ret = OB_SUCCESS; is_exist = false; @@ -1017,11 +1015,11 @@ int ObRecoveryPointSchemaFilter::check_partition_exist_( return ret; } -int ObRecoveryPointSchemaFilter::check_table_exist(const uint64_t table_id, bool& is_exist) +int ObRecoveryPointSchemaFilter::check_table_exist(const uint64_t table_id, bool &is_exist) { int ret = OB_SUCCESS; is_exist = false; - ObSchemaGetterGuard* schema_guard = NULL; + ObSchemaGetterGuard *schema_guard = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1044,11 +1042,11 @@ int ObRecoveryPointSchemaFilter::check_table_exist(const uint64_t table_id, bool } int ObRecoveryPointSchemaFilter::check_table_exist_( - const uint64_t table_id, ObSchemaGetterGuard& schema_guard, bool& is_exist) + const uint64_t table_id, ObSchemaGetterGuard &schema_guard, bool &is_exist) { int ret = OB_SUCCESS; is_exist = false; - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; bool need_skip = false; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; @@ -1061,8 +1059,8 @@ int ObRecoveryPointSchemaFilter::check_table_exist_( // do nothing } else if (OB_FAIL(schema_guard.get_table_schema(table_id, table_schema))) { STORAGE_LOG(WARN, "failed to get table schema", K(ret), K(table_id)); - } else if (OB_FAIL( - ObBackupRestoreTableSchemaChecker::check_backup_restore_need_skip_table(table_schema, need_skip, is_restore_point_))) { + } else if (OB_FAIL(ObBackupRestoreTableSchemaChecker::check_backup_restore_need_skip_table( + table_schema, need_skip, is_restore_point_))) { LOG_WARN("failed to check backup restore need skip table", K(ret), K(table_id)); } else if (!need_skip) { // do nothing @@ -1072,7 +1070,7 @@ int ObRecoveryPointSchemaFilter::check_table_exist_( return ret; } -int ObRecoveryPointSchemaFilter::do_filter_tables(common::ObIArray& table_ids) +int ObRecoveryPointSchemaFilter::do_filter_tables(common::ObIArray &table_ids) { int ret = OB_SUCCESS; ObArray backup_tables; @@ -1114,7 +1112,7 @@ int ObRecoveryPointSchemaFilter::do_filter_tables(common::ObIArray& ta } int ObRecoveryPointSchemaFilter::do_filter_pg_partitions( - const ObPartitionKey& pg_key, common::ObPartitionArray& partitions) + const ObPartitionKey &pg_key, common::ObPartitionArray &partitions) { int ret = OB_SUCCESS; @@ -1126,7 +1124,7 @@ int ObRecoveryPointSchemaFilter::do_filter_pg_partitions( bool filtered = false; ObPartitionArray exist_partitions; for (int i = 0; OB_SUCC(ret) && i < partitions.count(); ++i) { - const ObPartitionKey& pkey = partitions.at(i); + const ObPartitionKey &pkey = partitions.at(i); if (OB_FAIL(check_partition_exist(pkey, is_exist))) { STORAGE_LOG(WARN, "backup filter check partition failed", K(ret), K(pg_key), K(pkey)); } else if (is_exist) { @@ -1150,12 +1148,12 @@ int ObRecoveryPointSchemaFilter::do_filter_pg_partitions( } int ObRecoveryPointSchemaFilter::check_if_table_miss_by_schema( - const ObPartitionKey& pgkey, const hash::ObHashSet& table_ids) + const ObPartitionKey &pgkey, const hash::ObHashSet &table_ids) { int ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; ObArray schema_tables; - ObSchemaGetterGuard* schema_guard = NULL; + ObSchemaGetterGuard *schema_guard = NULL; if (OB_UNLIKELY(!is_inited())) { ret = OB_NOT_INIT; @@ -1172,8 +1170,8 @@ int ObRecoveryPointSchemaFilter::check_if_table_miss_by_schema( return ret; } -int ObRecoveryPointSchemaFilter::check_if_table_miss_by_schema_(const ObPartitionKey& pgkey, - const common::hash::ObHashSet& table_ids, share::schema::ObSchemaGetterGuard& schema_guard) +int ObRecoveryPointSchemaFilter::check_if_table_miss_by_schema_(const ObPartitionKey &pgkey, + const common::hash::ObHashSet &table_ids, share::schema::ObSchemaGetterGuard &schema_guard) { int ret = OB_SUCCESS; int hash_ret = OB_SUCCESS; @@ -1199,8 +1197,8 @@ int ObRecoveryPointSchemaFilter::check_if_table_miss_by_schema_(const ObPartitio return ret; } -int ObRecoveryPointSchemaFilter::get_table_ids_in_pg_(const ObPartitionKey& pgkey, - common::ObIArray& table_ids, share::schema::ObSchemaGetterGuard& schema_guard) +int ObRecoveryPointSchemaFilter::get_table_ids_in_pg_(const ObPartitionKey &pgkey, + common::ObIArray &table_ids, share::schema::ObSchemaGetterGuard &schema_guard) { int ret = OB_SUCCESS; common::ObArray data_table_ids; @@ -1222,7 +1220,7 @@ int ObRecoveryPointSchemaFilter::get_table_ids_in_pg_(const ObPartitionKey& pgke if (OB_SUCC(ret)) { for (int64_t i = 0; OB_SUCC(ret) && i < data_table_ids.count(); ++i) { const uint64_t data_table_id = data_table_ids.at(i); - const ObTableSchema* table_schema = NULL; + const ObTableSchema *table_schema = NULL; if (OB_FAIL(schema_guard.get_table_schema(data_table_id, table_schema))) { STORAGE_LOG(WARN, "failed to get table schema", K(ret), K(data_table_id)); @@ -1238,8 +1236,8 @@ int ObRecoveryPointSchemaFilter::get_table_ids_in_pg_(const ObPartitionKey& pgke STORAGE_LOG(WARN, "get local index status fail", K(ret), K(pgkey)); } else { for (int64_t j = 0; OB_SUCC(ret) && j < index_stats.count(); ++j) { - const ObTableSchema* index_table_schema = NULL; - const ObIndexTableStat& index_table_stat = index_stats.at(j); + const ObTableSchema *index_table_schema = NULL; + const ObIndexTableStat &index_table_stat = index_stats.at(j); if (INDEX_STATUS_AVAILABLE != index_table_stat.index_status_) { // filter unavailable index } else if (OB_FAIL(schema_guard.get_table_schema(index_table_stat.index_id_, index_table_schema))) { @@ -1262,7 +1260,7 @@ int ObRecoveryPointSchemaFilter::get_table_ids_in_pg_(const ObPartitionKey& pgke /***********************ObBackupRestoreTableSchemaChecker***************************/ int ObBackupRestoreTableSchemaChecker::check_backup_restore_need_skip_table( - const share::schema::ObTableSchema* table_schema, bool& need_skip, const bool is_restore_point) + const share::schema::ObTableSchema *table_schema, bool &need_skip, const bool is_restore_point) { int ret = OB_SUCCESS; ObIndexStatus index_status; @@ -1276,19 +1274,21 @@ int ObBackupRestoreTableSchemaChecker::check_backup_restore_need_skip_table( } else if (table_schema->is_dropped_schema()) { STORAGE_LOG(INFO, "table is dropped, skip it", K(table_id)); } else if (FALSE_IT(index_status = table_schema->get_index_status())) { - } else if (table_schema->is_index_table() - && (is_restore_point ? - !is_final_index_status(index_status, table_schema->is_dropped_schema()) : - ObIndexStatus::INDEX_STATUS_AVAILABLE != index_status)) { - STORAGE_LOG(INFO, "restore table index is not expected status, skip it", - K(is_restore_point), K(index_status), K(*table_schema)); + } else if (table_schema->is_index_table() && + (is_restore_point ? !is_final_index_status(index_status, table_schema->is_dropped_schema()) + : ObIndexStatus::INDEX_STATUS_AVAILABLE != index_status)) { + STORAGE_LOG(INFO, + "restore table index is not expected status, skip it", + K(is_restore_point), + K(index_status), + K(*table_schema)); } else { need_skip = false; } return ret; } -ObRebuildListener::ObRebuildListener(transaction::ObPartitionTransCtxMgr& mgr) : ob_partition_ctx_mgr_(mgr) +ObRebuildListener::ObRebuildListener(transaction::ObPartitionTransCtxMgr &mgr) : ob_partition_ctx_mgr_(mgr) { int tmp_ret = OB_SUCCESS; while (OB_SUCCESS != (tmp_ret = ob_partition_ctx_mgr_.lock_minor_merge_lock())) { @@ -1317,12 +1317,12 @@ bool ObRebuildListener::on_partition_rebuild() } int ObRestoreFakeMemberListHelper::fake_restore_member_list( - const int64_t replica_cnt, common::ObMemberList& fake_member_list) + const int64_t replica_cnt, common::ObMemberList &fake_member_list) { int ret = OB_SUCCESS; fake_member_list.reset(); - const char* fake_ip = "127.0.0.1"; + const char *fake_ip = "127.0.0.1"; int32_t fake_port = 10000; if (replica_cnt <= 0) { diff --git a/src/storage/ob_storage_struct.h b/src/storage/ob_storage_struct.h index 7eae3653f71a89239674422c03b76599fa9c0213..e2322cc1ea60d37ad1438b1ac54f3995bc70b211 100644 --- a/src/storage/ob_storage_struct.h +++ b/src/storage/ob_storage_struct.h @@ -340,9 +340,9 @@ OB_INLINE bool is_valid_migrate_status(const ObMigrateStatus& status) struct AddTableParam { AddTableParam(); bool is_valid() const; - TO_STRING_KV(KP_(table), K_(max_kept_major_version_number), K_(multi_version_start), K_(in_slog_trans), - K_(need_prewarm), K_(is_daily_merge), K_(backup_snapshot_version), KP_(complement_minor_sstable), - K_(schema_version)); + TO_STRING_KV(KP_(table), K_(max_kept_major_version_number), K_(multi_version_start), + K_(in_slog_trans), K_(need_prewarm), K_(is_daily_merge), + KP_(complement_minor_sstable), K_(schema_version)); storage::ObSSTable* table_; int64_t max_kept_major_version_number_; @@ -351,7 +351,6 @@ struct AddTableParam { bool need_prewarm_; bool is_daily_merge_; storage::ObSSTable* complement_minor_sstable_; - int64_t backup_snapshot_version_; int64_t schema_version_; }; diff --git a/src/storage/ob_table_store.cpp b/src/storage/ob_table_store.cpp index d4337190e4ec4bccc5e5110325376f6ae3577aca..4cc4332f2f4a8a6fa8a9911f6c532a127c763ed2 100644 --- a/src/storage/ob_table_store.cpp +++ b/src/storage/ob_table_store.cpp @@ -54,7 +54,7 @@ ObTableStore::~ObTableStore() void ObTableStore::reset() { for (int64_t i = 0; i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (nullptr != table) { table->dec_ref(); } @@ -81,8 +81,8 @@ void ObTableStore::reset() OB_SERIALIZE_MEMBER( ObTableStore, pkey_, table_id_, uptime_, start_pos_, inc_pos_, replay_tables_, multi_version_start_); -int ObTableStore::init(const common::ObPartitionKey& pkey, const uint64_t table_id, - ObFreezeInfoSnapshotMgr* freeze_info_mgr, ObPGMemtableMgr* pg_memtable_mgr) +int ObTableStore::init(const common::ObPartitionKey &pkey, const uint64_t table_id, + ObFreezeInfoSnapshotMgr *freeze_info_mgr, ObPGMemtableMgr *pg_memtable_mgr) { int ret = OB_SUCCESS; @@ -117,7 +117,7 @@ int ObTableStore::init(const common::ObPartitionKey& pkey, const uint64_t table_ } int ObTableStore::init( - const ObTableStore& table_store, ObFreezeInfoSnapshotMgr* freeze_info_mgr, ObPGMemtableMgr* pg_memtable_mgr) + const ObTableStore &table_store, ObFreezeInfoSnapshotMgr *freeze_info_mgr, ObPGMemtableMgr *pg_memtable_mgr) { int ret = OB_SUCCESS; @@ -149,7 +149,7 @@ int ObTableStore::init( // TODO get_all_tables no need return active memtable, and should always return complement int ObTableStore::get_all_tables( - const bool include_active_memtable, const bool include_complement_minor_sstable, ObTablesHandle& handle) + const bool include_active_memtable, const bool include_complement_minor_sstable, ObTablesHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -180,7 +180,7 @@ int ObTableStore::get_all_tables( return ret; } -int ObTableStore::get_read_tables(const int64_t snapshot_version, ObTablesHandle& handle, const bool allow_not_ready) +int ObTableStore::get_read_tables(const int64_t snapshot_version, ObTablesHandle &handle, const bool allow_not_ready) { int ret = OB_SUCCESS; bool can_read = false; @@ -239,10 +239,10 @@ int ObTableStore::get_read_tables(const int64_t snapshot_version, ObTablesHandle } int ObTableStore::get_read_base_tables( - const int64_t snapshot_version, ObTablesHandle& handle, bool& contain_snapshot_version) + const int64_t snapshot_version, ObTablesHandle &handle, bool &contain_snapshot_version) { int ret = OB_SUCCESS; - ObITable* table = nullptr; + ObITable *table = nullptr; for (int64_t i = inc_pos_ - 1; OB_SUCC(ret) && i >= start_pos_; --i) { if (OB_ISNULL(tables_[i])) { @@ -265,13 +265,13 @@ int ObTableStore::get_read_base_tables( } int ObTableStore::get_inc_read_tables( - const int64_t snapshot_version, ObTablesHandle& handle, bool& contain_snapshot_version) + const int64_t snapshot_version, ObTablesHandle &handle, bool &contain_snapshot_version) { int ret = OB_SUCCESS; - ObSSTable* base_table = nullptr; - ObITable* inc_table = nullptr; + ObSSTable *base_table = nullptr; + ObITable *inc_table = nullptr; - if (OB_ISNULL(base_table = static_cast(handle.get_last_table()))) { + if (OB_ISNULL(base_table = static_cast(handle.get_last_table()))) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected base table handle", K(ret), K(handle)); } else { @@ -280,7 +280,7 @@ int ObTableStore::get_inc_read_tables( uint64_t last_log_ts = base_table->is_major_sstable() ? INT64_MAX : base_table->get_end_log_ts(); for (int64_t i = inc_pos_; OB_SUCC(ret) && i < table_count_; i++) { inc_table = tables_[i]; - LOG_DEBUG("table", K(i), KPC(static_cast(inc_table)), K(last_log_ts), K(handle)); + LOG_DEBUG("table", K(i), KPC(static_cast(inc_table)), K(last_log_ts), K(handle)); if (!found_inc) { if ((base_table->is_major_sstable() && inc_table->get_upper_trans_version() > base_table->get_snapshot_version()) /*major*/ @@ -341,11 +341,11 @@ int ObTableStore::get_inc_read_tables( return ret; } -int ObTableStore::get_hist_major_table(const int64_t snapshot_version, ObTablesHandle& handle) +int ObTableStore::get_hist_major_table(const int64_t snapshot_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObITable* table = nullptr; + ObITable *table = nullptr; for (int64_t i = start_pos_ - 1; OB_SUCC(ret) && i >= 0; --i) { if (OB_ISNULL(table = tables_[i])) { ret = OB_ERR_SYS; @@ -362,7 +362,7 @@ int ObTableStore::get_hist_major_table(const int64_t snapshot_version, ObTablesH return ret; } -int ObTableStore::get_major_sstable(const common::ObVersion& version, ObTablesHandle& handle) +int ObTableStore::get_major_sstable(const common::ObVersion &version, ObTablesHandle &handle) { int ret = OB_SUCCESS; @@ -374,7 +374,7 @@ int ObTableStore::get_major_sstable(const common::ObVersion& version, ObTablesHa LOG_WARN("invalid args", K(ret), K(version)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < inc_pos_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(i), K(PRETTY_TS(*this))); @@ -397,7 +397,7 @@ int ObTableStore::get_major_sstable(const common::ObVersion& version, ObTablesHa return ret; } -int ObTableStore::get_sample_read_tables(const common::SampleInfo& sample_info, ObTablesHandle& handle) +int ObTableStore::get_sample_read_tables(const common::SampleInfo &sample_info, ObTablesHandle &handle) { int ret = OB_SUCCESS; ObTablesHandle tmp_handle; @@ -409,7 +409,7 @@ int ObTableStore::get_sample_read_tables(const common::SampleInfo& sample_info, LOG_WARN("failed to get read tables", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_handle.get_count(); ++i) { - ObITable* table = tmp_handle.get_table(i); + ObITable *table = tmp_handle.get_table(i); bool need_table = false; if (SampleInfo::SAMPLE_ALL_DATA == sample_info.scope_) { need_table = true; @@ -433,7 +433,7 @@ int ObTableStore::get_sample_read_tables(const common::SampleInfo& sample_info, return ret; } -int ObTableStore::get_latest_major_sstable(ObTableHandle& handle) +int ObTableStore::get_latest_major_sstable(ObTableHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -464,7 +464,7 @@ int ObTableStore::get_latest_major_sstable(ObTableHandle& handle) } // merged_table allowed to be null -int ObTableStore::build_new_merge_store(const AddTableParam& param, ObTablesHandle& old_handle) +int ObTableStore::build_new_merge_store(const AddTableParam ¶m, ObTablesHandle &old_handle) { int ret = OB_SUCCESS; // The version range of major sstables will not cross. @@ -476,8 +476,8 @@ int ObTableStore::build_new_merge_store(const AddTableParam& param, ObTablesHand // 4. According to keep_major_version_num supplement, the major sstable may needs to be retained // (if the partition is split, the upper layer should pass 0. If it is not 0, // the baseline before and after the split will be retained at the same time) - ObArray major_tables; - ObArray inc_tables; // memtable or minor sstable + ObArray major_tables; + ObArray inc_tables; // memtable or minor sstable int64_t temp_kept_major_version_num = param.max_kept_major_version_number_; int64_t multi_version_start = param.multi_version_start_; bool need_safe_check = table_count_ >= MAX_SSTABLE_CNT_IN_STORAGE - RESERVED_STORE_CNT_IN_STORAGE; @@ -521,11 +521,7 @@ int ObTableStore::build_new_merge_store(const AddTableParam& param, ObTablesHand } if (OB_SUCC(ret)) { - if (OB_FAIL(build_tables(temp_kept_major_version_num, - multi_version_start, - major_tables, - inc_tables, - param.backup_snapshot_version_))) { + if (OB_FAIL(build_tables(temp_kept_major_version_num, multi_version_start, major_tables, inc_tables))) { LOG_WARN("failed to build_tables", K(ret), K(multi_version_start), KPC(param.table_), K(old_handle)); } else { if (OB_NOT_NULL(param.complement_minor_sstable_)) { @@ -544,14 +540,14 @@ int ObTableStore::build_new_merge_store(const AddTableParam& param, ObTablesHand return ret; } -bool ObTableStore::is_multi_version_break(const ObVersionRange& new_version_range, const int64_t last_snapshot_vesion) +bool ObTableStore::is_multi_version_break(const ObVersionRange &new_version_range, const int64_t last_snapshot_vesion) { return new_version_range.base_version_ != new_version_range.multi_version_start_ && new_version_range.multi_version_start_ > last_snapshot_vesion; } int ObTableStore::classify_tables( - const ObTablesHandle& old_handle, ObArray& major_tables, ObArray& inc_tables) + const ObTablesHandle &old_handle, ObArray &major_tables, ObArray &inc_tables) { int ret = OB_SUCCESS; major_tables.reset(); @@ -563,7 +559,7 @@ int ObTableStore::classify_tables( } for (int64_t i = 0; OB_SUCC(ret) && i < old_handle.get_count(); ++i) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); @@ -595,7 +591,7 @@ int ObTableStore::classify_tables( return ret; } -int ObTableStore::add_trans_sstable(ObSSTable* new_table, ObIArray& trans_tables) +int ObTableStore::add_trans_sstable(ObSSTable *new_table, ObIArray &trans_tables) { int ret = OB_SUCCESS; if (OB_UNLIKELY(nullptr == new_table || trans_tables.count() > 1)) { @@ -623,7 +619,7 @@ int ObTableStore::add_trans_sstable(ObSSTable* new_table, ObIArray& t return ret; } -int ObTableStore::add_major_sstable(ObSSTable* new_table, ObArray& major_tables) +int ObTableStore::add_major_sstable(ObSSTable *new_table, ObArray &major_tables) { int ret = OB_SUCCESS; bool need_add = true; @@ -633,7 +629,7 @@ int ObTableStore::add_major_sstable(ObSSTable* new_table, ObArray& ma LOG_WARN("invalid args", K(ret), KP(new_table)); } for (int64_t i = major_tables.count() - 1; OB_SUCC(ret) && need_add && i >= 0; --i) { - ObITable* table = major_tables.at(i); + ObITable *table = major_tables.at(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); @@ -659,10 +655,10 @@ int ObTableStore::add_major_sstable(ObSSTable* new_table, ObArray& ma return ret; } -int ObTableStore::add_minor_sstable(const bool need_safe_check, ObIArray& inc_tables, ObSSTable* new_table) +int ObTableStore::add_minor_sstable(const bool need_safe_check, ObIArray &inc_tables, ObSSTable *new_table) { int ret = OB_SUCCESS; - ObArray tmp_tables; + ObArray tmp_tables; if (OB_ISNULL(new_table)) { ret = OB_INVALID_ARGUMENT; @@ -684,7 +680,7 @@ int ObTableStore::add_minor_sstable(const bool need_safe_check, ObIArray= b.get_end_log_ts() && a.get_start_log_ts() <= b.get_start_log_ts()) { @@ -693,7 +689,7 @@ bool ObTableStore::check_include_by_log_ts_range(ObITable& a, ObITable& b) return bret; } -bool ObTableStore::check_intersect_by_log_ts_range(ObITable& a, ObITable& b) +bool ObTableStore::check_intersect_by_log_ts_range(ObITable &a, ObITable &b) { bool bret = false; if (!(a.get_end_log_ts() <= b.get_start_log_ts() || a.get_start_log_ts() >= b.get_end_log_ts())) { @@ -703,7 +699,7 @@ bool ObTableStore::check_intersect_by_log_ts_range(ObITable& a, ObITable& b) } int ObTableStore::check_need_add_minor_sstable( - ObIArray& inc_tables, ObITable* new_table, ObIArray& tmp_tables) + ObIArray &inc_tables, ObITable *new_table, ObIArray &tmp_tables) { int ret = OB_SUCCESS; @@ -715,7 +711,7 @@ int ObTableStore::check_need_add_minor_sstable( LOG_ERROR("meet invalid or empty log_ts_range sstable", KPC(new_table)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < inc_tables.count(); ++i) { - ObITable* table = inc_tables.at(i); + ObITable *table = inc_tables.at(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret)); @@ -741,13 +737,12 @@ int ObTableStore::check_need_add_minor_sstable( } int ObTableStore::build_tables(const int64_t kept_major_version_num, const int64_t expect_multi_version_start, - ObIArray& major_tables, ObIArray& inc_tables, const int64_t backup_snapshot_version) + ObIArray &major_tables, ObIArray &inc_tables) { int ret = OB_SUCCESS; int64_t inc_pos = -1; int64_t need_major_pos = -1; - int64_t backup_major_pos = -1; - ObITable* major_table = NULL; + ObITable *major_table = NULL; table_count_ = 0; start_pos_ = 0; is_ready_for_read_ = false; @@ -765,8 +760,6 @@ int ObTableStore::build_tables(const int64_t kept_major_version_num, const int64 } else if (OB_FAIL( find_need_major_sstable(major_tables, expect_multi_version_start, need_major_pos, major_table))) { LOG_WARN("failed to find_need_major_sstable", K(ret)); - } else if (OB_FAIL(find_need_backup_major_sstable(major_tables, backup_snapshot_version, backup_major_pos))) { - LOG_WARN("failed to find need backup major sstable", K(ret), K(backup_snapshot_version)); } if (OB_SUCC(ret)) { @@ -792,18 +785,12 @@ int ObTableStore::build_tables(const int64_t kept_major_version_num, const int64 } start_pos_ = need_major_pos - copy_start_pos; inc_pos_ = major_tables.count() - copy_start_pos; - if (OB_FAIL(add_backup_table(major_tables, backup_major_pos, copy_start_pos))) { - LOG_WARN("failed to add_backup_table", K(ret)); - } else if (OB_FAIL(inner_add_table(major_tables, copy_start_pos))) { + if (OB_FAIL(inner_add_table(major_tables, copy_start_pos))) { LOG_WARN("failed to add major table", K(ret)); } else if (inc_pos >= 0 && OB_FAIL(inner_add_table(inc_tables, inc_pos))) { LOG_WARN("failed to add inc table", K(ret)); } else { - LOG_INFO("succ to add table for build_tables", - K(backup_major_pos), - K(need_major_pos), - K(inc_pos), - K(copy_start_pos)); + LOG_INFO("succ to add table for build_tables", K(need_major_pos), K(inc_pos), K(copy_start_pos)); } } } @@ -820,42 +807,7 @@ int ObTableStore::build_tables(const int64_t kept_major_version_num, const int64 return ret; } -int ObTableStore::add_backup_table( - ObIArray& major_tables, const int64_t backup_major_pos, const int64_t copy_start_pos) -{ - int ret = OB_SUCCESS; - - if (OB_UNLIKELY(!is_inited_)) { - ret = OB_ERR_SYS; - LOG_ERROR("table store not is_inited_", K(ret), K(PRETTY_TS(*this))); - } else if (backup_major_pos < 0 || backup_major_pos >= copy_start_pos) { - // do nothing - } else if (backup_major_pos >= major_tables.count()) { - ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid args", K(ret), K(backup_major_pos), K(major_tables)); - } else { - ObITable* major_table = major_tables.at(backup_major_pos); - - if (OB_SUCC(ret)) { - if (table_count_ >= MAX_SSTABLE_CNT_IN_STORAGE) { - ret = OB_ERR_SYS; - LOG_ERROR("cannot build store with too many tables", K(ret), K(table_count_)); - } else if (!major_table->is_sstable()) { - ret = OB_ERR_SYS; - LOG_ERROR("major sstable must be sstable", K(ret), K(*major_table)); - } else { - tables_[table_count_++] = major_table; - major_table->inc_ref(); - ++start_pos_; - ++inc_pos_; - LOG_INFO("add backup major table", K(*major_table)); - } - } - } - return ret; -} - -int ObTableStore::inner_add_table(ObIArray& tables, const int64_t start) +int ObTableStore::inner_add_table(ObIArray &tables, const int64_t start) { int ret = OB_SUCCESS; @@ -896,7 +848,7 @@ int ObTableStore::check_ready_for_read() } else { // check major tables for (int64_t i = start_pos_; OB_SUCC(ret) && is_ready_for_read_ && i < inc_pos_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected null table", K(ret), KP(table), K(i), K(PRETTY_TS(*this))); @@ -910,9 +862,9 @@ int ObTableStore::check_ready_for_read() } // check if LogTsRanges are consecutive between all minor sstables - ObITable* last_table = nullptr; + ObITable *last_table = nullptr; for (int64_t i = inc_pos_; is_ready_for_read_ && OB_SUCC(ret) && i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected null table", K(ret), KP(table), K(i), K(PRETTY_TS(*this))); @@ -939,8 +891,8 @@ int ObTableStore::check_ready_for_read() return ret; } -int ObTableStore::get_next_major_merge_info(const int merge_version, int64_t& need_base_table_pos, - int64_t& next_major_version, int64_t& next_major_freeze_ts, int64_t& base_schema_version, int64_t& schema_version) +int ObTableStore::get_next_major_merge_info(const int merge_version, int64_t &need_base_table_pos, + int64_t &next_major_version, int64_t &next_major_freeze_ts, int64_t &base_schema_version, int64_t &schema_version) { int ret = OB_SUCCESS; ObFreezeInfoSnapshotMgr::FreezeInfo freeze_info; @@ -953,7 +905,7 @@ int ObTableStore::get_next_major_merge_info(const int merge_version, int64_t& ne LOG_WARN("major sstable not exist", K(ret), K(PRETTY_TS(*this))); } else { for (int64_t i = inc_pos_ - 1; OB_SUCC(ret) && i >= start_pos_; --i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected null table", K(ret), KP(table), K(i), K(PRETTY_TS(*this))); @@ -989,13 +941,13 @@ int ObTableStore::get_next_major_merge_info(const int merge_version, int64_t& ne return ret; } -int ObTableStore::get_major_merge_tables(const ObGetMergeTablesParam& param, ObGetMergeTablesResult& result) +int ObTableStore::get_major_merge_tables(const ObGetMergeTablesParam ¶m, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; int64_t next_major_version = 0; int64_t next_major_freeze_ts = 0; int64_t need_base_table_pos = -1; - ObSSTable* base_table = NULL; + ObSSTable *base_table = NULL; result.reset(); result.merge_version_ = param.merge_version_; result.suggest_merge_type_ = MAJOR_MERGE; @@ -1017,7 +969,7 @@ int ObTableStore::get_major_merge_tables(const ObGetMergeTablesParam& param, ObG LOG_WARN("failed to get latest major sstable for merge", K(ret)); } } else { - if (OB_ISNULL(base_table = static_cast(tables_[need_base_table_pos]))) { + if (OB_ISNULL(base_table = static_cast(tables_[need_base_table_pos]))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("Unexpected null table", K(ret), KP(base_table), K(need_base_table_pos), K(PRETTY_TS(*this))); } else if (next_major_version > param.merge_version_) { @@ -1091,13 +1043,13 @@ int ObTableStore::get_major_merge_tables(const ObGetMergeTablesParam& param, ObG } int ObTableStore::find_major_merge_inc_tables( - const ObSSTable& base_table, const int64_t next_major_freeze_ts, ObTablesHandle& handle) + const ObSSTable &base_table, const int64_t next_major_freeze_ts, ObTablesHandle &handle) { int ret = OB_SUCCESS; bool start_add_table_flag = false; bool need_add_complement_table_flag = true; for (int64_t i = inc_pos_; OB_SUCC(ret) && i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("Unexpected null table", K(ret), KP(table), K(i), K(PRETTY_TS(*this))); @@ -1130,7 +1082,7 @@ int ObTableStore::find_major_merge_inc_tables( return ret; } -int ObTableStore::add_minor_merge_result(ObITable* table, ObGetMergeTablesResult& result) +int ObTableStore::add_minor_merge_result(ObITable *table, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; @@ -1161,7 +1113,7 @@ int ObTableStore::add_minor_merge_result(ObITable* table, ObGetMergeTablesResult } // Used to adjust whether to do L0 Minor merge or L1 Minor merge -int ObTableStore::refine_mini_minor_merge_result(ObGetMergeTablesResult& result) +int ObTableStore::refine_mini_minor_merge_result(ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; @@ -1170,9 +1122,9 @@ int ObTableStore::refine_mini_minor_merge_result(ObGetMergeTablesResult& result) ret = OB_ERR_UNEXPECTED; LOG_WARN("Unexpected merge type to refine merge tables", K(result), K(ret)); } else { - common::ObSEArray mini_tables; - ObITable* table = NULL; - ObSSTable* sstable = NULL; + common::ObSEArray mini_tables; + ObITable *table = NULL; + ObSSTable *sstable = NULL; int64_t mini_sstable_size = 1; int64_t minor_sstable_size = 1; int64_t minor_sstable_count = 0; @@ -1183,7 +1135,7 @@ int ObTableStore::refine_mini_minor_merge_result(ObGetMergeTablesResult& result) } else if (table->is_memtable() || table->is_major_sstable()) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected table type", K(*table), K(ret)); - } else if (FALSE_IT(sstable = reinterpret_cast(table))) { + } else if (FALSE_IT(sstable = reinterpret_cast(table))) { } else if (table->is_mini_minor_sstable()) { mini_sstable_size += sstable->get_total_row_count(); if (OB_FAIL(mini_tables.push_back(table))) { @@ -1267,7 +1219,7 @@ int ObTableStore::refine_mini_minor_merge_result(ObGetMergeTablesResult& result) } int ObTableStore::get_mini_merge_tables( - const ObGetMergeTablesParam& param, const int64_t demand_multi_version_start, ObGetMergeTablesResult& result) + const ObGetMergeTablesParam ¶m, const int64_t demand_multi_version_start, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; int64_t merge_inc_base_version = 0; @@ -1306,7 +1258,7 @@ int ObTableStore::get_mini_merge_tables( } int ObTableStore::deal_with_minor_result( - const ObMergeType& merge_type, const int64_t demand_multi_version_start, ObGetMergeTablesResult& result) + const ObMergeType &merge_type, const int64_t demand_multi_version_start, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; if (result.handle_.empty()) { @@ -1326,14 +1278,14 @@ void ObTableStore::adjust_minor_merge_boundary(int64_t &min_snapshot, int64_t &m max_snapshot = INT64_MAX; if (table_count_ >= OB_EMERGENCY_TABLE_CNT) { min_snapshot = 0; - } else if (start_pos_ >= 0 && inc_pos_ > start_pos_) { // get last major sstable after start_pos_ + } else if (start_pos_ >= 0 && inc_pos_ > start_pos_) { // get last major sstable after start_pos_ min_snapshot = tables_[inc_pos_ - 1]->get_snapshot_version(); } } } int ObTableStore::get_mini_minor_merge_tables( - const ObGetMergeTablesParam& param, const int64_t multi_version_start, ObGetMergeTablesResult& result) + const ObGetMergeTablesParam ¶m, const int64_t multi_version_start, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; const ObMergeType merge_type = param.merge_type_; @@ -1398,8 +1350,8 @@ int ObTableStore::get_mini_minor_merge_tables( return ret; } -int ObTableStore::get_hist_minor_range(const ObIArray& freeze_infos, - const bool is_optimize, int64_t& min_snapshot_version, int64_t& max_snapshot_version) +int ObTableStore::get_hist_minor_range(const ObIArray &freeze_infos, + const bool is_optimize, int64_t &min_snapshot_version, int64_t &max_snapshot_version) { int ret = OB_SUCCESS; @@ -1412,7 +1364,7 @@ int ObTableStore::get_hist_minor_range(const ObIArrayget_base_version() < last_freeze_ts) { // skip small minor sstable - } else if (table->get_snapshot_version() > freeze_ts - || (is_strict_mode && table->get_max_merged_trans_version() > freeze_ts)) { + } else if (table->get_snapshot_version() > freeze_ts || + (is_strict_mode && table->get_max_merged_trans_version() > freeze_ts)) { if (cnt > max_cnt) { max_cnt = cnt; max_idx = idx; @@ -1453,7 +1405,7 @@ int ObTableStore::get_hist_minor_range(const ObIArrayget_latest_frozen_timestamp())) { // no freeze info found, wait normal mini minor to free sstable @@ -1540,10 +1492,10 @@ int ObTableStore::get_hist_minor_merge_tables( return ret; } -int ObTableStore::check_continues_and_get_schema_version(const ObMergeType& merge_type, ObGetMergeTablesResult& result) +int ObTableStore::check_continues_and_get_schema_version(const ObMergeType &merge_type, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; - ObITable* table = nullptr; + ObITable *table = nullptr; if (OB_UNLIKELY(!result.log_ts_range_.is_valid() || result.handle_.empty())) { ret = OB_ERR_SYS; @@ -1564,13 +1516,13 @@ int ObTableStore::check_continues_and_get_schema_version(const ObMergeType& merg return ret; } -int ObTableStore::is_memtable_need_merge(const ObMemtable& memtable, bool& need_merge) +int ObTableStore::is_memtable_need_merge(const ObMemtable &memtable, bool &need_merge) { int ret = OB_SUCCESS; need_merge = false; // when big transaction feature becomes stable, we could just use end_log_ts to judge need_merge if (table_count_ > start_pos_ && start_pos_ >= 0) { - ObITable* table = nullptr; + ObITable *table = nullptr; if (OB_ISNULL(table = tables_[table_count_ - 1])) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected null sstable", K(ret), K(PRETTY_TS(*this))); @@ -1617,8 +1569,8 @@ int ObTableStore::is_memtable_need_merge(const ObMemtable& memtable, bool& need_ return ret; } -int ObTableStore::find_mini_merge_tables(const ObGetMergeTablesParam& param, - const ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite& freeze_info, ObGetMergeTablesResult& result) +int ObTableStore::find_mini_merge_tables(const ObGetMergeTablesParam ¶m, + const ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite &freeze_info, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; int64_t max_snapshot_version = INT64_MAX; @@ -1640,7 +1592,7 @@ int ObTableStore::find_mini_merge_tables(const ObGetMergeTablesParam& param, max_snapshot_version = freeze_info.next.freeze_ts; } for (int64_t i = 0; OB_SUCC(ret) && i < frozen_memtables.get_count(); ++i) { - memtable::ObMemtable* memtable = static_cast(frozen_memtables.get_table(i)); + memtable::ObMemtable *memtable = static_cast(frozen_memtables.get_table(i)); bool need_merge = false; if (OB_ISNULL(memtable)) { ret = OB_ERR_SYS; @@ -1667,9 +1619,9 @@ int ObTableStore::find_mini_merge_tables(const ObGetMergeTablesParam& param, K(param), KPC(memtable)); break; - } else if (result.handle_.get_count() > 0 ) { - if (result.log_ts_range_.end_log_ts_ < memtable->get_start_log_ts() - || result.log_ts_range_.max_log_ts_ > memtable->get_end_log_ts()) { + } else if (result.handle_.get_count() > 0) { + if (result.log_ts_range_.end_log_ts_ < memtable->get_start_log_ts() || + result.log_ts_range_.max_log_ts_ > memtable->get_end_log_ts()) { FLOG_INFO("log id not continues, reset previous minor merge tables", K(i), "last_end_log_ts", @@ -1714,8 +1666,8 @@ int ObTableStore::find_mini_merge_tables(const ObGetMergeTablesParam& param, return ret; } -int ObTableStore::find_mini_minor_merge_tables(const ObGetMergeTablesParam& param, const int64_t min_snapshot_version, - const int64_t max_snapshot_version, const int64_t expect_multi_version, ObGetMergeTablesResult& result) +int ObTableStore::find_mini_minor_merge_tables(const ObGetMergeTablesParam ¶m, const int64_t min_snapshot_version, + const int64_t max_snapshot_version, const int64_t expect_multi_version, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; ObTablesHandle all_tables; @@ -1735,7 +1687,7 @@ int ObTableStore::find_mini_minor_merge_tables(const ObGetMergeTablesParam& para LOG_WARN("failed to get all tables", K(ret), K(PRETTY_TS(*this))); } for (int64_t i = inc_pos; OB_SUCC(ret) && i < all_tables.get_count(); ++i) { - ObITable* table = all_tables.get_table(i); + ObITable *table = all_tables.get_table(i); if (OB_UNLIKELY(nullptr == table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(i), K(PRETTY_TS(*this))); @@ -1746,8 +1698,8 @@ int ObTableStore::find_mini_minor_merge_tables(const ObGetMergeTablesParam& para continue; } else if (table->get_base_version() < min_snapshot_version) { continue; - } else if (is_multi_version_break(table->get_version_range(), result.version_range_.snapshot_version_) - && table->get_multi_version_start() > expect_multi_version) { + } else if (is_multi_version_break(table->get_version_range(), result.version_range_.snapshot_version_) && + table->get_multi_version_start() > expect_multi_version) { if (result.handle_.get_count() > 1) { // do not involve sstable with bigger uncontinue multi version than max_snapshot_version FLOG_INFO("Multi version start larger than max snapshot, stop find more minor sstables", @@ -1776,8 +1728,8 @@ int ObTableStore::find_mini_minor_merge_tables(const ObGetMergeTablesParam& para result.handle_.reset(); result.version_range_.reset(); result.log_ts_range_.reset(); - } else if (table->get_snapshot_version() > max_snapshot_version - || (is_strict_mode && table->get_max_merged_trans_version() > max_snapshot_version)) { + } else if (table->get_snapshot_version() > max_snapshot_version || + (is_strict_mode && table->get_max_merged_trans_version() > max_snapshot_version)) { // snapshot_version <= max_merged_trans_version <= upper_trans_version // upper_trans_version is more safe to keep the minor sstable do not // crossing the major freeze, but it's not always properly filled. @@ -1807,7 +1759,7 @@ int ObTableStore::find_mini_minor_merge_tables(const ObGetMergeTablesParam& para return ret; } -int ObTableStore::refine_mini_merge_result(ObGetMergeTablesResult& result) +int ObTableStore::refine_mini_merge_result(ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -1820,7 +1772,7 @@ int ObTableStore::refine_mini_merge_result(ObGetMergeTablesResult& result) ret = OB_NO_NEED_MERGE; LOG_WARN("no need minor merge", K(ret), K(result), K(PRETTY_TS(*this))); } else if (table_count_ > 0 && tables_[table_count_ - 1]->is_minor_sstable()) { - ObITable* last_table = tables_[table_count_ - 1]; + ObITable *last_table = tables_[table_count_ - 1]; if (result.log_ts_range_.start_log_ts_ > last_table->get_end_log_ts()) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("Unexpected uncontinuous log_ts_range in mini merge", K(ret), K(result), KPC(last_table)); @@ -1844,7 +1796,7 @@ int ObTableStore::refine_mini_merge_result(ObGetMergeTablesResult& result) return ret; } -int ObTableStore::refine_mini_merge_result_in_reboot_phase(ObITable& last_table, ObGetMergeTablesResult& result) +int ObTableStore::refine_mini_merge_result_in_reboot_phase(ObITable &last_table, ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; const int64_t last_end_log_ts = last_table.get_end_log_ts(); @@ -1886,7 +1838,7 @@ int ObTableStore::refine_mini_merge_result_in_reboot_phase(ObITable& last_table, return ret; } -int ObTableStore::add_complement_to_mini_merge_result(ObGetMergeTablesResult& result) +int ObTableStore::add_complement_to_mini_merge_result(ObGetMergeTablesResult &result) { int ret = OB_SUCCESS; if (OB_NOT_NULL(complement_minor_sstable_)) { @@ -1906,7 +1858,7 @@ int ObTableStore::add_complement_to_mini_merge_result(ObGetMergeTablesResult& re return ret; } -int ObTableStore::get_minor_schema_version(int64_t& schema_version) +int ObTableStore::get_minor_schema_version(int64_t &schema_version) { int ret = OB_SUCCESS; ObTablesHandle all_tables; @@ -1919,25 +1871,25 @@ int ObTableStore::get_minor_schema_version(int64_t& schema_version) } else { for (int64_t i = all_tables.get_count() - 1; OB_SUCC(ret) && i >= 0; --i) { int64_t tmp_schema_version = 0; - ObITable* table = all_tables.get_table(i); + ObITable *table = all_tables.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table should not be null", K(ret)); } else if (table->is_memtable()) { - tmp_schema_version = static_cast(table)->get_max_schema_version(); + tmp_schema_version = static_cast(table)->get_max_schema_version(); } else { #ifdef ERRSIM ret = E(EventTable::EN_SKIP_GLOBAL_SSTABLE_SCHEMA_VERSION) ret; if (OB_FAIL(ret)) { ret = OB_SUCCESS; if (table_id_ == pkey_.get_table_id() && - static_cast(table)->get_meta().create_snapshot_version_ == table->get_snapshot_version()) { + static_cast(table)->get_meta().create_snapshot_version_ == table->get_snapshot_version()) { LOG_INFO("skip global index major sstable", K(*table)); continue; } } #endif - tmp_schema_version = static_cast(table)->get_meta().schema_version_; + tmp_schema_version = static_cast(table)->get_meta().schema_version_; } if (OB_SUCC(ret) && tmp_schema_version > schema_version) { schema_version = tmp_schema_version; @@ -1962,8 +1914,8 @@ int ObTableStore::get_minor_schema_version(int64_t& schema_version) return ret; } -int ObTableStore::find_need_major_sstable(const common::ObIArray& major_tables, - const int64_t multi_version_start, int64_t& major_pos, ObITable*& major_table) +int ObTableStore::find_need_major_sstable(const common::ObIArray &major_tables, + const int64_t multi_version_start, int64_t &major_pos, ObITable *&major_table) { int ret = OB_SUCCESS; major_pos = -1; @@ -1996,34 +1948,7 @@ int ObTableStore::find_need_major_sstable(const common::ObIArray& maj return ret; } -int ObTableStore::find_need_backup_major_sstable( - const common::ObIArray& major_tables, const int64_t backup_snapshot_version, int64_t& major_pos) -{ - int ret = OB_SUCCESS; - major_pos = -1; - - if (OB_UNLIKELY(!is_inited_)) { - ret = OB_ERR_SYS; - LOG_ERROR("table store not is_inited_", K(ret), K(PRETTY_TS(*this))); - } - - for (int64_t i = major_tables.count() - 1; OB_SUCC(ret) && i >= 0; --i) { - if (major_tables.at(i)->get_snapshot_version() <= backup_snapshot_version && - major_tables.at(i)->is_major_sstable()) { - major_pos = i; - LOG_INFO("found first need backup major table", - K(major_pos), - K(backup_snapshot_version), - K(i), - "major_table", - *major_tables.at(i)); - break; - } - } - return ret; -} - -int ObTableStore::cal_multi_version_start(const int64_t demand_multi_version_start, ObVersionRange& version_range) +int ObTableStore::cal_multi_version_start(const int64_t demand_multi_version_start, ObVersionRange &version_range) { int ret = OB_SUCCESS; @@ -2043,7 +1968,7 @@ int ObTableStore::cal_multi_version_start(const int64_t demand_multi_version_sta return ret; } -int ObTableStore::cal_minor_merge_inc_base_version(int64_t& inc_base_version) +int ObTableStore::cal_minor_merge_inc_base_version(int64_t &inc_base_version) { int ret = OB_SUCCESS; inc_base_version = 0; @@ -2064,14 +1989,14 @@ int ObTableStore::cal_minor_merge_inc_base_version(int64_t& inc_base_version) return ret; } -int ObTableStore::cal_mini_merge_inc_base_version(int64_t& inc_base_version) +int ObTableStore::cal_mini_merge_inc_base_version(int64_t &inc_base_version) { int ret = OB_SUCCESS; if (OB_FAIL(cal_minor_merge_inc_base_version(inc_base_version))) { LOG_WARN("failed to cal_minor_merge_base_version", K(ret), K(table_id_)); } else { ObTablesHandle memtables; - ObMemtable* first_memtable = nullptr; + ObMemtable *first_memtable = nullptr; const bool include_active_memtable = false; if (OB_FAIL(get_memtables(include_active_memtable, memtables))) { if (OB_ENTRY_NOT_EXIST == ret) { @@ -2105,7 +2030,7 @@ int ObTableStore::cal_mini_merge_inc_base_version(int64_t& inc_base_version) return ret; } -int ObTableStore::get_boundary_major_sstable(const bool last, ObITable*& major_table) +int ObTableStore::get_boundary_major_sstable(const bool last, ObITable *&major_table) { int ret = OB_SUCCESS; major_table = nullptr; @@ -2123,7 +2048,7 @@ int ObTableStore::get_boundary_major_sstable(const bool last, ObITable*& major_t return ret; } -int ObTableStore::get_boundary_minor_sstable(const bool last, ObITable*& minor_table) +int ObTableStore::get_boundary_minor_sstable(const bool last, ObITable *&minor_table) { int ret = OB_SUCCESS; minor_table = nullptr; @@ -2140,7 +2065,7 @@ int ObTableStore::get_boundary_minor_sstable(const bool last, ObITable*& minor_t return ret; } -int ObTableStore::get_table_count(int64_t& table_count) const +int ObTableStore::get_table_count(int64_t &table_count) const { int ret = OB_SUCCESS; table_count = 0; @@ -2154,7 +2079,7 @@ int ObTableStore::get_table_count(int64_t& table_count) const return ret; } -int ObTableStore::check_table_count_safe(bool& is_safe) const +int ObTableStore::check_table_count_safe(bool &is_safe) const { int ret = OB_SUCCESS; is_safe = false; @@ -2171,7 +2096,7 @@ int ObTableStore::check_table_count_safe(bool& is_safe) const return ret; } -int ObTableStore::has_major_sstable(bool& has_major) +int ObTableStore::has_major_sstable(bool &has_major) { int ret = OB_SUCCESS; has_major = false; @@ -2186,7 +2111,7 @@ int ObTableStore::has_major_sstable(bool& has_major) return ret; } -int64_t ObTableStore::to_string(char* buf, const int64_t buf_len) const +int64_t ObTableStore::to_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; if (OB_ISNULL(buf) || buf_len <= 0) { @@ -2208,7 +2133,7 @@ int64_t ObTableStore::to_string(char* buf, const int64_t buf_len) const J_COMMA(); J_ARRAY_START(); for (int64_t i = 0; i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (NULL != table && table->is_sstable()) { J_OBJ_START(); J_KV(K(i), @@ -2273,7 +2198,7 @@ int ObTableStore::finish_replay(const int64_t multi_version_start) return ret; } -bool ObTableStore::ObITableSnapshotVersionCompare::operator()(const ObITable* lstore, const ObITable* rstore) const +bool ObTableStore::ObITableSnapshotVersionCompare::operator()(const ObITable *lstore, const ObITable *rstore) const { bool bret = false; int tmp_ret = OB_SUCCESS; @@ -2295,7 +2220,7 @@ bool ObTableStore::ObITableSnapshotVersionCompare::operator()(const ObITable* ls return bret; } -bool ObTableStore::ObITableIDCompare::operator()(const ObITable* ltable, const ObITable* rtable) const +bool ObTableStore::ObITableIDCompare::operator()(const ObITable *ltable, const ObITable *rtable) const { bool bret = false; int tmp_ret = OB_SUCCESS; @@ -2313,7 +2238,7 @@ bool ObTableStore::ObITableIDCompare::operator()(const ObITable* ltable, const O return bret; } -bool ObTableStore::ObITableLogTsRangeCompare::operator()(const ObITable* ltable, const ObITable* rtable) const +bool ObTableStore::ObITableLogTsRangeCompare::operator()(const ObITable *ltable, const ObITable *rtable) const { bool bret = false; int tmp_ret = OB_SUCCESS; @@ -2351,7 +2276,7 @@ bool ObTableStore::ObITableLogTsRangeCompare::operator()(const ObITable* ltable, return bret; } -int ObTableStore::sort_minor_tables(ObArray& tables) +int ObTableStore::sort_minor_tables(ObArray &tables) { int ret = OB_SUCCESS; @@ -2368,7 +2293,7 @@ int ObTableStore::sort_minor_tables(ObArray& tables) return ret; } -int ObTableStore::sort_major_tables(ObArray& tables) +int ObTableStore::sort_major_tables(ObArray &tables) { int ret = OB_SUCCESS; @@ -2386,11 +2311,10 @@ int ObTableStore::sort_major_tables(ObArray& tables) } // delete old major sstable and minor sstable -int ObTableStore::need_remove_old_table(const ObVersion& kept_min_version, const int64_t multi_version_start, - const int64_t backup_snapshot_version, int64_t& real_kept_major_num, bool& need_remove) +int ObTableStore::need_remove_old_table(const ObVersion &kept_min_version, const int64_t multi_version_start, + int64_t &real_kept_major_num, bool &need_remove) { int ret = OB_SUCCESS; - int64_t need_backup_version = -1; need_remove = false; if (inc_pos_ < 1) { @@ -2399,31 +2323,22 @@ int ObTableStore::need_remove_old_table(const ObVersion& kept_min_version, const } else if (OB_UNLIKELY(!is_valid())) { ret = OB_NOT_INIT; LOG_WARN("not valid", K(ret), K(PRETTY_TS(*this))); - } else if (!kept_min_version.is_valid() || multi_version_start <= 0 || backup_snapshot_version < 0) { + } else if (!kept_min_version.is_valid() || multi_version_start <= 0) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid args", K(ret), K(kept_min_version), K(multi_version_start), K(backup_snapshot_version)); + LOG_WARN("invalid args", K(ret), K(kept_min_version), K(multi_version_start)); } else { - // TODO one loop is enough - for (int64_t i = inc_pos_ - 1; i >= 0; --i) { - ObITable* major_sstable = tables_[i]; - if (major_sstable->is_major_sstable() && major_sstable->get_snapshot_version() <= backup_snapshot_version) { - need_backup_version = major_sstable->get_version().major_; - break; - } - } // check old major sstable before start_pos for (int64_t i = 0; OB_SUCC(ret) && i < start_pos_ && !need_remove; ++i) { - ObITable* major_sstable = tables_[i]; + ObITable *major_sstable = tables_[i]; if (major_sstable->is_major_sstable()) { - if (major_sstable->get_version().major_ < kept_min_version && - major_sstable->get_version().major_ != need_backup_version) { + if (major_sstable->get_version().major_ < kept_min_version) { need_remove = true; } } } if (OB_SUCC(ret) && need_remove) { - ObITable* latest_major_sstable = nullptr; + ObITable *latest_major_sstable = nullptr; if (OB_FAIL(get_boundary_major_sstable(true, latest_major_sstable))) { LOG_WARN("Failed to get last major sstable", K(ret)); } else if (OB_ISNULL(latest_major_sstable)) { @@ -2443,7 +2358,7 @@ int ObTableStore::need_remove_old_table(const ObVersion& kept_min_version, const // check major sstable after start_pos const int64_t next_pos = start_pos_ + 1; if (next_pos < inc_pos_) { - ObITable* major_sstable = tables_[next_pos]; + ObITable *major_sstable = tables_[next_pos]; if (major_sstable->is_major_sstable() && major_sstable->get_snapshot_version() < multi_version_start) { need_remove = true; LOG_INFO("need remove unneed major sstable for multi_version_start", @@ -2457,13 +2372,13 @@ int ObTableStore::need_remove_old_table(const ObVersion& kept_min_version, const // we fill upper trans version of minor sstable after transaction status determined // now we also should check if there is some minor need to be recycled if (OB_SUCC(ret) && !need_remove && inc_pos_ < table_count_) { - ObITable* first_minor_table = nullptr; + ObITable *first_minor_table = nullptr; if (OB_ISNULL(first_minor_table = tables_[inc_pos_])) { ret = OB_ERR_SYS; STORAGE_LOG(ERROR, "Unexpected null sstable", K(ret), K(PRETTY_TS(*this))); } else if (first_minor_table->get_upper_trans_version() == INT64_MAX) { } else { - ObITable* need_major_table = nullptr; + ObITable *need_major_table = nullptr; for (int64_t i = inc_pos_ - 1; OB_SUCC(ret) && i >= start_pos_; --i) { if (OB_ISNULL(need_major_table = tables_[i])) { ret = OB_ERR_SYS; @@ -2494,7 +2409,7 @@ int ObTableStore::update_replay_tables() LOG_ERROR("not inited", K(ret), K(PRETTY_TS(*this))); } else { for (int64_t i = 0; OB_SUCC(ret) && i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(i), K(PRETTY_TS(*this))); @@ -2518,8 +2433,8 @@ int ObTableStore::update_multi_version_start() LOG_ERROR("ObTableStore is not inited", K(ret), K(PRETTY_TS(*this))); } else if (is_valid()) { multi_version_start_ = -1; - ObITable* table = nullptr; - ObITable* last_table = nullptr; + ObITable *table = nullptr; + ObITable *last_table = nullptr; for (int64_t i = inc_pos_; OB_SUCC(ret) && i < table_count_; i++) { if (OB_ISNULL(table = tables_[i])) { ret = OB_ERR_SYS; @@ -2558,7 +2473,7 @@ int ObTableStore::update_multi_version_start() return ret; } -int ObTableStore::equals(const ObTableStore& other, bool& is_equal) +int ObTableStore::equals(const ObTableStore &other, bool &is_equal) { int ret = OB_SUCCESS; @@ -2586,7 +2501,7 @@ int ObTableStore::equals(const ObTableStore& other, bool& is_equal) return ret; } -int ObTableStore::get_replay_tables(ObIArray& replay_tables) +int ObTableStore::get_replay_tables(ObIArray &replay_tables) { int ret = OB_SUCCESS; replay_tables.reset(); @@ -2600,7 +2515,7 @@ int ObTableStore::get_replay_tables(ObIArray& replay_tables) return ret; } -int ObTableStore::get_all_memtables(const bool include_active_memtable, ObTablesHandle& handle) +int ObTableStore::get_all_memtables(const bool include_active_memtable, ObTablesHandle &handle) { int ret = OB_SUCCESS; const bool reset_handle = false; @@ -2611,14 +2526,14 @@ int ObTableStore::get_all_memtables(const bool include_active_memtable, ObTables return ret; } -int ObTableStore::get_memtables(const bool include_active_memtable, ObTablesHandle& handle) +int ObTableStore::get_memtables(const bool include_active_memtable, ObTablesHandle &handle) { int ret = OB_SUCCESS; const bool reset_handle = false; int64_t start_log_ts = 0; int64_t start_snapshot_version = -1; if (OB_LIKELY(table_count_ > 0)) { - ObITable* last_table = tables_[table_count_ - 1]; + ObITable *last_table = tables_[table_count_ - 1]; if (last_table->is_table_with_log_ts_range()) { start_log_ts = last_table->get_end_log_ts(); start_snapshot_version = last_table->get_snapshot_version(); @@ -2631,7 +2546,7 @@ int ObTableStore::get_memtables(const bool include_active_memtable, ObTablesHand return ret; } -int ObTableStore::get_all_sstables(const bool need_complemnt, ObTablesHandle& handle) +int ObTableStore::get_all_sstables(const bool need_complemnt, ObTablesHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -2658,10 +2573,10 @@ int ObTableStore::get_all_sstables(const bool need_complemnt, ObTablesHandle& ha } int ObTableStore::get_neighbour_freeze_info( - const int64_t snapshot_version, ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite& freeze_info) + const int64_t snapshot_version, ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite &freeze_info) { int ret = OB_SUCCESS; - ObITable* last_major_sstable = nullptr; + ObITable *last_major_sstable = nullptr; if (OB_FAIL(get_boundary_major_sstable(true, last_major_sstable))) { LOG_WARN("Failed to get last major sstable", K(ret)); } else if (OB_SUCC(freeze_info_mgr_->get_neighbour_major_freeze(snapshot_version, freeze_info))) { @@ -2691,7 +2606,7 @@ int ObTableStore::get_neighbour_freeze_info( return ret; } -int ObTableStore::check_need_mini_minor_merge(const bool using_remote_memstore, bool& need_merge) +int ObTableStore::check_need_mini_minor_merge(const bool using_remote_memstore, bool &need_merge) { int ret = OB_SUCCESS; need_merge = false; @@ -2763,7 +2678,7 @@ int ObTableStore::check_need_mini_minor_merge(const bool using_remote_memstore, } int ObTableStore::judge_need_mini_minor_merge( - const bool using_remote_memstore, const int64_t minor_check_snapshot_version, bool& need_merge) + const bool using_remote_memstore, const int64_t minor_check_snapshot_version, bool &need_merge) { int ret = OB_SUCCESS; const int64_t delay_merge_schedule_interval = GCONF._minor_compaction_interval; @@ -2794,11 +2709,11 @@ int64_t ObTableStore::cal_hist_minor_merge_threshold() const return MIN((1 + hist_threashold) * OB_HIST_MINOR_FACTOR, MAX_TABLE_CNT_IN_STORAGE / 2); } -int ObTableStore::check_need_hist_minor_merge(bool& need_merge) +int ObTableStore::check_need_hist_minor_merge(bool &need_merge) { int ret = OB_SUCCESS; const int64_t hist_threashold = cal_hist_minor_merge_threshold(); - ObITable* first_major_table = nullptr; + ObITable *first_major_table = nullptr; need_merge = false; if (IS_NOT_INIT) { @@ -2844,7 +2759,7 @@ int ObTableStore::check_need_hist_minor_merge(bool& need_merge) return ret; } -int ObTableStore::set_replay_sstables(const bool is_replay_old, const common::ObIArray& sstables) +int ObTableStore::set_replay_sstables(const bool is_replay_old, const common::ObIArray &sstables) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_inited_)) { @@ -2872,7 +2787,7 @@ int ObTableStore::set_replay_sstables(const bool is_replay_old, const common::Ob LOG_WARN("table count is not equal", K(ret), K(sstables), K(replay_tables_)); } else { // push right sstables into tables_ & replay_tables_ replay_tables_.reuse(); - ObSSTable* sstable = nullptr; + ObSSTable *sstable = nullptr; table_count_ = 0; for (int64_t i = 0; OB_SUCC(ret) && i < sstables.count(); ++i) { if (OB_ISNULL(sstable = sstables.at(i))) { @@ -2904,12 +2819,12 @@ int ObTableStore::set_replay_sstables(const bool is_replay_old, const common::Ob return ret; } -bool ObTableStore::is_own_table(const ObITable* table) +bool ObTableStore::is_own_table(const ObITable *table) { return table->get_partition_key() == pkey_; } -int ObTableStore::check_complete(bool& is_complete) +int ObTableStore::check_complete(bool &is_complete) { int ret = OB_SUCCESS; ObTablesHandle handle; @@ -2925,7 +2840,7 @@ int ObTableStore::check_complete(bool& is_complete) return ret; } -bool ObTableStore::check_complete_(const ObTablesHandle& handle) +bool ObTableStore::check_complete_(const ObTablesHandle &handle) { bool is_complete = true; bool is_major_exist = false; @@ -2944,8 +2859,8 @@ bool ObTableStore::check_complete_(const ObTablesHandle& handle) } for (int64_t i = 0; is_complete && i < handle.get_count() - 1; i++) { - ObITable* cur_table = handle.get_table(i); - ObITable* next_table = handle.get_table(i + 1); + ObITable *cur_table = handle.get_table(i); + ObITable *next_table = handle.get_table(i + 1); if (cur_table->is_table_with_log_ts_range() && cur_table->get_end_log_ts() < next_table->get_start_log_ts()) { is_complete = false; } @@ -2957,7 +2872,7 @@ bool ObTableStore::check_complete_(const ObTablesHandle& handle) } // TODO merge into get_all_tables -int ObTableStore::get_all_tables_from_start(ObTablesHandle& handle) +int ObTableStore::get_all_tables_from_start(ObTablesHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -2985,7 +2900,7 @@ int ObTableStore::get_all_tables_from_start(ObTablesHandle& handle) } // TODO after buffer minor move to inc_pos_ - 1, we also should add buffer minor -int ObTableStore::get_minor_sstables(ObTablesHandle& handle) +int ObTableStore::get_minor_sstables(ObTablesHandle &handle) { int ret = OB_SUCCESS; if (is_valid()) { @@ -2998,24 +2913,24 @@ int ObTableStore::get_minor_sstables(ObTablesHandle& handle) return ret; } -int ObTableStore::get_min_schema_version(int64_t& min_schema_version) +int ObTableStore::get_min_schema_version(int64_t &min_schema_version) { int ret = OB_SUCCESS; - ObITable* table = nullptr; + ObITable *table = nullptr; min_schema_version = INT64_MAX; for (int64_t i = 0; OB_SUCC(ret) && i < table_count_; i++) { if (OB_ISNULL(table = tables_[i])) { ret = OB_ERR_SYS; LOG_ERROR("Unexpected null sstable", K(ret), K(i), K(PRETTY_TS(*this))); } else { - min_schema_version = min(min_schema_version, static_cast(table)->get_meta().schema_version_); + min_schema_version = min(min_schema_version, static_cast(table)->get_meta().schema_version_); } } return ret; } int ObTableStore::get_mark_deletion_tables( - const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle& handle) + const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle &handle) { UNUSED(snapshot_version); int ret = OB_SUCCESS; @@ -3028,7 +2943,7 @@ int ObTableStore::get_mark_deletion_tables( LOG_WARN("failed to get_all_tables", K(ret), K(PRETTY_TS(*this))); } else { for (int64_t i = 0; OB_SUCC(ret) && i < tmp_handle.get_count(); ++i) { - ObITable* table = tmp_handle.get_table(i); + ObITable *table = tmp_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table is null", K(ret), K(i), K(PRETTY_TS(*this))); @@ -3062,7 +2977,7 @@ int ObTableStore::clear_complement_minor_sstable() return ret; } -int ObTableStore::get_schema_version(int64_t& schema_version) const +int ObTableStore::get_schema_version(int64_t &schema_version) const { int ret = OB_SUCCESS; if (IS_NOT_INIT) { @@ -3072,7 +2987,7 @@ int ObTableStore::get_schema_version(int64_t& schema_version) const ret = OB_ENTRY_NOT_EXIST; LOG_WARN("table store is empty", K(ret), K(table_id_)); } else { - schema_version = static_cast(tables_[0])->get_meta().schema_version_; + schema_version = static_cast(tables_[0])->get_meta().schema_version_; } return ret; } @@ -3086,13 +3001,13 @@ int ObTableStore::get_schema_version(int64_t& schema_version) const */ int ObTableStore::set_reference_tables( - ObTablesHandle& new_handle, ObTablesHandle& old_handle, const int64_t memtable_base_version, bool& need_update) + ObTablesHandle &new_handle, ObTablesHandle &old_handle, const int64_t memtable_base_version, bool &need_update) { int ret = OB_SUCCESS; need_update = true; ObTablesHandle handle_without_complement; ObTablesHandle old_handle_without_complement; - ObSSTable* complement_sstable = NULL; + ObSSTable *complement_sstable = NULL; if (OB_UNLIKELY(!is_inited_)) { ret = OB_NOT_INIT; LOG_ERROR("not inited, fatal error", K(ret)); @@ -3118,7 +3033,7 @@ int ObTableStore::set_reference_tables( LOG_WARN("failed to push back table", K(ret), K(PRETTY_TS(*this))); } } else { - complement_sstable = static_cast(new_handle.get_table(i)); + complement_sstable = static_cast(new_handle.get_table(i)); } } @@ -3132,8 +3047,8 @@ int ObTableStore::set_reference_tables( while (OB_SUCC(ret) && pos < handle_without_complement.get_count() && pos < old_handle_without_complement.get_count()) { - ObITable* new_table = handle_without_complement.get_table(pos); - ObITable* old_table = old_handle_without_complement.get_table(pos); + ObITable *new_table = handle_without_complement.get_table(pos); + ObITable *old_table = old_handle_without_complement.get_table(pos); if (old_table->get_key() == new_table->get_key()) { tables_[table_count_++] = new_table; new_table->inc_ref(); @@ -3144,7 +3059,7 @@ int ObTableStore::set_reference_tables( } for (int64_t i = pos; OB_SUCC(ret) && i < handle_without_complement.get_count(); i++) { - ObITable* new_table = handle_without_complement.get_table(i); + ObITable *new_table = handle_without_complement.get_table(i); if (new_table->is_sstable()) { tables_[table_count_++] = new_table; new_table->inc_ref(); @@ -3152,7 +3067,7 @@ int ObTableStore::set_reference_tables( } for (int64_t i = pos; OB_SUCC(ret) && i < old_handle_without_complement.get_count(); i++) { - ObITable* old_table = old_handle_without_complement.get_table(i); + ObITable *old_table = old_handle_without_complement.get_table(i); if (OB_ISNULL(old_table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(pkey_), K(table_id_)); @@ -3204,7 +3119,7 @@ int ObTableStore::set_reference_tables( * Check the old_handle, not this table_store * */ int ObTableStore::check_need_split( - const ObTablesHandle& old_handle, common::ObVersion& split_version, bool& need_split, bool& need_minor_split) + const ObTablesHandle &old_handle, common::ObVersion &split_version, bool &need_split, bool &need_minor_split) { int ret = OB_SUCCESS; bool can_split = true; @@ -3248,7 +3163,7 @@ int ObTableStore::check_need_split( return ret; } -int ObTableStore::is_physical_split_finished(bool& is_physical_split_finish) +int ObTableStore::is_physical_split_finished(bool &is_physical_split_finish) { int ret = OB_SUCCESS; ObTablesHandle handle; @@ -3269,7 +3184,7 @@ int ObTableStore::is_physical_split_finished(bool& is_physical_split_finish) return ret; } -int ObTableStore::is_physical_split_finished(ObTablesHandle& old_handle, bool& is_physical_split_finish) +int ObTableStore::is_physical_split_finished(ObTablesHandle &old_handle, bool &is_physical_split_finish) { int ret = OB_SUCCESS; int64_t major_split_pos = -1; @@ -3285,10 +3200,10 @@ int ObTableStore::is_physical_split_finished(ObTablesHandle& old_handle, bool& i return ret; } -int ObTableStore::get_physical_split_info(ObVirtualPartitionSplitInfo& split_info) +int ObTableStore::get_physical_split_info(ObVirtualPartitionSplitInfo &split_info) { int ret = OB_SUCCESS; - ObSSTable* table = NULL; + ObSSTable *table = NULL; ObTablesHandle old_handle; int64_t major_split_pos = -1; int64_t first_reference_pos = -1; @@ -3310,11 +3225,11 @@ int ObTableStore::get_physical_split_info(ObVirtualPartitionSplitInfo& split_inf return ret; } -int ObTableStore::get_reference_tables(ObTablesHandle& handle) +int ObTableStore::get_reference_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObITable* latest_major_sstable = NULL; + ObITable *latest_major_sstable = NULL; handle.reset(); if (OB_UNLIKELY(!is_valid())) { ret = OB_ERR_SYS; @@ -3349,7 +3264,7 @@ int ObTableStore::get_reference_tables(ObTablesHandle& handle) } // After p0 minor sstable+memtable are spilted, p1 need to update table_store and take split sstables -int ObTableStore::build_minor_split_store(const ObTablesHandle& old_handle, ObTablesHandle& handle, bool& need_update) +int ObTableStore::build_minor_split_store(const ObTablesHandle &old_handle, ObTablesHandle &handle, bool &need_update) { int ret = OB_SUCCESS; bool has_fetch_split_table = false; @@ -3383,7 +3298,7 @@ int ObTableStore::build_minor_split_store(const ObTablesHandle& old_handle, ObTa } else { start_pos_ = 0; for (int64_t i = 0; OB_SUCC(ret) && i < old_handle.get_count(); i++) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(pkey_), K(table_id_), K(old_handle), K(i)); @@ -3442,7 +3357,7 @@ int ObTableStore::build_minor_split_store(const ObTablesHandle& old_handle, ObTa // After the p0 major sstable is split, p1 updates table_store, // taking the sstable belonging to p1 after the split and the major sstable of the unsplit part of p0 -int ObTableStore::build_major_split_store(const ObTablesHandle& old_handle, ObTablesHandle& handle, bool& need_update) +int ObTableStore::build_major_split_store(const ObTablesHandle &old_handle, ObTablesHandle &handle, bool &need_update) { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; @@ -3467,7 +3382,7 @@ int ObTableStore::build_major_split_store(const ObTablesHandle& old_handle, ObTa need_update = false; LOG_INFO("no need to build major split table store", K(ret), K(old_handle)); } else { - ObITable* table = old_handle.get_table(major_split_pos); + ObITable *table = old_handle.get_table(major_split_pos); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(pkey_), K(table_id_)); @@ -3479,7 +3394,7 @@ int ObTableStore::build_major_split_store(const ObTablesHandle& old_handle, ObTa table_count_++; for (int64_t i = 0; OB_SUCC(ret) && i < old_handle.get_count(); i++) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(pkey_), K(table_id_)); @@ -3536,7 +3451,7 @@ bool ObTableStore::is_spliting() return is_spliting; } -int ObTableStore::check_can_split(bool& can_split) +int ObTableStore::check_can_split(bool &can_split) { int ret = OB_SUCCESS; bool is_complete = false; @@ -3560,17 +3475,17 @@ int ObTableStore::check_can_split(bool& can_split) return ret; } -int ObTableStore::check_can_split(const ObTablesHandle& old_handle, bool& can_split) +int ObTableStore::check_can_split(const ObTablesHandle &old_handle, bool &can_split) { int ret = OB_SUCCESS; ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite freeze_info; - ObITable* minor_sstable = NULL; + ObITable *minor_sstable = NULL; can_split = true; - const ObPartitionKey& memtable_pkey = pg_memtable_mgr_->get_pkey(); + const ObPartitionKey &memtable_pkey = pg_memtable_mgr_->get_pkey(); // A memtable without a source partition can be physically split for (int64_t i = old_handle.get_count() - 1; can_split && i >= 0; i--) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (table->get_partition_key() != memtable_pkey && table->is_memtable()) { can_split = false; if (REACH_TIME_INTERVAL(60 * 1000 * 1000)) { @@ -3582,7 +3497,7 @@ int ObTableStore::check_can_split(const ObTablesHandle& old_handle, bool& can_sp // When merging and splitting concurrently, make sure that multiple copies are split under the same major version for (int64_t i = old_handle.get_count() - 1; OB_SUCC(ret) && can_split && i >= 0; i--) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (!is_own_table(table) && table->is_minor_sstable() && NULL == minor_sstable) { minor_sstable = table; } else if (!is_own_table(table) && table->is_major_sstable() && NULL != minor_sstable) { @@ -3603,7 +3518,7 @@ int ObTableStore::check_can_split(const ObTablesHandle& old_handle, bool& can_sp // 2. After the machine is restarted, it is necessary to determine whether // there is a hole between the table store and the active memtable int ObTableStore::check_need_reference_tables( - ObTablesHandle& old_handle, const int64_t memtable_base_version, bool& need_reference) + ObTablesHandle &old_handle, const int64_t memtable_base_version, bool &need_reference) { int ret = OB_SUCCESS; int64_t base_version = 0; @@ -3642,20 +3557,20 @@ int ObTableStore::check_need_reference_tables( } int ObTableStore::get_minor_split_table_pos( - const ObTablesHandle& old_handle, int64_t& first_reference_pos, int64_t& last_reference_pos) + const ObTablesHandle &old_handle, int64_t &first_reference_pos, int64_t &last_reference_pos) { int ret = OB_SUCCESS; first_reference_pos = -1; last_reference_pos = -1; - const ObPartitionKey& pgkey = pg_memtable_mgr_->get_pkey(); + const ObPartitionKey &pgkey = pg_memtable_mgr_->get_pkey(); for (int64_t i = old_handle.get_count() - 1; OB_SUCC(ret) && i >= 0; i--) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(pkey_), K(table_id_)); } else { - const ObITable::TableKey& table_key = table->get_key(); + const ObITable::TableKey &table_key = table->get_key(); if ((table_key.is_minor_sstable() && table_key.pkey_ != pkey_) || (table_key.is_memtable() && table_key.pkey_ != pgkey)) { if (-1 == last_reference_pos) { @@ -3668,12 +3583,12 @@ int ObTableStore::get_minor_split_table_pos( return ret; } -int ObTableStore::get_major_split_table_pos(const ObTablesHandle& old_handle, int64_t& pos) +int ObTableStore::get_major_split_table_pos(const ObTablesHandle &old_handle, int64_t &pos) { int ret = OB_SUCCESS; pos = -1; for (int64_t i = old_handle.get_count() - 1; OB_SUCC(ret) && i >= 0; i--) { - ObITable* table = old_handle.get_table(i); + ObITable *table = old_handle.get_table(i); if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_ERROR("table must not null", K(ret), K(pkey_), K(table_id_)); @@ -3686,7 +3601,7 @@ int ObTableStore::get_major_split_table_pos(const ObTablesHandle& old_handle, in return ret; } -int ObTableStore::get_major_split_tables(ObTablesHandle& handle) +int ObTableStore::get_major_split_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; int64_t pos = -1; @@ -3709,7 +3624,7 @@ int ObTableStore::get_major_split_tables(ObTablesHandle& handle) return ret; } -int ObTableStore::get_minor_split_tables(ObTablesHandle& handle) +int ObTableStore::get_minor_split_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; int64_t first_reference_pos = -1; @@ -3737,7 +3652,7 @@ int ObTableStore::get_minor_split_tables(ObTablesHandle& handle) } // Migrate section -int ObTableStore::check_can_migrate(bool& can_migrate) +int ObTableStore::check_can_migrate(bool &can_migrate) { int ret = OB_SUCCESS; ObTablesHandle handle; @@ -3751,7 +3666,7 @@ int ObTableStore::check_can_migrate(bool& can_migrate) can_migrate = check_complete_(handle); for (int64_t i = handle.get_count() - 1; can_migrate && i >= 0; i--) { - ObITable* table = handle.get_table(i); + ObITable *table = handle.get_table(i); if (table->is_memtable() && table->get_partition_key() != pg_memtable_mgr_->get_pkey()) { can_migrate = false; if (REACH_TIME_INTERVAL(60 * 1000 * 1000)) { @@ -3766,7 +3681,7 @@ int ObTableStore::check_can_migrate(bool& can_migrate) } // TODO check table store continuous with end_log_ts of major sstable -int ObTableStore::get_continue_tables(ObTablesHandle& handle) +int ObTableStore::get_continue_tables(ObTablesHandle &handle) { int ret = OB_SUCCESS; bool has_major = false; @@ -3786,7 +3701,7 @@ int ObTableStore::get_continue_tables(ObTablesHandle& handle) } for (int64_t i = start_pos_; i < inc_pos_ && OB_SUCC(ret); ++i) { - ObSSTable* sstable = static_cast(tables_[i]); + ObSSTable *sstable = static_cast(tables_[i]); if (OB_ISNULL(sstable)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("error unexpected, table must not be NULL", K(ret), K(i), K(PRETTY_TS(*this))); @@ -3800,8 +3715,8 @@ int ObTableStore::get_continue_tables(ObTablesHandle& handle) } if (OB_SUCC(ret) && has_major) { - ObITable* last_table = nullptr; - ObITable* curr_table = nullptr; + ObITable *last_table = nullptr; + ObITable *curr_table = nullptr; for (int64_t i = inc_pos_; OB_SUCC(ret) && i < table_count_; ++i) { if (OB_ISNULL(curr_table = tables_[i])) { ret = OB_ERR_SYS; @@ -3820,7 +3735,7 @@ int ObTableStore::get_continue_tables(ObTablesHandle& handle) } int ObTableStore::get_needed_local_tables_for_migrate( - const ObMigrateRemoteTableInfo& remote_table_info, ObTablesHandle& handle) + const ObMigrateRemoteTableInfo &remote_table_info, ObTablesHandle &handle) { int ret = OB_SUCCESS; handle.reset(); @@ -3836,7 +3751,7 @@ int ObTableStore::get_needed_local_tables_for_migrate( bool need_add = !remote_table_info.has_major(); // Keep the major sstable older than the source for (int64_t i = inc_pos_ - 1; OB_SUCC(ret) && i >= 0; --i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_ISNULL(table)) { ret = OB_ERR_SYS; LOG_WARN("table should not be null", K(ret)); @@ -3851,7 +3766,7 @@ int ObTableStore::get_needed_local_tables_for_migrate( return ret; } -int ObTableStore::get_multi_version_start(int64_t& multi_version_start) +int ObTableStore::get_multi_version_start(int64_t &multi_version_start) { int ret = OB_SUCCESS; multi_version_start = INT64_MAX; @@ -3884,7 +3799,7 @@ int ObTableStore::get_multi_version_start(int64_t& multi_version_start) return ret; } -int ObTableStore::get_min_max_major_version(int64_t& min_version, int64_t& max_version) +int ObTableStore::get_min_max_major_version(int64_t &min_version, int64_t &max_version) { int ret = OB_SUCCESS; min_version = INT64_MAX; @@ -3904,10 +3819,10 @@ int ObTableStore::get_min_max_major_version(int64_t& min_version, int64_t& max_v return ret; } -int ObTableStore::get_flashback_major_sstable(const int64_t flashback_scn, ObTablesHandle& handle) +int ObTableStore::get_flashback_major_sstable(const int64_t flashback_scn, ObTablesHandle &handle) { int ret = OB_SUCCESS; - ObITable* major_sstable = NULL; + ObITable *major_sstable = NULL; handle.reset(); if (table_count_ <= 0) { @@ -3956,12 +3871,12 @@ int ObLogTsCompater::set_log_ts(const int64_t log_ts) return ret; } -int ObTableCompater::add_tables(ObIArray& sstables) +int ObTableCompater::add_tables(ObIArray &sstables) { int ret = OB_SUCCESS; if (sstables.empty()) { } else { - ObSSTable* sstable = nullptr; + ObSSTable *sstable = nullptr; for (int64_t i = 0; OB_SUCC(ret) && i < sstables.count(); i++) { if (OB_ISNULL(sstable = sstables.at(i))) { ret = OB_ERR_SYS; @@ -3982,18 +3897,18 @@ int ObTableCompater::add_tables(ObIArray& sstables) return ret; } -int ObTableCompater::add_tables(ObIArray& sstables) +int ObTableCompater::add_tables(ObIArray &sstables) { int ret = OB_SUCCESS; if (sstables.empty()) { } else { for (int64_t i = 0; OB_SUCC(ret) && i < sstables.count(); i++) { - ObMigrateTableInfo::SSTableInfo& sstable_info = sstables.at(i); + ObMigrateTableInfo::SSTableInfo &sstable_info = sstables.at(i); if (sstable_info.src_table_key_.is_major_sstable()) { sstable_info.dest_log_ts_range_.reset(); } else { - ObITable::TableKey& table_key = sstable_info.src_table_key_; + ObITable::TableKey &table_key = sstable_info.src_table_key_; ObLogTsCompater base_log_ts(table_key.get_base_version(), sstable_info.dest_log_ts_range_, true); ObLogTsCompater snapshot_log_ts(table_key.get_snapshot_version(), sstable_info.dest_log_ts_range_, false); if (OB_FAIL(compaters_.push_back(base_log_ts))) { @@ -4019,7 +3934,7 @@ int ObTableCompater::fill_log_ts() int64_t new_log_ts = ObLogTsRange::MIN_TS; int64_t last_version = INT64_MAX; for (int64_t i = 0; OB_SUCC(ret) && i < compaters_.count(); i++) { - ObLogTsCompater& compater = compaters_.at(i); + ObLogTsCompater &compater = compaters_.at(i); if (compater.version_ != last_version) { new_log_ts++; last_version = compater.version_; @@ -4050,10 +3965,10 @@ int ObTableCompater::fill_log_ts() } void ObPrintableTableStore::table_to_string( - ObITable* table, const char* table_type, char* buf, const int64_t buf_len, int64_t& pos) const + ObITable *table, const char *table_type, char *buf, const int64_t buf_len, int64_t &pos) const { if (table != nullptr && table->is_sstable()) { - ObCurTraceId::TraceId* trace_id = ObCurTraceId::get_trace_id(); + ObCurTraceId::TraceId *trace_id = ObCurTraceId::get_trace_id(); BUF_PRINTF("[%ld] [ ", GETTID()); BUF_PRINTO(PC(trace_id)); BUF_PRINTF(" ] "); @@ -4070,11 +3985,11 @@ void ObPrintableTableStore::table_to_string( table->get_end_log_ts(), table->get_max_log_ts(), table->get_ref(), - static_cast(table)->has_compact_row()); + static_cast(table)->has_compact_row()); } } -int64_t ObPrintableTableStore::to_string(char* buf, const int64_t buf_len) const +int64_t ObPrintableTableStore::to_string(char *buf, const int64_t buf_len) const { int64_t pos = 0; if (OB_ISNULL(buf) || buf_len <= 0) { @@ -4100,7 +4015,7 @@ int64_t ObPrintableTableStore::to_string(char* buf, const int64_t buf_len) const J_COLON(); J_OBJ_START(); if (table_count_ > 0 || complement_minor_sstable_ != nullptr) { - ObCurTraceId::TraceId* trace_id = ObCurTraceId::get_trace_id(); + ObCurTraceId::TraceId *trace_id = ObCurTraceId::get_trace_id(); J_NEWLINE(); // table_type| partition_id|version| base_version|multi_version|snapshot_version // |upper_trans_version|start_log_ts|end_log_ts|max_log_ts|ref @@ -4142,15 +4057,15 @@ int64_t ObPrintableTableStore::to_string(char* buf, const int64_t buf_len) const return pos; } -int ObTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle& handle) +int ObTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle &handle) { int ret = OB_SUCCESS; bool can_read = false; bool contain_snapshot_version = false; int64_t inc_base_pos = -1; - ObArray major_tables; + ObArray major_tables; int64_t need_major_pos = 0; - ObITable* major_table = NULL; + ObITable *major_table = NULL; handle.reset(); int64_t major_snapshot_version = 0; int64_t needed_inc_pos = -1; @@ -4165,7 +4080,7 @@ int ObTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTa LOG_WARN("table store not valid", K(ret), K(snapshot_version), K(PRETTY_TS(*this))); } else { for (int64_t i = 0; OB_SUCC(ret) && i < inc_pos_; ++i) { - ObITable* tmp_major_table = tables_[i]; + ObITable *tmp_major_table = tables_[i]; if (OB_FAIL(major_tables.push_back(tmp_major_table))) { LOG_WARN("failed to push major table into array", K(ret), KP(tmp_major_table)); } @@ -4187,7 +4102,7 @@ int ObTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTa if (OB_SUCC(ret)) { // find first suitable inc pos for (int64_t i = inc_pos_; i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (table->get_upper_trans_version() > major_snapshot_version) { needed_inc_pos = i; break; @@ -4197,7 +4112,7 @@ int ObTableStore::get_recovery_point_tables(const int64_t snapshot_version, ObTa if (needed_inc_pos < 0) { } else { for (int64_t i = needed_inc_pos; OB_SUCC(ret) && i < table_count_; ++i) { - ObITable* table = tables_[i]; + ObITable *table = tables_[i]; if (OB_FAIL(handle.add_table(table))) { LOG_WARN("failed to add table into handle", K(ret), KPC(table)); } diff --git a/src/storage/ob_table_store.h b/src/storage/ob_table_store.h index 6686d09d01b373a434f25bff7c6fcc9749136d2e..74e00f191e38fd210439e7cdc8e1a02eb5065a8a 100644 --- a/src/storage/ob_table_store.h +++ b/src/storage/ob_table_store.h @@ -45,40 +45,40 @@ public: friend class ObPrintableTableSchema; static const int64_t OB_TABLE_STORE_VERSION = 1; struct ObITableIDCompare { - explicit ObITableIDCompare(int& sort_ret) : result_code_(sort_ret) + explicit ObITableIDCompare(int &sort_ret) : result_code_(sort_ret) {} - bool operator()(const ObITable* ltable, const ObITable* rtable) const; + bool operator()(const ObITable *ltable, const ObITable *rtable) const; - int& result_code_; + int &result_code_; }; struct ObITableLogTsRangeCompare { - explicit ObITableLogTsRangeCompare(int& sort_ret) : result_code_(sort_ret) + explicit ObITableLogTsRangeCompare(int &sort_ret) : result_code_(sort_ret) {} - bool operator()(const ObITable* ltable, const ObITable* rtable) const; + bool operator()(const ObITable *ltable, const ObITable *rtable) const; - int& result_code_; + int &result_code_; }; struct ObITableSnapshotVersionCompare { - explicit ObITableSnapshotVersionCompare(int& sort_ret) : result_code_(sort_ret) + explicit ObITableSnapshotVersionCompare(int &sort_ret) : result_code_(sort_ret) {} - bool operator()(const ObITable* lstore, const ObITable* rstore) const; + bool operator()(const ObITable *lstore, const ObITable *rstore) const; - int& result_code_; + int &result_code_; }; ObTableStore(); virtual ~ObTableStore(); - int init(const common::ObPartitionKey& pkey, const uint64_t table_id, ObFreezeInfoSnapshotMgr* freeze_info_mgr, - ObPGMemtableMgr* pg_memtable_mgr); - int init(const ObTableStore& table_store, ObFreezeInfoSnapshotMgr* freeze_info_mgr, ObPGMemtableMgr* pg_memtable_mgr); + int init(const common::ObPartitionKey &pkey, const uint64_t table_id, ObFreezeInfoSnapshotMgr *freeze_info_mgr, + ObPGMemtableMgr *pg_memtable_mgr); + int init(const ObTableStore &table_store, ObFreezeInfoSnapshotMgr *freeze_info_mgr, ObPGMemtableMgr *pg_memtable_mgr); void reset(); OB_INLINE bool is_valid() const; uint64_t get_table_id() const { return table_id_; } - const ObPartitionKey& get_partition_key() const + const ObPartitionKey &get_partition_key() const { return pkey_; } @@ -90,154 +90,151 @@ public: // Split Section int set_reference_tables( - ObTablesHandle& handle, ObTablesHandle& old_handle, const int64_t memtable_base_version, bool& need_update); + ObTablesHandle &handle, ObTablesHandle &old_handle, const int64_t memtable_base_version, bool &need_update); int check_need_split( - const ObTablesHandle& old_handle, common::ObVersion& split_version, bool& need_split, bool& need_minor_split); - int is_physical_split_finished(bool& is_physical_split_finish); - int is_physical_split_finished(ObTablesHandle& old_handle, bool& is_physical_split_finish); - int get_physical_split_info(ObVirtualPartitionSplitInfo& split_info); - int get_reference_tables(ObTablesHandle& handle); - int get_major_split_tables(ObTablesHandle& handle); - int get_minor_split_tables(ObTablesHandle& handle); - int check_can_split(bool& can_split); - int check_can_split(const ObTablesHandle& old_handle, bool& can_split); - int build_major_split_store(const ObTablesHandle& old_handle, ObTablesHandle& handle, bool& need_update); - int build_minor_split_store(const ObTablesHandle& old_handle, ObTablesHandle& handle, bool& need_update); + const ObTablesHandle &old_handle, common::ObVersion &split_version, bool &need_split, bool &need_minor_split); + int is_physical_split_finished(bool &is_physical_split_finish); + int is_physical_split_finished(ObTablesHandle &old_handle, bool &is_physical_split_finish); + int get_physical_split_info(ObVirtualPartitionSplitInfo &split_info); + int get_reference_tables(ObTablesHandle &handle); + int get_major_split_tables(ObTablesHandle &handle); + int get_minor_split_tables(ObTablesHandle &handle); + int check_can_split(bool &can_split); + int check_can_split(const ObTablesHandle &old_handle, bool &can_split); + int build_major_split_store(const ObTablesHandle &old_handle, ObTablesHandle &handle, bool &need_update); + int build_minor_split_store(const ObTablesHandle &old_handle, ObTablesHandle &handle, bool &need_update); // Common Section int get_all_tables( - const bool include_active_memtable, const bool include_complement_minor_sstable, ObTablesHandle& handle); - int get_read_tables(const int64_t snapshot_version, ObTablesHandle& handle, const bool allow_not_ready = false); + const bool include_active_memtable, const bool include_complement_minor_sstable, ObTablesHandle &handle); + int get_read_tables(const int64_t snapshot_version, ObTablesHandle &handle, const bool allow_not_ready = false); // get major sstable of specified version - int get_major_sstable(const common::ObVersion& version, ObTablesHandle& handle); - int get_latest_major_sstable(ObTableHandle& handle); - int get_sample_read_tables(const common::SampleInfo& sample_info, ObTablesHandle& handle); - int build_new_merge_store(const AddTableParam& param, ObTablesHandle& old_handle); - int get_major_merge_tables(const ObGetMergeTablesParam& param, ObGetMergeTablesResult& result); + int get_major_sstable(const common::ObVersion &version, ObTablesHandle &handle); + int get_latest_major_sstable(ObTableHandle &handle); + int get_sample_read_tables(const common::SampleInfo &sample_info, ObTablesHandle &handle); + int build_new_merge_store(const AddTableParam ¶m, ObTablesHandle &old_handle); + int get_major_merge_tables(const ObGetMergeTablesParam ¶m, ObGetMergeTablesResult &result); int get_mini_minor_merge_tables( - const ObGetMergeTablesParam& param, const int64_t multi_version_start, ObGetMergeTablesResult& result); - int get_hist_minor_range(const common::ObIArray& freeze_infos, - const bool is_optimize, int64_t& min_snapshot_version, int64_t& max_snapshot_version); + const ObGetMergeTablesParam ¶m, const int64_t multi_version_start, ObGetMergeTablesResult &result); + int get_hist_minor_range(const common::ObIArray &freeze_infos, + const bool is_optimize, int64_t &min_snapshot_version, int64_t &max_snapshot_version); int get_hist_minor_merge_tables( - const ObGetMergeTablesParam& param, const int64_t multi_version_start, ObGetMergeTablesResult& result); + const ObGetMergeTablesParam ¶m, const int64_t multi_version_start, ObGetMergeTablesResult &result); int get_mini_merge_tables( - const ObGetMergeTablesParam& param, const int64_t demand_multi_version_start, ObGetMergeTablesResult& result); - int get_table_count(int64_t& table_count) const; - int check_table_count_safe(bool& is_safe) const; - int has_major_sstable(bool& has_major); + const ObGetMergeTablesParam ¶m, const int64_t demand_multi_version_start, ObGetMergeTablesResult &result); + int get_table_count(int64_t &table_count) const; + int check_table_count_safe(bool &is_safe) const; + int has_major_sstable(bool &has_major); - int check_can_migrate(bool& can_migrate); + int check_can_migrate(bool &can_migrate); bool is_ready_for_read() const { return is_ready_for_read_; } - int need_remove_old_table(const common::ObVersion& kept_min_version, const int64_t multi_version_start, - const int64_t backup_snapshot_verison, int64_t& real_kept_major_num, bool& need_remove); - int equals(const ObTableStore& other, bool& is_equal); + int equals(const ObTableStore &other, bool &is_equal); + int need_remove_old_table(const common::ObVersion &kept_min_version, const int64_t multi_version_start, + int64_t &real_kept_major_num, bool &need_remove); int finish_replay(const int64_t multi_version_start); - int get_replay_tables(ObIArray& replay_tables); - int set_replay_sstables(const bool is_replay_old, const common::ObIArray& sstables); - int get_all_sstables(const bool need_complemnt, ObTablesHandle& handle); - int get_continue_tables(ObTablesHandle& handle); - int check_need_mini_minor_merge(const bool using_remote_memstore, bool& need_merge); + int get_replay_tables(ObIArray &replay_tables); + int set_replay_sstables(const bool is_replay_old, const common::ObIArray &sstables); + int get_all_sstables(const bool need_complemnt, ObTablesHandle &handle); + int get_continue_tables(ObTablesHandle &handle); + int check_need_mini_minor_merge(const bool using_remote_memstore, bool &need_merge); int64_t cal_hist_minor_merge_threshold() const; - int check_need_hist_minor_merge(bool& need_merge); - int get_multi_version_start(int64_t& multi_version_start); - int get_min_max_major_version(int64_t& min_version, int64_t& max_version); - int check_complete(bool& is_complete); - int get_minor_sstables(ObTablesHandle& handle); - ObSSTable* get_complement_minor_sstable() + int check_need_hist_minor_merge(bool &need_merge); + int get_multi_version_start(int64_t &multi_version_start); + int get_min_max_major_version(int64_t &min_version, int64_t &max_version); + int check_complete(bool &is_complete); + int get_minor_sstables(ObTablesHandle &handle); + ObSSTable *get_complement_minor_sstable() { return complement_minor_sstable_; } - int get_flashback_major_sstable(const int64_t flashback_scn, ObTablesHandle& handle); - int get_mark_deletion_tables(const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle& handle); + int get_flashback_major_sstable(const int64_t flashback_scn, ObTablesHandle &handle); + int get_mark_deletion_tables(const int64_t end_log_ts, const int64_t snapshot_version, ObTablesHandle &handle); int clear_complement_minor_sstable(); - int get_min_schema_version(int64_t& min_schema_version); - int get_schema_version(int64_t& schema_version) const; - int get_needed_local_tables_for_migrate(const ObMigrateRemoteTableInfo& remote_table_info, ObTablesHandle& handle); - int is_memtable_need_merge(const memtable::ObMemtable& memtable, bool& need_merge); - int get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle& handle); + int get_min_schema_version(int64_t &min_schema_version); + int get_schema_version(int64_t &schema_version) const; + int get_needed_local_tables_for_migrate(const ObMigrateRemoteTableInfo &remote_table_info, ObTablesHandle &handle); + int is_memtable_need_merge(const memtable::ObMemtable &memtable, bool &need_merge); + int get_recovery_point_tables(const int64_t snapshot_version, ObTablesHandle &handle); DECLARE_VIRTUAL_TO_STRING; private: // Common Section void adjust_minor_merge_boundary(int64_t &min_snapshot, int64_t &max_snapshot); - bool is_multi_version_break(const ObVersionRange& new_version_range, const int64_t last_snapshot_vesion); - int classify_tables(const ObTablesHandle& old_handle, common::ObArray& major_tables, - common::ObArray& inc_tables); - int add_trans_sstable(ObSSTable* new_table, common::ObIArray& trans_tables); - int add_major_sstable(ObSSTable* new_table, common::ObArray& major_tables); + bool is_multi_version_break(const ObVersionRange &new_version_range, const int64_t last_snapshot_vesion); + int classify_tables(const ObTablesHandle &old_handle, common::ObArray &major_tables, + common::ObArray &inc_tables); + int add_trans_sstable(ObSSTable *new_table, common::ObIArray &trans_tables); + int add_major_sstable(ObSSTable *new_table, common::ObArray &major_tables); int add_minor_sstable( - const bool need_safe_check, common::ObIArray& inc_tables, storage::ObSSTable* new_table); - bool check_include_by_log_ts_range(ObITable& a, ObITable& b); - bool check_intersect_by_log_ts_range(ObITable& a, ObITable& b); + const bool need_safe_check, common::ObIArray &inc_tables, storage::ObSSTable *new_table); + bool check_include_by_log_ts_range(ObITable &a, ObITable &b); + bool check_intersect_by_log_ts_range(ObITable &a, ObITable &b); int check_need_add_minor_sstable( - common::ObIArray& inc_tables, ObITable* new_table, ObIArray& tmp_tables); + common::ObIArray &inc_tables, ObITable *new_table, ObIArray &tmp_tables); int build_tables(const int64_t kept_major_version_num, const int64_t multi_version_start, - ObIArray& major_tables, ObIArray& inc_tables, const int64_t backup_snapshot_version); - int cal_major_copy_start_pos(const ObIArray& major_tables, const int64_t kept_major_version_num, - const int64_t backup_snapshot_version, const int64_t need_major_pos, int64_t& copy_start_pos); - int find_need_major_sstable(const common::ObIArray& major_tables, const int64_t multi_version_start, - int64_t& major_pos, ObITable*& major_table); - int find_need_backup_major_sstable( - const common::ObIArray& major_tables, const int64_t backup_snapshot_version, int64_t& major_pos); + ObIArray &major_tables, ObIArray &inc_tables); + int cal_major_copy_start_pos(const ObIArray &major_tables, const int64_t kept_major_version_num, + const int64_t backup_snapshot_version, const int64_t need_major_pos, int64_t ©_start_pos); + int find_need_major_sstable(const common::ObIArray &major_tables, const int64_t multi_version_start, + int64_t &major_pos, ObITable *&major_table); int add_backup_table( - common::ObIArray& major_tables, const int64_t backup_major_pos, const int64_t copy_start_pos); - int refine_mini_minor_merge_result(ObGetMergeTablesResult& result); - int refine_mini_merge_result(ObGetMergeTablesResult& result); - int refine_mini_merge_result_in_reboot_phase(ObITable& last_table, ObGetMergeTablesResult& result); - int add_complement_to_mini_merge_result(ObGetMergeTablesResult& result); - int refine_mini_merge_log_ts_range(const ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite& freeze_info, - const int64_t demand_multi_version_start, ObGetMergeTablesResult& result); - int find_mini_minor_merge_tables(const ObGetMergeTablesParam& param, const int64_t min_snapshot_version, - const int64_t max_snapshot_version, const int64_t expect_multi_version, ObGetMergeTablesResult& result); - int find_mini_merge_tables(const ObGetMergeTablesParam& param, - const ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite& freeze_info, ObGetMergeTablesResult& result); - int check_continues_and_get_schema_version(const ObMergeType& merge_type, ObGetMergeTablesResult& result); - int add_minor_merge_result(ObITable* table, ObGetMergeTablesResult& result); - int cal_minor_merge_inc_base_version(int64_t& inc_base_version); - int cal_mini_merge_inc_base_version(int64_t& inc_base_version); - int cal_multi_version_start(const int64_t demand_multi_version_start, ObVersionRange& version_range); - int inner_add_table(common::ObIArray& tables, const int64_t start); + common::ObIArray &major_tables, const int64_t backup_major_pos, const int64_t copy_start_pos); + int refine_mini_minor_merge_result(ObGetMergeTablesResult &result); + int refine_mini_merge_result(ObGetMergeTablesResult &result); + int refine_mini_merge_result_in_reboot_phase(ObITable &last_table, ObGetMergeTablesResult &result); + int add_complement_to_mini_merge_result(ObGetMergeTablesResult &result); + int refine_mini_merge_log_ts_range(const ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite &freeze_info, + const int64_t demand_multi_version_start, ObGetMergeTablesResult &result); + int find_mini_minor_merge_tables(const ObGetMergeTablesParam ¶m, const int64_t min_snapshot_version, + const int64_t max_snapshot_version, const int64_t expect_multi_version, ObGetMergeTablesResult &result); + int find_mini_merge_tables(const ObGetMergeTablesParam ¶m, + const ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite &freeze_info, ObGetMergeTablesResult &result); + int check_continues_and_get_schema_version(const ObMergeType &merge_type, ObGetMergeTablesResult &result); + int add_minor_merge_result(ObITable *table, ObGetMergeTablesResult &result); + int cal_minor_merge_inc_base_version(int64_t &inc_base_version); + int cal_mini_merge_inc_base_version(int64_t &inc_base_version); + int cal_multi_version_start(const int64_t demand_multi_version_start, ObVersionRange &version_range); + int inner_add_table(common::ObIArray &tables, const int64_t start); int check_ready_for_read(); - int get_next_major_merge_info(const int merge_version, int64_t& latest_major_table_pos, int64_t& next_major_version, - int64_t& next_major_freeze_ts, int64_t& base_schema_version, int64_t& schema_version); - int get_read_base_tables(const int64_t snapshot_version, ObTablesHandle& handle, bool& contain_snapshot_version); - int get_hist_major_table(const int64_t snapshot_version, ObTablesHandle& handle); - int get_inc_read_tables(const int64_t snapshot_version, ObTablesHandle& handle, bool& contain_snapshot_version); + int get_next_major_merge_info(const int merge_version, int64_t &latest_major_table_pos, int64_t &next_major_version, + int64_t &next_major_freeze_ts, int64_t &base_schema_version, int64_t &schema_version); + int get_read_base_tables(const int64_t snapshot_version, ObTablesHandle &handle, bool &contain_snapshot_version); + int get_hist_major_table(const int64_t snapshot_version, ObTablesHandle &handle); + int get_inc_read_tables(const int64_t snapshot_version, ObTablesHandle &handle, bool &contain_snapshot_version); int update_replay_tables(); int update_multi_version_start(); - int get_memtables(const bool include_active_memtable, ObTablesHandle& handle); - int get_all_memtables(const bool include_active_memtable, ObTablesHandle& handle); - int sort_minor_tables(ObArray& tables); - int sort_major_tables(ObArray& tables); - int get_boundary_major_sstable(const bool last, ObITable*& major_table); - int get_boundary_minor_sstable(const bool last, ObITable*& minor_table); - bool is_own_table(const ObITable* table); - virtual int get_minor_schema_version(int64_t& schema_version); // virtual is for test - int get_all_tables_from_start(ObTablesHandle& handle); - bool check_complete_(const ObTablesHandle& handle); + int get_memtables(const bool include_active_memtable, ObTablesHandle &handle); + int get_all_memtables(const bool include_active_memtable, ObTablesHandle &handle); + int sort_minor_tables(ObArray &tables); + int sort_major_tables(ObArray &tables); + int get_boundary_major_sstable(const bool last, ObITable *&major_table); + int get_boundary_minor_sstable(const bool last, ObITable *&minor_table); + bool is_own_table(const ObITable *table); + virtual int get_minor_schema_version(int64_t &schema_version); // virtual is for test + int get_all_tables_from_start(ObTablesHandle &handle); + bool check_complete_(const ObTablesHandle &handle); int find_major_merge_inc_tables( - const ObSSTable& base_table, const int64_t next_major_freeze_ts, ObTablesHandle& handle); + const ObSSTable &base_table, const int64_t next_major_freeze_ts, ObTablesHandle &handle); int judge_need_mini_minor_merge( - const bool using_remote_memstore, const int64_t minor_check_snapshot_version, bool& need_merge); + const bool using_remote_memstore, const int64_t minor_check_snapshot_version, bool &need_merge); int deal_with_mini_minor_result( - const ObMergeType& merge_type, const int64_t multi_version_start, ObGetMergeTablesResult& result); + const ObMergeType &merge_type, const int64_t multi_version_start, ObGetMergeTablesResult &result); int deal_with_minor_result( - const ObMergeType& merge_type, const int64_t demand_multi_version_start, ObGetMergeTablesResult& result); + const ObMergeType &merge_type, const int64_t demand_multi_version_start, ObGetMergeTablesResult &result); int get_neighbour_freeze_info( - const int64_t snapshot_version, ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite& freeze_info); + const int64_t snapshot_version, ObFreezeInfoSnapshotMgr::NeighbourFreezeInfoLite &freeze_info); // Split Section bool is_spliting(); int check_need_reference_tables( - ObTablesHandle& old_handle, const int64_t memtable_base_version, bool& need_reference); + ObTablesHandle &old_handle, const int64_t memtable_base_version, bool &need_reference); int get_minor_split_table_pos( - const ObTablesHandle& old_handle, int64_t& first_reference_pos, int64_t& last_reference_pos); - int get_major_split_table_pos(const ObTablesHandle& old_handle, int64_t& pos); - + const ObTablesHandle &old_handle, int64_t &first_reference_pos, int64_t &last_reference_pos); + int get_major_split_table_pos(const ObTablesHandle &old_handle, int64_t &pos); protected: static const int64_t INVAID_TABLE_POS = -1; @@ -247,13 +244,13 @@ protected: static const int64_t OB_EMERGENCY_TABLE_CNT = 52; // No Need Persistence bool is_inited_; - ObFreezeInfoSnapshotMgr* freeze_info_mgr_; + ObFreezeInfoSnapshotMgr *freeze_info_mgr_; // tables_: [Major SSTable | Minor SSTable | Memtable] - ObITable* tables_[MAX_SSTABLE_CNT_IN_STORAGE]; + ObITable *tables_[MAX_SSTABLE_CNT_IN_STORAGE]; int64_t table_count_; bool is_ready_for_read_; - ObPGMemtableMgr* pg_memtable_mgr_; - ObSSTable* complement_minor_sstable_; + ObPGMemtableMgr *pg_memtable_mgr_; + ObSSTable *complement_minor_sstable_; // Need Persistence common::ObPartitionKey pkey_; @@ -280,25 +277,25 @@ public: {} ~ObLogTsCompater() {} - explicit ObLogTsCompater(const int64_t version, common::ObLogTsRange& log_ts_range, bool is_base) + explicit ObLogTsCompater(const int64_t version, common::ObLogTsRange &log_ts_range, bool is_base) : version_(version), log_ts_range_(&log_ts_range), is_base_(is_base) {} int set_log_ts(const int64_t log_ts); - bool operator<(const ObLogTsCompater& rtable) const + bool operator<(const ObLogTsCompater &rtable) const { return version_ < rtable.version_; } - bool operator==(const ObLogTsCompater& rtable) const + bool operator==(const ObLogTsCompater &rtable) const { return version_ == rtable.version_; } - bool operator>(const ObLogTsCompater& rtable) const + bool operator>(const ObLogTsCompater &rtable) const { return version_ > rtable.version_; } TO_STRING_KV(K_(version), K_(log_ts_range), K_(is_base)); int64_t version_; - ObLogTsRange* log_ts_range_; + ObLogTsRange *log_ts_range_; bool is_base_; }; @@ -313,8 +310,8 @@ public: { compaters_.reset(); } - int add_tables(ObIArray& sstables); - int add_tables(ObIArray& sstables); + int add_tables(ObIArray &sstables); + int add_tables(ObIArray &sstables); int fill_log_ts(); TO_STRING_KV(K_(compaters)); @@ -324,15 +321,15 @@ private: class ObPrintableTableStore final : public ObTableStore { public: - virtual int64_t to_string(char* buf, const int64_t buf_len) const override; + virtual int64_t to_string(char *buf, const int64_t buf_len) const override; private: - void table_to_string(ObITable* table, const char* table_type, char* buf, const int64_t buf_len, int64_t& pos) const; + void table_to_string(ObITable *table, const char *table_type, char *buf, const int64_t buf_len, int64_t &pos) const; ObPrintableTableStore() = delete; }; -#define PRETTY_TS_P(x) (reinterpret_cast(x)) -#define PRETTY_TS(x) (reinterpret_cast(x)) +#define PRETTY_TS_P(x) (reinterpret_cast(x)) +#define PRETTY_TS(x) (reinterpret_cast(x)) } // namespace storage } // namespace oceanbase diff --git a/unittest/share/backup/test_backup_struct.cpp b/unittest/share/backup/test_backup_struct.cpp index 97d988d367e64d8f0d96c263d587742d2c73250b..25ffd95b0f9b21fa66af2d7f003a0875de50657a 100644 --- a/unittest/share/backup/test_backup_struct.cpp +++ b/unittest/share/backup/test_backup_struct.cpp @@ -19,10 +19,10 @@ #include "share/backup/ob_backup_path.h" #include "share/backup/ob_log_archive_backup_info_mgr.h" #include "share/backup/ob_backup_struct.h" +#include "rootserver/ob_backup_data_clean.h" #undef private #include #include "lib/hash/ob_hashmap.h" - using namespace oceanbase; using namespace common; using namespace share; @@ -451,6 +451,101 @@ TEST(ObLogArchiveBackupInfoMgr, log_archive_info_cmp) } + +TEST(ObLogArchiveBackupInfoMgr, log_archive_info_cmp2) +{ + int ret = OB_SUCCESS; + ObArray log_infos; + ObLogArchiveBackupInfo log_info; + log_info.status_.start_ts_ = 1; + log_info.status_.checkpoint_ts_ = 0; + log_info.status_.round_ = 1; + ret = log_infos.push_back(log_info); + ASSERT_EQ(OB_SUCCESS, ret); + log_info.reset(); + log_info.status_.start_ts_ = 1; + log_info.status_.checkpoint_ts_ = 0; + log_info.status_.round_ = 2; + ret = log_infos.push_back(log_info); + ASSERT_EQ(OB_SUCCESS, ret); + log_info.reset(); + log_info.status_.start_ts_ = 1; + log_info.status_.checkpoint_ts_ = 0; + log_info.status_.round_ = 3; + ret = log_infos.push_back(log_info); + ASSERT_EQ(OB_SUCCESS, ret); + + + typedef ObArray::iterator ArrayIter; + rootserver::ObBackupDataClean::CompareLogArchiveSnapshotVersion cmp; + ArrayIter iter = std::lower_bound(log_infos.begin(), + log_infos.end(), + 1, + cmp); + if (iter == log_infos.end()) { + --iter; + } else if (iter != log_infos.begin() + && iter->status_.start_ts_ > 1) { + --iter; + } + log_info = *iter; + LOG_INFO("log info", K(log_info)); + +} + + +TEST(ObBackupDataClean, duplicate_task) +{ + int ret = OB_SUCCESS; + ObTenantBackupTaskInfo task_info; + ObArray task_infos; + + //mock task info + //array backup set id is : 1, 2, 1, 2 + task_info.tenant_id_ = OB_SYS_TENANT_ID; + task_info.incarnation_ = 1; + task_info.backup_set_id_ = 1; + task_info.copy_id_ = 0; + task_info.status_ = ObTenantBackupTaskInfo::FINISH; + ret = task_infos.push_back(task_info); + ASSERT_EQ(OB_SUCCESS, ret); + task_info.reset(); + task_info.tenant_id_ = OB_SYS_TENANT_ID; + task_info.incarnation_ = 1; + task_info.backup_set_id_ = 2; + ret = task_infos.push_back(task_info); + task_info.copy_id_ = 0; + task_info.status_ = ObTenantBackupTaskInfo::FINISH; + ASSERT_EQ(OB_SUCCESS, ret); + task_info.reset(); + task_info.tenant_id_ = OB_SYS_TENANT_ID; + task_info.incarnation_ = 1; + task_info.backup_set_id_ = 1; + task_info.copy_id_ = 0; + task_info.status_ = ObTenantBackupTaskInfo::DOING; + ret = task_infos.push_back(task_info); + ASSERT_EQ(OB_SUCCESS, ret); + task_info.reset(); + task_info.tenant_id_ = OB_SYS_TENANT_ID; + task_info.incarnation_ = 1; + task_info.backup_set_id_ = 2; + task_info.copy_id_ = 0; + task_info.status_ = ObTenantBackupTaskInfo::DOING; + ret = task_infos.push_back(task_info); + ASSERT_EQ(OB_SUCCESS, ret); + + rootserver::ObBackupDataClean data_clean; + data_clean.is_inited_ = true; + ret = data_clean.duplicate_task_info(task_infos); + ASSERT_EQ(2, task_infos.count()); + ASSERT_EQ(1, task_infos.at(0).backup_set_id_); + ASSERT_EQ(ObTenantBackupTaskInfo::DOING, task_infos.at(0).status_); + ASSERT_EQ(2, task_infos.at(1).backup_set_id_); + ASSERT_EQ(ObTenantBackupTaskInfo::DOING, task_infos.at(1).status_); + +} + + int main(int argc, char **argv) { OB_LOGGER.set_log_level("INFO"); diff --git a/unittest/storage/blocksstable/ob_data_file_prepare.h b/unittest/storage/blocksstable/ob_data_file_prepare.h index 903a4877ff06b6d5b5b9805dc474d725236c9dc7..dbb4eab3e7b10b886174e0e09962f8693ed7f48a 100644 --- a/unittest/storage/blocksstable/ob_data_file_prepare.h +++ b/unittest/storage/blocksstable/ob_data_file_prepare.h @@ -43,16 +43,16 @@ public: { destory(); } - int init(const char* test_name, const int64_t macro_block_size = 64 * 1024, const int64_t macro_block_count = 100, + int init(const char *test_name, const int64_t macro_block_size = 64 * 1024, const int64_t macro_block_count = 100, const int64_t disk_num = 0); virtual int open(); virtual int restart(); virtual void destory(); - ObStorageEnv& get_storage_env() + ObStorageEnv &get_storage_env() { return storage_env_; } - ObStoreFileSystem& get_file_system() + ObStoreFileSystem &get_file_system() { return OB_FILE_SYSTEM; } @@ -78,33 +78,33 @@ private: class TestDataFilePrepare : public ::testing::Test { public: TestDataFilePrepare( - const char* test_name, const int64_t macro_block_size = 64 * 1024, const int64_t macro_block_count = 100); + const char *test_name, const int64_t macro_block_size = 64 * 1024, const int64_t macro_block_count = 100); virtual ~TestDataFilePrepare(); virtual void SetUp(); virtual void TearDown(); virtual void fake_freeze_mgr(); - const ObStorageEnv& get_storage_env() + const ObStorageEnv &get_storage_env() { return util_.get_storage_env(); } - ObStoreFileSystem& get_file_system() + ObStoreFileSystem &get_file_system() { return util_.get_file_system(); } - const ObStorageFileHandle& get_storage_file_handle(); + const ObStorageFileHandle &get_storage_file_handle(); protected: static const int64_t TENANT_ID = 1; static const int64_t TABLE_ID = 3001; TestDataFilePrepareUtil util_; ObArenaAllocator allocator_; - const char* test_name_; + const char *test_name_; const int64_t macro_block_size_; const int64_t macro_block_count_; }; TestDataFilePrepare::TestDataFilePrepare( - const char* test_name, const int64_t macro_block_size, const int64_t macro_block_count) + const char *test_name, const int64_t macro_block_size, const int64_t macro_block_count) : util_(), allocator_(ObModIds::TEST), test_name_(test_name), @@ -133,14 +133,12 @@ void TestDataFilePrepare::fake_freeze_mgr() common::ObArray gc_schema_version; common::ObArray snapshots; common::ObMySQLProxy sql_proxy; - ObFreezeInfoSnapshotMgr* freeze_mgr; + ObFreezeInfoSnapshotMgr *freeze_mgr; freeze_mgr = &ObFreezeInfoMgrWrapper::get_instance(); if (!freeze_mgr->is_inited()) { ASSERT_EQ(OB_SUCCESS, freeze_mgr->init(sql_proxy, false)); const int64_t snapshot_gc_ts = 500; - const int64_t backup_snapshot_version = snapshot_gc_ts - 100; - const int64_t delay_delete_snapshot_version = backup_snapshot_version; bool changed = false; ASSERT_EQ(OB_SUCCESS, gc_schema_version.push_back(ObFreezeInfoSnapshotMgr::SchemaPair(1, 210))); @@ -150,18 +148,11 @@ void TestDataFilePrepare::fake_freeze_mgr() ASSERT_EQ(OB_SUCCESS, freeze_info.push_back(ObFreezeInfoSnapshotMgr::FreezeInfoLite(4, 400, 0))); ASSERT_EQ(OB_SUCCESS, - freeze_mgr->update_info(snapshot_gc_ts, - gc_schema_version, - freeze_info, - snapshots, - backup_snapshot_version, - delay_delete_snapshot_version, - INT64_MAX, - changed)); + freeze_mgr->update_info(snapshot_gc_ts, gc_schema_version, freeze_info, snapshots, INT64_MAX, changed)); } } -const ObStorageFileHandle& TestDataFilePrepare::get_storage_file_handle() +const ObStorageFileHandle &TestDataFilePrepare::get_storage_file_handle() { ObPGKey pg_key(combine_id(1, 1001), 1, 0); ObIPartitionGroupGuard pg_guard; @@ -174,7 +165,7 @@ TestDataFilePrepareUtil::TestDataFilePrepareUtil() {} int TestDataFilePrepareUtil::init( - const char* test_name, const int64_t macro_block_size, const int64_t macro_block_count, const int64_t disk_num) + const char *test_name, const int64_t macro_block_size, const int64_t macro_block_count, const int64_t disk_num) { int ret = OB_SUCCESS; char cur_dir[OB_MAX_FILE_NAME_LENGTH]; diff --git a/unittest/storage/test_ob_freeze_info_snapshot_mgr.cpp b/unittest/storage/test_ob_freeze_info_snapshot_mgr.cpp index e9071cb45b795074cdd740fa17a0927e700660fd..58e283eab9941d0b949066310f8d709579471835 100644 --- a/unittest/storage/test_ob_freeze_info_snapshot_mgr.cpp +++ b/unittest/storage/test_ob_freeze_info_snapshot_mgr.cpp @@ -31,7 +31,7 @@ class MockSchemaCache : public ObFreezeInfoSnapshotMgr::SchemaCache { public: MockSchemaCache() : SchemaCache(schema_query_set_), schema_query_set_(*this) {} - virtual int fetch_freeze_schema(const uint64_t, const int64_t, int64_t& schema_version) override + virtual int fetch_freeze_schema(const uint64_t, const int64_t, int64_t &schema_version) override { int ret = OB_SUCCESS; if (rand() % 4 == 0) { @@ -43,8 +43,8 @@ public: return ret; } - virtual int fetch_freeze_schema(const uint64_t tenant_id, const int64_t, int64_t& schema_version, - common::ObIArray& freeze_schema) override + virtual int fetch_freeze_schema(const uint64_t tenant_id, const int64_t, int64_t &schema_version, + common::ObIArray &freeze_schema) override { int ret = OB_SUCCESS; for (int64_t i = 0; i < TEST_ALL_TENANT_NUM; i++) { @@ -78,8 +78,6 @@ public: ObArray schemas; ObArray infos; ObArray snapshots; - const int64_t backup_snapshot_version = 0; - const int64_t delay_delete_snapshot_version = 0; for (int i = 0; i < TEST_NUM; i++) { schemas.reset(); @@ -100,14 +98,7 @@ public: } bool changed; - mgr.update_info((i + 1) * 10, - schemas, - infos, - snapshots, - backup_snapshot_version, - INT64_MAX, - delay_delete_snapshot_version, - changed); + mgr.update_info((i + 1) * 10, schemas, infos, snapshots, INT64_MAX, changed); usleep(100000); } @@ -125,7 +116,7 @@ TEST_F(TestFreezeInfoSnapshotMgr, test_rs_return_minus_one_for_gc_snapshot_info) for (int i = 0; i < TEST_NUM; i++) { for (int j = 0; j < TEST_TENANT_NUM; j++) { - ObFreezeInfoSnapshotMgr::NeighbourFreezeInfo& info_item = info[i][j]; + ObFreezeInfoSnapshotMgr::NeighbourFreezeInfo &info_item = info[i][j]; EXPECT_EQ( OB_SUCCESS, mgr.get_neighbour_major_freeze(((((int64_t)j + 1001) << 40) + 50001), i * 10 + 5, info[i][j])); STORAGE_LOG(WARN, "get neighbour major freeze", K(j + 1001), K(i * 10 + 5), K(info_item)); @@ -143,9 +134,9 @@ TEST_F(TestFreezeInfoSnapshotMgr, test_rs_return_minus_one_for_gc_snapshot_info) TEST_F(TestFreezeInfoSnapshotMgr, test_rs_return_minus_one_for_get_freeze_schema_evrsion) { MockSchemaCache cache; - MockSchemaCache::schema_node* p = NULL; + MockSchemaCache::schema_node *p = NULL; - p = (MockSchemaCache::schema_node*)cache.allocator_.alloc(); + p = (MockSchemaCache::schema_node *)cache.allocator_.alloc(); cache.head_ = cache.tail_ = p; cache.inited_ = true; @@ -182,7 +173,7 @@ TEST_F(TestFreezeInfoSnapshotMgr, test_rs_return_minus_one_for_get_freeze_schema } } - MockSchemaCache::schema_node* curr = cache.head_->next; + MockSchemaCache::schema_node *curr = cache.head_->next; STORAGE_LOG(INFO, "start finding -1 in list"); while (curr) { EXPECT_TRUE(curr->schema_version != -1); @@ -193,7 +184,7 @@ TEST_F(TestFreezeInfoSnapshotMgr, test_rs_return_minus_one_for_get_freeze_schema } // namespace unittest } // namespace oceanbase -int main(int argc, char** argv) +int main(int argc, char **argv) { OB_LOGGER.set_file_name("test_ob_freeze_info_snapshot_mgr.log"); OB_LOGGER.set_log_level("INFO");