dataroaring commented on code in PR #53540:
URL: https://github.com/apache/doris/pull/53540#discussion_r2232763476


##########
be/src/cloud/cloud_tablet.cpp:
##########
@@ -127,6 +129,48 @@ Status CloudTablet::capture_rs_readers(const Version& 
spec_version,
     return capture_rs_readers_unlocked(version_path, rs_splits);
 }
 
+Status CloudTablet::capture_rs_readers_with_freshness_tolerance(
+        const Version& spec_version, std::vector<RowSetSplits>* rs_splits,
+        bool skip_missing_version, int64_t query_freshness_tolerance_ms) {
+    Versions version_path;
+    std::shared_lock rlock(_meta_lock);
+    // find a versin path where every edge(rowset) has been warmuped
+    auto validator = [&](int64_t start_version, int64_t end_version) -> bool {
+        if (start_version < end_version) {
+            return false;
+        }
+        Version version {start_version, end_version};
+        auto it = _rs_version_map.find(version);
+        if (it == _rs_version_map.end()) {
+            it = _stale_rs_version_map.find(version);
+            if (it == _stale_rs_version_map.end()) {
+                return Status::Error<CAPTURE_ROWSET_READER_ERROR>(
+                        "fail to find Rowset in stale_rs_version for version. 
tablet={}, "
+                        "version={}-{}",
+                        tablet_id(), version.first, version.second);
+            }
+        }
+        const auto& rs = it->second;
+        return rs->has_been_warmuped();
+    };
+    
RETURN_IF_ERROR(_timestamped_version_tracker.capture_consistent_versions_with_validator(
+            0, version_path, validator));
+    int64_t path_max_version = version_path.back().second;
+    bool shold_fallback =
+            std::ranges::any_of(_tablet_meta->all_rs_metas(), [&](const auto& 
rs_meta) -> bool {
+                // TODO: consider use another timestamp
+                return rs_meta->start_version() > path_max_version &&
+                       std::chrono::seconds(::time(nullptr) - 
rs_meta->newest_write_timestamp()) >
+                               
std::chrono::milliseconds(query_freshness_tolerance_ms);
+            });
+    if (shold_fallback) {

Review Comment:
   should_fallback?



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

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

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