refactor: Move the file when doing Dump for FileSharedMMap#212
refactor: Move the file when doing Dump for FileSharedMMap#212zhanglei1949 merged 4 commits intoalibaba:mainfrom
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoOptimize FileSharedMMap::Dump() with atomic rename fallback
WalkthroughsDescription• Optimize FileSharedMMap::Dump() to use atomic rename when possible • Attempt fast O(1) rename on same filesystem before copying • Fall back to copy_file for cross-filesystem moves • Add Close() calls to properly release resources after dump operations Diagramflowchart LR
A["Dump called"] --> B{"path_.empty()?"}
B -->|Yes| C["Call MMapContainer::Dump"]
C --> D["Close"]
B -->|No| E["Sync"]
E --> F{"path == path_?"}
F -->|Yes| G["Close"]
F -->|No| H["Save src_path"]
H --> I["Close"]
I --> J{"Try rename"}
J -->|Success| K["Return"]
J -->|EXDEV| L["Copy file"]
L --> M["Unlink source"]
J -->|Other error| N["Throw exception"]
File Changes1. src/storages/container/file_mmap_container.cc
|
Code Review by Qodo
|
When dumping for a FileSharedMMap, we just move the underlying file to a new position.
It is OK since the file itself must be a copy of other files.
Fix #208