do a bit less work in the normal case (#5695)
Summary: i.e. if alive logfile is not being moved to archive while we are in GetSortedWalsOfType() Pull Request resolved: https://github.com/facebook/rocksdb/pull/5695 Differential Revision: D17279489 Pulled By: vjnadimpalli fbshipit-source-id: 02bcf920a75b812edba8b87c6079b4e6fd5e683c
This commit is contained in:
parent
699e1b5ede
commit
4d945c57ac
@ -312,9 +312,9 @@ Status WalManager::GetSortedWalsOfType(const std::string& path,
|
|||||||
uint64_t size_bytes;
|
uint64_t size_bytes;
|
||||||
s = env_->GetFileSize(LogFileName(path, number), &size_bytes);
|
s = env_->GetFileSize(LogFileName(path, number), &size_bytes);
|
||||||
// re-try in case the alive log file has been moved to archive.
|
// re-try in case the alive log file has been moved to archive.
|
||||||
|
if (!s.ok() && log_type == kAliveLogFile) {
|
||||||
std::string archived_file = ArchivedLogFileName(path, number);
|
std::string archived_file = ArchivedLogFileName(path, number);
|
||||||
if (!s.ok() && log_type == kAliveLogFile &&
|
if (env_->FileExists(archived_file).ok()) {
|
||||||
env_->FileExists(archived_file).ok()) {
|
|
||||||
s = env_->GetFileSize(archived_file, &size_bytes);
|
s = env_->GetFileSize(archived_file, &size_bytes);
|
||||||
if (!s.ok() && env_->FileExists(archived_file).IsNotFound()) {
|
if (!s.ok() && env_->FileExists(archived_file).IsNotFound()) {
|
||||||
// oops, the file just got deleted from archived dir! move on
|
// oops, the file just got deleted from archived dir! move on
|
||||||
@ -322,6 +322,7 @@ Status WalManager::GetSortedWalsOfType(const std::string& path,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -388,7 +389,7 @@ Status WalManager::ReadFirstRecord(const WalFileType type,
|
|||||||
if (type == kAliveLogFile) {
|
if (type == kAliveLogFile) {
|
||||||
std::string fname = LogFileName(db_options_.wal_dir, number);
|
std::string fname = LogFileName(db_options_.wal_dir, number);
|
||||||
s = ReadFirstLine(fname, number, sequence);
|
s = ReadFirstLine(fname, number, sequence);
|
||||||
if (env_->FileExists(fname).ok() && !s.ok()) {
|
if (!s.ok() && env_->FileExists(fname).ok()) {
|
||||||
// return any error that is not caused by non-existing file
|
// return any error that is not caused by non-existing file
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user