From 88a8fdf849ce38ae782fbb4e34d9003266e02401 Mon Sep 17 00:00:00 2001 From: Omkar Gawde Date: Fri, 11 Sep 2026 04:35:03 -0700 Subject: [PATCH] Compare excluded-file lookup against the engine it searched (#15197) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/15197 **What**: Compare the excluded-file lookup iterator against the engine it was obtained from, in `BackupEngineImpl::RestoreDBFromBackup()`. **How**: The loop walks `locked_restore_from_dirs` calling `find()` on each engine's `backuped_file_infos_`, but tested the result against `this` engine's `end()`. Test against the same engine's `end()`. **Why**: Comparing iterators obtained from different containers is undefined. It is inert here rather than a live bug: on libstdc++ and libc++ an `unordered_map` end iterator is a null sentinel that is not container-specific, so a miss compares equal and a hit does not. On an implementation with a container-specific end iterator - MSVC, a required CI axis - a miss would read as found and dereference the sentinel node. No test can pin this; see the test plan. Reviewed By: xingbowang Differential Revision: D119585045 fbshipit-source-id: 9ff0e770b426f6a2c4a0fdad261910a927d1bfa7 --- utilities/backup/backup_engine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/backup/backup_engine.cc b/utilities/backup/backup_engine.cc index 283991c3bd..8a78394572 100644 --- a/utilities/backup/backup_engine.cc +++ b/utilities/backup/backup_engine.cc @@ -1729,7 +1729,7 @@ IOStatus BackupEngineImpl::RestoreDBFromBackup( bool found = false; for (auto be : locked_restore_from_dirs) { auto it = be->backuped_file_infos_.find(file); - if (it != backuped_file_infos_.end()) { + if (it != be->backuped_file_infos_.end()) { restore_file_infos.emplace_back(be, &*it->second); found = true; break;