hello-stephen commented on code in PR #71222:
URL: https://github.com/apache/doris/pull/71222#discussion_r4784167136


##########
be/src/io/cache/block_file_cache.cpp:
##########
@@ -705,7 +705,7 @@ FileBlocks BlockFileCache::get_impl(const UInt128Wrapper& 
hash, const CacheConte
     /// find list [block1, ..., blockN] of blocks which intersect with given 
range.
     auto it = _files.find(hash);
     if (it == _files.end()) {
-        if (_async_open_done) {
+        if (!is_async_open_in_progress()) {

Review Comment:
   [P2] Provide a recovery path for persisted blocks after restore fails. An 
unreadable `version` file can stop bulk restore while RocksDB and the block 
files are intact. Previously a lookup for an untracked hash could still recover 
the block and return it to the eviction queues. After `FAILED`, this gate 
disables that path, the leak cleaner never starts, and the factory still keeps 
the cache online. On a disk already above the resource threshold, startup 
reservation can find no tracked victims and return `SKIP_CACHE` even for 
previously cached keys, while the old files continue to occupy the disk. 
Recover or reclaim those entries without allowing stale removals to be restored.



##########
be/src/io/cache/fs_file_cache_storage.cpp:
##########
@@ -1179,6 +1193,9 @@ void 
FSFileCacheStorage::load_file_blocks_directly_unlocked(
                          << ", value_error=" << 
iterator->get_last_value_error().to_string();
             continue;
         }
+        if (mgr->is_removed_during_async_open(hash, meta_key.offset, 
cache_lock)) {

Review Comment:
   [P2] Fence refills against an older queued unlink. If GC has removed the 
last in-memory cell for a hash but has not unlinked its file yet, this check 
skips the still-present RocksDB record and lets `get_or_set()` admit an `EMPTY` 
cell. A normal reader can finalize its refill to the same v3 path before GC 
resumes. The old `remove(key)` then unlinks the replacement and can delete its 
metadata, leaving a `DOWNLOADED` cell that cannot be read. Keep the offset 
ineligible for refill until the pending removal finishes, or make removal 
generation-aware. The new test pauses GC at exactly this point but drops the 
empty cell and waits for unlink before it writes.



##########
be/src/io/cache/block_file_cache.cpp:
##########
@@ -2655,6 +2658,24 @@ void BlockFileCache::run_background_gc() {
     }
 }
 
+bool BlockFileCache::is_removed_during_async_open(
+        const UInt128Wrapper& hash, size_t offset,
+        std::lock_guard<std::mutex>& /*cache_lock*/) const {
+    return _removed_during_async_open.contains(AccessKeyAndOffset(hash, 
offset));
+}
+
+void BlockFileCache::mark_async_open_done() {
+    SCOPED_CACHE_LOCK(_mutex, this);
+    std::unordered_set<AccessKeyAndOffset, 
KeyAndOffsetHash>().swap(_removed_during_async_open);

Review Comment:
   [P3] Reclaim the tombstone set after releasing the cache mutex. The 
swapped-out temporary is destroyed at the end of this statement, so both 
terminal transitions deallocate every recorded tombstone while holding 
`_mutex`. The set can grow with all distinct removals during a long restore, 
and lookups wait for the entire cleanup. Swap into a local declared outside the 
lock scope and publish the terminal state while still holding the lock.



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