mirror of https://github.com/milvus-io/milvus.git
fix: Fix panic caused by removing directory (#38622)
https://github.com/milvus-io/milvus/issues/38604 --------- Signed-off-by: sunby <sunbingyi1992@gmail.com>pull/38984/head
parent
0a2c964bb8
commit
f0cddfd160
|
@ -103,6 +103,9 @@ InvertedIndexTantivy<T>::InvertedIndexTantivy(
|
|||
|
||||
template <typename T>
|
||||
InvertedIndexTantivy<T>::~InvertedIndexTantivy() {
|
||||
if (wrapper_) {
|
||||
wrapper_->free();
|
||||
}
|
||||
auto local_chunk_manager =
|
||||
storage::LocalChunkManagerSingleton::GetInstance().GetChunkManager();
|
||||
auto prefix = path_;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "LocalChunkManager.h"
|
||||
#include "boost/algorithm/string/join.hpp"
|
||||
#include "boost/filesystem/directory.hpp"
|
||||
#include "log/Log.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
@ -217,10 +219,18 @@ LocalChunkManager::RemoveDir(const std::string& dir) {
|
|||
boost::system::error_code err;
|
||||
boost::filesystem::remove_all(dirPath, err);
|
||||
if (err) {
|
||||
boost::filesystem::directory_iterator it(dirPath);
|
||||
std::vector<std::string> paths;
|
||||
for (; it != boost::filesystem::directory_iterator(); ++it) {
|
||||
paths.push_back(it->path().string());
|
||||
}
|
||||
std::string files = boost::algorithm::join(paths, ", ");
|
||||
PanicInfo(FileWriteFailed,
|
||||
fmt::format("remove local directory:{} failed, error: {}",
|
||||
dir,
|
||||
err.message()));
|
||||
fmt::format(
|
||||
"remove local directory:{} failed, error: {}, files: {}",
|
||||
dir,
|
||||
err.message(),
|
||||
files));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -588,23 +588,25 @@ struct TantivyIndexWrapper {
|
|||
return reader_;
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
check_search() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
free() {
|
||||
if (writer_ != nullptr) {
|
||||
tantivy_free_index_writer(writer_);
|
||||
writer_ = nullptr;
|
||||
}
|
||||
|
||||
if (reader_ != nullptr) {
|
||||
tantivy_free_index_reader(reader_);
|
||||
reader_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
check_search() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private:
|
||||
bool finished_ = false;
|
||||
IndexWriter writer_ = nullptr;
|
||||
|
|
Loading…
Reference in New Issue