wyxxxcat commented on code in PR #69290:
URL: https://github.com/apache/doris/pull/69290#discussion_r4597043910


##########
cloud/src/recycler/s3_accessor.cpp:
##########
@@ -314,8 +315,23 @@ std::optional<S3Conf> S3Conf::from_obj_store_info(const 
ObjectStoreInfoPB& obj_i
     return s3_conf;
 }
 
+namespace {
+
+// Endpoint, bucket and prefix as configured, plus the credential identity: 
gateways such as Ceph
+// RGW resolve one bucket name per tenant. The ak is hidden as in logs, the sk 
is never part of it.
+// '\n' never occurs in an endpoint or a bucket name, so different confs never 
collide.
+std::string s3_location(const S3Conf& conf) {
+    return fmt::format("{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}", conf.endpoint, 
conf.bucket, conf.prefix,
+                       static_cast<int>(conf.provider), 
hide_access_key(conf.ak), conf.role_arn,

Review Comment:
   [P2] Preserve full AK identity when deduplicating storage locations
   
   `hide_access_key()` is a display mask, not an identity digest: it keeps only 
the middle six characters of a long AK. For example, the synthetic keys 
`AKIAIOSFODNN7EXAMPLE` and `BKIAIOSFODNN7EXAMPLF` both become 
`xxxxxxxFODNN7xxxxxxx` (confirmed locally using the exact function from this 
head). If two S3-compatible vaults otherwise have identical 
endpoint/bucket/prefix/provider settings, their locations now compare equal 
despite different AKs. [Ceph RGW permits the same bucket name in different 
tenants and selects the implicit tenant from the authenticated 
user](https://docs.ceph.com/en/latest/radosgw/multitenancy/), so these can be 
different object namespaces; `checked_locations` then skips one vault and 
misses all its leaks. Keep the masking for display, but use a digest of the 
complete identity for equality, or conservatively avoid deduplication when 
identity cannot be established. Add a case where different AKs have the same 
masked value; the current test keys have different re
 tained middle characters and miss this regression.



##########
cloud/src/recycler/checker.cpp:
##########
@@ -1049,20 +1063,38 @@ int InstanceChecker::do_inverted_check() {
     // so we choose to skip here.
     TEST_SYNC_POINT_RETURN_WITH_VALUE("InstanceChecker::do_inverted_check", 
(int)0);
 
-    for (auto& [_, accessor] : accessor_map_) {
+    // List each storage location once, resources sharing one would count its 
leaks repeatedly.
+    // Compare `location()`, not the normalized `uri()` ("a/b" and "a//b" hold 
different objects).
+    std::unordered_set<std::string> checked_locations;
+    for (auto& [resource_id, accessor] : accessor_map_) {
+        if (!checked_locations.insert(accessor->location()).second) {
+            LOG(INFO) << "skip inverted check of a storage location already 
checked, instance_id="
+                      << instance_id_ << " resource_id=" << resource_id
+                      << " uri=" << accessor->uri();
+            continue;
+        }
+        const StorageRoot& root = accessor->root();
         std::unique_ptr<ListIterator> list_iter;
+        // A vault that fails to list does not stop the check of the others
         int ret = accessor->list_directory("data", &list_iter);
         if (ret != 0) {
-            return -1;
+            LOG(WARNING) << "failed to list data directory. uri=" << 
accessor->uri();
+            check_ret = -1;
+            continue;
         }
 
         for (auto file = list_iter->next(); file.has_value(); file = 
list_iter->next()) {
+            if (stopped()) {
+                // Otherwise each remaining object would start a rowset read 
cut short by the stop
+                LOG(INFO) << "inverted check stopped, instance_id=" << 
instance_id_;
+                return -1;
+            }
             const auto& path = file->path;
             if (path == "data/packed_file" || 
path.starts_with("data/packed_file/")) {
                 continue; // packed_file has dedicated check logic
             }
             ++num_scanned;
-            int ret = check_segment_file(path);
+            int ret = check_segment_file(path, root);

Review Comment:
   [P2] Apply cross-vault ownership validation to index files too
   
   Only the segment path receives `root`; `.idx` objects return success 
immediately in `check_segment_file()` and then enter 
`check_inverted_index_file()` without any storage identity. For a concrete 
case, commit rowset R of tablet T with `resource_id=A` and one segment, keep 
its valid `.dat`/V2 `.idx` in vault A, and leave only a duplicate 
`data/T/R_0.idx` in a distinct-root vault B. The V2 helper reads T's rowsets, 
finds segment 0 in A's metadata and accepts B's copy; the V1 helper likewise 
never checks `resource_id`. The scan therefore returns success with zero leaks, 
although recycling R deletes files through A's accessor and cannot remove B's 
index copy. This is the still-unhandled index side of the earlier cross-vault 
ownership finding: the new test explicitly creates zero inverted indexes, so it 
only proves the `.dat` fix. Pass the scanned root into both index validators 
and verify the matching rowset's resource, with V1/V2 index-only orphan 
coverage.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to