[BUG.FIX] support remove tmp file concurrently
This commit is contained in:
@ -1187,34 +1187,28 @@ int ObTmpFileManager::seek(const int64_t fd, const int64_t offset, const int whe
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObTmpFileManager::clear(const int64_t fd)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
ObTmpFileHandle file_handle;
|
|
||||||
if (OB_UNLIKELY(!is_inited_)) {
|
|
||||||
ret = OB_NOT_INIT;
|
|
||||||
STORAGE_LOG(WARN, "ObTmpFileManager has not been inited", K(ret));
|
|
||||||
} else if (OB_FAIL(files_.get(fd, file_handle))) {
|
|
||||||
STORAGE_LOG(WARN, "fail to get tmp file handle", K(ret), K(fd));
|
|
||||||
} else if (OB_FAIL(file_handle.get_resource_ptr()->clear())) {
|
|
||||||
STORAGE_LOG(WARN, "fail to clear file", K(ret));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTmpFileManager::remove(const int64_t fd)
|
int ObTmpFileManager::remove(const int64_t fd)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (OB_UNLIKELY(!is_inited_)) {
|
if (OB_UNLIKELY(!is_inited_)) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
STORAGE_LOG(WARN, "ObTmpFileManager has not been inited", K(ret));
|
STORAGE_LOG(WARN, "ObTmpFileManager has not been inited", K(ret));
|
||||||
} else if (OB_FAIL(clear(fd))) {
|
|
||||||
STORAGE_LOG(WARN, "fail to clear file", K(ret));
|
|
||||||
} else if (OB_FAIL(files_.erase(fd))) {
|
|
||||||
STORAGE_LOG(WARN, "fail to erase from map", K(ret));
|
|
||||||
} else {
|
} else {
|
||||||
ObTaskController::get().allow_next_syslog();
|
common::SpinWLockGuard guard(rm_file_lock_);
|
||||||
STORAGE_LOG(INFO, "succeed to remove a tmp file", K(fd), K(common::lbt()));
|
ObTmpFileHandle file_handle;
|
||||||
|
if (OB_FAIL(files_.get(fd, file_handle))) {
|
||||||
|
if (common::OB_ENTRY_NOT_EXIST != ret) {
|
||||||
|
STORAGE_LOG(WARN, "fail to get tmp file handle", K(ret), K(fd));
|
||||||
|
} else {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
STORAGE_LOG(INFO, "this tmp file has been removed", K(fd), K(common::lbt()));
|
||||||
|
}
|
||||||
|
} else if (OB_FAIL(files_.erase(fd))) {
|
||||||
|
STORAGE_LOG(WARN, "fail to erase from map", K(ret));
|
||||||
|
} else {
|
||||||
|
ObTaskController::get().allow_next_syslog();
|
||||||
|
STORAGE_LOG(INFO, "succeed to remove a tmp file", K(fd), K(common::lbt()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1279,7 +1273,7 @@ int ObTmpFileManager::sync(const int64_t fd, const int64_t timeout_ms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObTmpFileManager::ObTmpFileManager()
|
ObTmpFileManager::ObTmpFileManager()
|
||||||
: files_(), storage_file_(), file_handle_(), next_fd_(-1), next_dir_(-1), is_inited_(false)
|
: files_(), storage_file_(), file_handle_(), next_fd_(-1), next_dir_(-1), rm_file_lock_(), is_inited_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ObTmpFileManager::~ObTmpFileManager()
|
ObTmpFileManager::~ObTmpFileManager()
|
||||||
|
|||||||
@ -397,7 +397,6 @@ private:
|
|||||||
private:
|
private:
|
||||||
ObTmpFileManager();
|
ObTmpFileManager();
|
||||||
virtual ~ObTmpFileManager();
|
virtual ~ObTmpFileManager();
|
||||||
int clear(const int64_t fd);
|
|
||||||
int get_next_dir(int64_t& next_dir);
|
int get_next_dir(int64_t& next_dir);
|
||||||
int get_next_fd(int64_t& next_fd);
|
int get_next_fd(int64_t& next_fd);
|
||||||
void next_value(int64_t& current_val, int64_t& next_val);
|
void next_value(int64_t& current_val, int64_t& next_val);
|
||||||
@ -412,6 +411,7 @@ private:
|
|||||||
ObStorageFileHandle file_handle_;
|
ObStorageFileHandle file_handle_;
|
||||||
int64_t next_fd_;
|
int64_t next_fd_;
|
||||||
int64_t next_dir_;
|
int64_t next_dir_;
|
||||||
|
common::SpinRWLock rm_file_lock_;
|
||||||
bool is_inited_;
|
bool is_inited_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTmpFileManager);
|
DISALLOW_COPY_AND_ASSIGN(ObTmpFileManager);
|
||||||
|
|||||||
Reference in New Issue
Block a user