fix last lob meta info deep_copy bug
This commit is contained in:
		| @ -637,6 +637,7 @@ static int read_all( | |||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|   ObLobQueryResult result; |   ObLobQueryResult result; | ||||||
|   meta_iter.set_not_calc_char_len(true); |   meta_iter.set_not_calc_char_len(true); | ||||||
|  |   meta_iter.set_not_need_last_info(true); | ||||||
|   while (OB_SUCC(ret)) { |   while (OB_SUCC(ret)) { | ||||||
|     ret = meta_iter.get_next_row(result.meta_result_); |     ret = meta_iter.get_next_row(result.meta_result_); | ||||||
|     const char *lob_data = result.meta_result_.info_.lob_data_.ptr(); |     const char *lob_data = result.meta_result_.info_.lob_data_.ptr(); | ||||||
| @ -3821,6 +3822,7 @@ int ObLobManager::batch_delete(ObLobAccessParam& param, ObLobMetaScanIter &meta_ | |||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|   ObLobQueryResult result; |   ObLobQueryResult result; | ||||||
|   meta_iter.set_not_calc_char_len(true); |   meta_iter.set_not_calc_char_len(true); | ||||||
|  |   meta_iter.set_not_need_last_info(true); | ||||||
|   while (OB_SUCC(ret)) { |   while (OB_SUCC(ret)) { | ||||||
|     if (OB_FAIL(meta_iter.get_next_row(result.meta_result_))) { |     if (OB_FAIL(meta_iter.get_next_row(result.meta_result_))) { | ||||||
|       if (ret == OB_ITER_END) { |       if (ret == OB_ITER_END) { | ||||||
|  | |||||||
| @ -39,7 +39,8 @@ int ObLobMetaScanIter::open(ObLobAccessParam ¶m, ObILobApator* lob_adatper) | |||||||
| } | } | ||||||
|  |  | ||||||
| ObLobMetaScanIter::ObLobMetaScanIter() | ObLobMetaScanIter::ObLobMetaScanIter() | ||||||
|   : lob_adatper_(nullptr), meta_iter_(nullptr), param_(), scan_param_(), cur_pos_(0), cur_byte_pos_(0), not_calc_char_len_(false) {} |   : lob_adatper_(nullptr), meta_iter_(nullptr), param_(), scan_param_(), cur_pos_(0), cur_byte_pos_(0), not_calc_char_len_(false), | ||||||
|  |     not_need_last_info_(false) {} | ||||||
|  |  | ||||||
| int ObLobMetaScanIter::get_next_row(ObLobMetaInfo &row) | int ObLobMetaScanIter::get_next_row(ObLobMetaInfo &row) | ||||||
| { | { | ||||||
| @ -63,11 +64,6 @@ int ObLobMetaScanIter::get_next_row(ObLobMetaInfo &row) | |||||||
|           row.byte_len_ = 0; |           row.byte_len_ = 0; | ||||||
|           row.char_len_ = 0; |           row.char_len_ = 0; | ||||||
|           row.seq_id_ = ObString(); |           row.seq_id_ = ObString(); | ||||||
|           // when get iter end, do deep copy for last scan result |  | ||||||
|           int tmp_ret = cur_info_.deep_copy(*param_.allocator_, cur_info_); |  | ||||||
|           if (tmp_ret != OB_SUCCESS) { |  | ||||||
|             LOG_WARN("fail to do deep copy for cur info", K(tmp_ret), K(cur_info_)); |  | ||||||
|           } |  | ||||||
|         } else { |         } else { | ||||||
|           LOG_WARN("failed to get next row.", K(ret)); |           LOG_WARN("failed to get next row.", K(ret)); | ||||||
|         } |         } | ||||||
| @ -103,6 +99,14 @@ int ObLobMetaScanIter::get_next_row(ObLobMetaInfo &row) | |||||||
|         // update sum(len) |         // update sum(len) | ||||||
|         cur_pos_ += (is_char) ? row.char_len_ : row.byte_len_; |         cur_pos_ += (is_char) ? row.char_len_ : row.byte_len_; | ||||||
|         cur_byte_pos_ += row.byte_len_; |         cur_byte_pos_ += row.byte_len_; | ||||||
|  |         if (OB_SUCC(ret) && ! not_need_last_info() && cur_byte_pos_ == param_.byte_size_) { | ||||||
|  |           ObLobMetaInfo info = cur_info_; | ||||||
|  |           if (OB_FAIL(cur_info_.deep_copy(*param_.allocator_, info))) { | ||||||
|  |             LOG_WARN("fail to do deep copy for cur info", K(info), K(row), K(param_), KPC(this)); | ||||||
|  |           } else { | ||||||
|  |             LOG_DEBUG("deep_copy last info", K(cur_info_), K(param_)); | ||||||
|  |           } | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -85,7 +85,9 @@ public: | |||||||
|   bool is_range_over(const ObLobMetaInfo& info); |   bool is_range_over(const ObLobMetaInfo& info); | ||||||
|   void set_not_calc_char_len(bool not_calc_char_len) { not_calc_char_len_ = not_calc_char_len; } |   void set_not_calc_char_len(bool not_calc_char_len) { not_calc_char_len_ = not_calc_char_len; } | ||||||
|   bool not_calc_char_len() const { return not_calc_char_len_; } |   bool not_calc_char_len() const { return not_calc_char_len_; } | ||||||
|   TO_STRING_KV(K_(cur_pos), K_(cur_byte_pos), K_(cur_info), K_(not_calc_char_len)); |   void set_not_need_last_info(bool not_need_last_info) { not_need_last_info_ = not_need_last_info;} | ||||||
|  |   bool not_need_last_info() const { return not_need_last_info_; } | ||||||
|  |   TO_STRING_KV(K_(cur_pos), K_(cur_byte_pos), K_(cur_info), K_(not_calc_char_len), K_(not_need_last_info)); | ||||||
| private: | private: | ||||||
|   bool is_in_range(const ObLobMetaInfo& info); |   bool is_in_range(const ObLobMetaInfo& info); | ||||||
| private: | private: | ||||||
| @ -97,6 +99,7 @@ private: | |||||||
|   uint64_t cur_byte_pos_; |   uint64_t cur_byte_pos_; | ||||||
|   ObLobMetaInfo cur_info_; |   ObLobMetaInfo cur_info_; | ||||||
|   bool not_calc_char_len_; |   bool not_calc_char_len_; | ||||||
|  |   bool not_need_last_info_; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct ObLobMetaWriteResult { | struct ObLobMetaWriteResult { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 shadowao
					shadowao