morningman commented on a change in pull request #4039:
URL: https://github.com/apache/incubator-doris/pull/4039#discussion_r452279720



##########
File path: be/src/olap/tablet_meta.h
##########
@@ -325,6 +334,10 @@ inline const std::vector<RowsetMetaSharedPtr>& 
TabletMeta::all_inc_rs_metas() co
     return _inc_rs_metas;
 }
 
+inline const std::vector<RowsetMetaSharedPtr>& 
TabletMeta::all_expired_snapshot_rs_metas() const {
+    return _expired_snapshot_rs_metas;

Review comment:
       how about `_stale_rs_metas`

##########
File path: be/src/olap/tablet.cpp
##########
@@ -358,9 +384,89 @@ void Tablet::delete_expired_inc_rowsets() {
     save_meta();
 }
 
+void Tablet::delete_expired_snapshot_rowset() {
+
+    int64_t now = UnixSeconds();
+    vector<pair<Version, VersionHash>> expired_versions;
+    WriteLock wrlock(&_meta_lock);
+    // Compute the end time to delete rowsets, when a expired rowset 
createtime less then this time, it will be deleted.
+    double expired_snapshot_sweep_endtime = ::difftime(now, 
config::tablet_rowset_expired_snapshot_sweep_time);
+    
+    std::vector<int64_t> path_version_vec;
+    // capture the path version to delete
+    
_timestamped_version_tracker.capture_expired_paths(static_cast<int64_t>(expired_snapshot_sweep_endtime),
 &path_version_vec);
+
+    auto old_size = _expired_snapshot_rs_version_map.size();
+    auto old_meta_size = _tablet_meta->all_expired_snapshot_rs_metas().size();
+
+    std::vector<Version> to_delete_version;
+    // fetch all versions of rowsets to delete
+    for (auto& path_version : path_version_vec) {
+        std::vector<Version> version_path;
+        // fetch the path versions in the version path and delete the path 
version in tracker
+        _timestamped_version_tracker.fetch_and_delete_path_by_id(path_version, 
&version_path);
+        to_delete_version.insert(to_delete_version.end(), 
version_path.begin(), version_path.end());
+    }
+
+    if (to_delete_version.empty()) {
+        return;
+    }
+
+    // check consistent versions
+    const RowsetSharedPtr lastest_delta = rowset_with_max_version();
+    DCHECK(lastest_delta != nullptr);
+
+    Version test_version = Version(0, lastest_delta->end_version());
+    OLAPStatus status = capture_consistent_versions(test_version, nullptr);
+
+    // When there is no consistent versions, we must reconstruct the tracker.
+    if (status != OLAP_SUCCESS) {
+        LOG(WARNING) << "The consistent version check fails, there are bugs. "
+                        << "Reconstruct the tracker to recover versions.";

Review comment:
       print tablet id too




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to