Fix build caused by DeleteFile not tolerating / at the beginning
Summary: db->DeleteFile calls ParseFileName to check name that was returned for sst file. Now, sst filename is returned using TableFileName which uses MakeFileName. This puts a / at the front of the name and ParseFileName doesn't like that. Changed ParseFileName to tolerate /s at the beginning. The test delet_file_test used to pass earlier because this behaviour of MakeFileName had been changed a while back to not return a / during which delete_file_test was checked in. But MakeFileName had to be reverted to add / at the front because GetLiveFiles used at many places outside rocksdb used the previous behaviour of MakeFileName. Test Plan: make;./delete_filetest;make all check Reviewers: dhruba, haobo, vamsi Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D12663
This commit is contained in:
parent
f121c4f504
commit
ab5c5c28fe
@ -3042,8 +3042,7 @@ Status DBImpl::DeleteFile(std::string name) {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBImpl::GetLiveFilesMetaData(
|
void DBImpl::GetLiveFilesMetaData(std::vector<LiveFileMetaData> *metadata) {
|
||||||
std::vector<LiveFileMetaData> *metadata) {
|
|
||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
return versions_->GetLiveFilesMetaData(metadata);
|
return versions_->GetLiveFilesMetaData(metadata);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ TEST(DeleteFileTest, DeleteFileWithIterator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status status = db_->DeleteFile(level2file);
|
Status status = db_->DeleteFile(level2file);
|
||||||
fprintf(stderr, "Deletion status %s: %s\n",
|
fprintf(stdout, "Deletion status %s: %s\n",
|
||||||
level2file.c_str(), status.ToString().c_str());
|
level2file.c_str(), status.ToString().c_str());
|
||||||
ASSERT_TRUE(status.ok());
|
ASSERT_TRUE(status.ok());
|
||||||
it->SeekToFirst();
|
it->SeekToFirst();
|
||||||
|
@ -130,10 +130,14 @@ std::string MetaDatabaseName(const std::string& dbname, uint64_t number) {
|
|||||||
// dbname/MANIFEST-[0-9]+
|
// dbname/MANIFEST-[0-9]+
|
||||||
// dbname/[0-9]+.(log|sst)
|
// dbname/[0-9]+.(log|sst)
|
||||||
// dbname/METADB-[0-9]+
|
// dbname/METADB-[0-9]+
|
||||||
|
// Disregards / at the beginning
|
||||||
bool ParseFileName(const std::string& fname,
|
bool ParseFileName(const std::string& fname,
|
||||||
uint64_t* number,
|
uint64_t* number,
|
||||||
FileType* type) {
|
FileType* type) {
|
||||||
Slice rest(fname);
|
Slice rest(fname);
|
||||||
|
if (fname.length() > 1 && fname[0] == '/') {
|
||||||
|
rest.remove_prefix(1);
|
||||||
|
}
|
||||||
if (rest == "CURRENT") {
|
if (rest == "CURRENT") {
|
||||||
*number = 0;
|
*number = 0;
|
||||||
*type = kCurrentFile;
|
*type = kCurrentFile;
|
||||||
|
Loading…
Reference in New Issue
Block a user