yiguolei commented on a change in pull request #1976: And multi-path in 
RowsetGraph
URL: https://github.com/apache/incubator-doris/pull/1976#discussion_r334723328
 
 

 ##########
 File path: be/src/olap/tablet.cpp
 ##########
 @@ -1134,4 +947,51 @@ OLAPStatus 
Tablet::generate_tablet_meta_copy(TabletMetaSharedPtr new_tablet_meta
     return OLAP_SUCCESS;
 }
 
+OLAPStatus Tablet::capture_unused_rowsets() {
+    Version max_version_before_hole;
+    VersionHash v_hash;
+
+    WriteLock wrlock(&_meta_lock);
+    
RETURN_NOT_OK(max_continuous_version_from_begining_unlock(&max_version_before_hole,
 &v_hash));
+
+    std::vector<Version> shortest_version_path;
+    RETURN_NOT_OK(_rs_graph.capture_consistent_versions(Version(0, 
max_version_before_hole.second), &shortest_version_path));
+
+    std::vector<std::pair<Version, RowsetSharedPtr>> rowsets_to_remove;
+    for (auto& it : _rs_version_map) {
+        if (it.second->start_version() > max_version_before_hole.second) {
+            // There are only one path after hole in versions.
+            continue;
+        }
+        bool in_path = false;
+        for (auto& version : shortest_version_path) {
+            if (it.second->version() == version) {
+                in_path = true;
+                break;
+            }
+        }
+        if (!in_path) {
+            rowsets_to_remove.emplace_back(std::make_pair(it.first, 
it.second));
+        }
+    }
+
+    TabletMetaSharedPtr new_tablet_meta(new TabletMeta());
+    RETURN_NOT_OK(generate_tablet_meta_copy(new_tablet_meta));
+
+    for (auto& pair : rowsets_to_remove) {
+        _rs_version_map.erase(pair.first);
+        new_tablet_meta->delete_rs_meta_by_version(pair.first, nullptr);
+        StorageEngine::instance()->add_unused_rowset(pair.second);
+    }
 
 Review comment:
   could not add the rowset to unused rowset list before save meta successfully 
because save meta may fail

----------------------------------------------------------------
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]

Reply via email to