Fix memleak when DB::DeleteFile()
Summary: Because the corresponding read_first_record_cache_ item wasn't erased, memory leaked. Closes https://github.com/facebook/rocksdb/pull/1712 Differential Revision: D4363654 Pulled By: ajkr fbshipit-source-id: 7da1adcfc8c380e4ffe05b8769fc2221ad17a225
This commit is contained in:
parent
9c2f64e148
commit
0a7ba0e548
@ -2047,8 +2047,7 @@ Status DBImpl::DeleteFile(std::string name) {
|
|||||||
name.c_str());
|
name.c_str());
|
||||||
return Status::NotSupported("Delete only supported for archived logs");
|
return Status::NotSupported("Delete only supported for archived logs");
|
||||||
}
|
}
|
||||||
status =
|
status = wal_manager_.DeleteFile(name, number);
|
||||||
env_->DeleteFile(immutable_db_options_.wal_dir + "/" + name.c_str());
|
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
ROCKS_LOG_ERROR(immutable_db_options_.info_log,
|
ROCKS_LOG_ERROR(immutable_db_options_.info_log,
|
||||||
"DeleteFile %s failed -- %s.\n", name.c_str(),
|
"DeleteFile %s failed -- %s.\n", name.c_str(),
|
||||||
|
@ -39,6 +39,15 @@ namespace rocksdb {
|
|||||||
|
|
||||||
#ifndef ROCKSDB_LITE
|
#ifndef ROCKSDB_LITE
|
||||||
|
|
||||||
|
Status WalManager::DeleteFile(const std::string& fname, uint64_t number) {
|
||||||
|
auto s = env_->DeleteFile(db_options_.wal_dir + "/" + fname);
|
||||||
|
if (s.ok()) {
|
||||||
|
MutexLock l(&read_first_record_cache_mutex_);
|
||||||
|
read_first_record_cache_.erase(number);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
Status WalManager::GetSortedWalFiles(VectorLogPtr& files) {
|
Status WalManager::GetSortedWalFiles(VectorLogPtr& files) {
|
||||||
// First get sorted files in db dir, then get sorted files from archived
|
// First get sorted files in db dir, then get sorted files from archived
|
||||||
// dir, to avoid a race condition where a log file is moved to archived
|
// dir, to avoid a race condition where a log file is moved to archived
|
||||||
|
@ -49,6 +49,8 @@ class WalManager {
|
|||||||
|
|
||||||
void ArchiveWALFile(const std::string& fname, uint64_t number);
|
void ArchiveWALFile(const std::string& fname, uint64_t number);
|
||||||
|
|
||||||
|
Status DeleteFile(const std::string& fname, uint64_t number);
|
||||||
|
|
||||||
Status TEST_ReadFirstRecord(const WalFileType type, const uint64_t number,
|
Status TEST_ReadFirstRecord(const WalFileType type, const uint64_t number,
|
||||||
SequenceNumber* sequence) {
|
SequenceNumber* sequence) {
|
||||||
return ReadFirstRecord(type, number, sequence);
|
return ReadFirstRecord(type, number, sequence);
|
||||||
|
Loading…
Reference in New Issue
Block a user