kangpinghuang commented on a change in pull request #932: Refactor tablet mgr
code
URL: https://github.com/apache/incubator-doris/pull/932#discussion_r275707218
##########
File path: be/src/olap/tablet_manager.cpp
##########
@@ -872,30 +882,86 @@ OLAPStatus TabletManager::start_trash_sweep() {
tablet->delete_expired_inc_rowsets();
}
}
- _tablet_map_lock.unlock();
+ auto it = _shutdown_tablets.begin();
+ for (; it != _shutdown_tablets.end();) {
+ // check if the meta has the tablet info and its state is shutdown
+ if (it->use_count() > 1) {
+ // it means current tablet is referenced in other thread
+ ++it;
+ continue;
+ }
+ TabletMetaSharedPtr new_tablet_meta(new(nothrow) TabletMeta());
+ if (new_tablet_meta == nullptr) {
+ LOG(WARNING) << "fail to malloc TabletMeta.";
+ ++it;
+ continue;
+ }
+ OLAPStatus check_st = TabletMetaManager::get_header((*it)->data_dir(),
+ (*it)->tablet_id(), (*it)->schema_hash(), new_tablet_meta);
+ if (check_st == OLAP_SUCCESS) {
+ if (new_tablet_meta->tablet_state() != TABLET_SHUTDOWN) {
+ LOG(WARNING) << "tablet's state changed to normal, skip remove
dirs"
+ << " tablet id = " << new_tablet_meta->tablet_id()
+ << " schema hash = " <<
new_tablet_meta->schema_hash();
+ // remove it from list
+ it = _shutdown_tablets.erase(it);
+ continue;
+ }
+ if (check_dir_existed((*it)->tablet_path())) {
+ // take snapshot of tablet meta
+ std::string meta_file = (*it)->tablet_path() + "/" +
std::to_string((*it)->tablet_id()) + ".hdr";
+ (*it)->tablet_meta()->save(meta_file);
+ OLAPStatus rm_st = move_to_trash((*it)->tablet_path(),
(*it)->tablet_path());
Review comment:
add INFO log before move to trash
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]