kangpinghuang commented on a change in pull request #1417: Check if there exist a rowset contains the added rowset URL: https://github.com/apache/incubator-doris/pull/1417#discussion_r299792880
########## File path: be/src/olap/rowset/segment_group.cpp ########## @@ -766,29 +775,35 @@ OLAPStatus SegmentGroup::convert_from_old_files(const std::string& snapshot_path } for (int segment_id = 0; segment_id < _num_segments; segment_id++) { std::string new_data_file_name = construct_data_file_path(_rowset_path_prefix, segment_id); - if (!check_dir_existed(new_data_file_name)) { - std::string old_data_file_name = construct_old_data_file_path(snapshot_path, segment_id); - if (link(old_data_file_name.c_str(), new_data_file_name.c_str()) != 0) { - LOG(WARNING) << "fail to create hard link. from=" << old_data_file_name << ", " - << "to=" << new_data_file_name << ", " << "errno=" << Errno::no(); - return OLAP_ERR_OS_ERROR; - } else { - VLOG(3) << "link data file from " << old_data_file_name - << " to " << new_data_file_name << " successfully"; - } + // if file exist should remove it because same file name does not mean same data + if (check_dir_existed(new_data_file_name)) { + LOG(INFO) << "file already exist, remove it. file=" << new_data_file_name; + RETURN_NOT_OK(remove_dir(new_data_file_name)); + } + std::string old_data_file_name = construct_old_data_file_path(snapshot_path, segment_id); + if (link(old_data_file_name.c_str(), new_data_file_name.c_str()) != 0) { + LOG(WARNING) << "fail to create hard link. from=" << old_data_file_name + << ", to=" << new_data_file_name << ", errno=" << Errno::no(); + return OLAP_ERR_OS_ERROR; + } else { + VLOG(3) << "link data file from " << old_data_file_name + << " to " << new_data_file_name << " successfully"; } success_links->push_back(new_data_file_name); std::string new_index_file_name = construct_index_file_path(_rowset_path_prefix, segment_id); - if (!check_dir_existed(new_index_file_name)) { - std::string old_index_file_name = construct_old_index_file_path(snapshot_path, segment_id); - if (link(old_index_file_name.c_str(), new_index_file_name.c_str()) != 0) { - LOG(WARNING) << "fail to create hard link. from=" << old_index_file_name << ", " - << "to=" << new_index_file_name << ", " << "errno=" << Errno::no(); - return OLAP_ERR_OS_ERROR; - } else { - VLOG(3) << "link index file from " << old_index_file_name - << " to " << new_index_file_name << " successfully"; - } + if (check_dir_existed(new_index_file_name)) { + LOG(INFO) << "file already exist, remote it. file=" << new_index_file_name; Review comment: ```suggestion LOG(INFO) << "file already exist, remove it. file=" << new_index_file_name; ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org