From b77cd245e8c0b9acc71ea4bb437d3780061ce484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=87=AF?= Date: Tue, 19 Mar 2024 17:40:24 +0800 Subject: [PATCH 1/4] [Fix](inverted index) fix inappropriate use of macro in inverted index fs directory error process --- .../segment_v2/inverted_index_fs_directory.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp index 05b1dc6f2189bf..bdd4f56c4990b3 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp @@ -69,12 +69,16 @@ #define PATH_DELIMITERA "/" #endif -#define LOG_AND_THROW_IF_ERROR(status, msg) \ - if (!status.ok()) { \ - auto err = std::string(msg) + ": " + status.to_string(); \ - LOG(WARNING) << err; \ - _CLTHROWA(CL_ERR_IO, err.c_str()); \ - } +#define LOG_AND_THROW_IF_ERROR(status, msg) \ + do { \ + auto _status_result = (status); \ + if (!_status_result.ok()) { \ + auto err = std::string(msg) + ": " + _status_result.to_string(); \ + LOG(WARNING) << err; \ + _CLTHROWA(CL_ERR_IO, err.c_str()); \ + } \ + } while (0) + namespace doris::segment_v2 { const char* const DorisFSDirectory::WRITE_LOCK_FILE = "write.lock"; From 4d24a3be457359b07ebf4498f9e0d26dc1aca24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=87=AF?= Date: Tue, 19 Mar 2024 17:55:34 +0800 Subject: [PATCH 2/4] [Fix](inverted index) fix inappropriate use of macro in inverted index fs directory error process --- .../inverted_index_fs_directory.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp index bdd4f56c4990b3..4eb29b2ec430f0 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp @@ -383,7 +383,8 @@ void DorisFSDirectory::init(const io::FileSystemSPtr& _fs, const char* _path, return; } bool exists = false; - LOG_AND_THROW_IF_ERROR(fs->exists(directory, &exists), "Doris compound directory init IO error") + LOG_AND_THROW_IF_ERROR(fs->exists(directory, &exists), + "Doris compound directory init IO error"); if (!exists) { auto e = "Doris compound directory init error: " + directory + " is not a directory"; LOG(WARNING) << e; @@ -425,7 +426,7 @@ bool DorisFSDirectory::fileExists(const char* name) const { char fl[CL_MAX_DIR]; priv_getFN(fl, name); bool exists = false; - LOG_AND_THROW_IF_ERROR(fs->exists(fl, &exists), "File exists IO error") + LOG_AND_THROW_IF_ERROR(fs->exists(fl, &exists), "File exists IO error"); return exists; } @@ -455,7 +456,7 @@ void DorisFSDirectory::touchFile(const char* name) { snprintf(buffer, CL_MAX_DIR, "%s%s%s", directory.c_str(), PATH_DELIMITERA, name); io::FileWriterPtr tmp_writer; - LOG_AND_THROW_IF_ERROR(fs->create_file(buffer, &tmp_writer), "Touch file IO error") + LOG_AND_THROW_IF_ERROR(fs->create_file(buffer, &tmp_writer), "Touch file IO error"); } int64_t DorisFSDirectory::fileLength(const char* name) const { @@ -481,7 +482,7 @@ bool DorisFSDirectory::doDeleteFile(const char* name) { CND_PRECONDITION(directory[0] != 0, "directory is not open"); char fl[CL_MAX_DIR]; priv_getFN(fl, name); - LOG_AND_THROW_IF_ERROR(fs->delete_file(fl), "Delete file IO error") + LOG_AND_THROW_IF_ERROR(fs->delete_file(fl), "Delete file IO error"); return true; } @@ -490,7 +491,7 @@ bool DorisFSDirectory::deleteDirectory() { char fl[CL_MAX_DIR]; priv_getFN(fl, ""); LOG_AND_THROW_IF_ERROR(fs->delete_directory(fl), - fmt::format("Delete directory {} IO error", fl)) + fmt::format("Delete directory {} IO error", fl)); return true; } @@ -504,11 +505,11 @@ void DorisFSDirectory::renameFile(const char* from, const char* to) { priv_getFN(nu, to); bool exists = false; - LOG_AND_THROW_IF_ERROR(fs->exists(nu, &exists), "File exists IO error") + LOG_AND_THROW_IF_ERROR(fs->exists(nu, &exists), "File exists IO error"); if (exists) { - LOG_AND_THROW_IF_ERROR(fs->delete_directory(nu), fmt::format("Delete {} IO error", nu)) + LOG_AND_THROW_IF_ERROR(fs->delete_directory(nu), fmt::format("Delete {} IO error", nu)); } - LOG_AND_THROW_IF_ERROR(fs->rename(old, nu), fmt::format("Rename {} to {} IO error", old, nu)) + LOG_AND_THROW_IF_ERROR(fs->rename(old, nu), fmt::format("Rename {} to {} IO error", old, nu)); } lucene::store::IndexOutput* DorisFSDirectory::createOutput(const char* name) { @@ -516,11 +517,11 @@ lucene::store::IndexOutput* DorisFSDirectory::createOutput(const char* name) { char fl[CL_MAX_DIR]; priv_getFN(fl, name); bool exists = false; - LOG_AND_THROW_IF_ERROR(fs->exists(fl, &exists), "Create output file exists IO error") + LOG_AND_THROW_IF_ERROR(fs->exists(fl, &exists), "Create output file exists IO error"); if (exists) { LOG_AND_THROW_IF_ERROR(fs->delete_file(fl), - fmt::format("Create output delete file {} IO error", fl)) - LOG_AND_THROW_IF_ERROR(fs->exists(fl, &exists), "Create output file exists IO error") + fmt::format("Create output delete file {} IO error", fl)); + LOG_AND_THROW_IF_ERROR(fs->exists(fl, &exists), "Create output file exists IO error"); assert(!exists); } auto* ret = _CLNEW FSIndexOutput(); From 4527ee82093852d8b4eb8e0e68db9ab6ced66bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=87=AF?= Date: Tue, 19 Mar 2024 18:49:56 +0800 Subject: [PATCH 3/4] [Fix](inverted index) fix inappropriate use of macro in inverted index fs directory error process --- be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp index 4eb29b2ec430f0..2f70cac31062ad 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp @@ -741,7 +741,7 @@ DorisFSDirectory* DorisFSDirectoryFactory::getDirectory( dir = _CLNEW DorisRAMFSDirectory(); } else { bool exists = false; - LOG_AND_THROW_IF_ERROR(_fs->exists(file, &exists), "Get directory exists IO error") + LOG_AND_THROW_IF_ERROR(_fs->exists(file, &exists), "Get directory exists IO error"); if (!exists) { LOG_AND_THROW_IF_ERROR(_fs->create_directory(file), "Get directory create directory IO error") From 5c57f0c45a5e12603ef51f3e0216551e8a5ab98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=87=AF?= Date: Tue, 19 Mar 2024 18:56:16 +0800 Subject: [PATCH 4/4] [Fix](inverted index) fix inappropriate use of macro in inverted index fs directory error process --- be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp index 2f70cac31062ad..08927e550ba9b8 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp @@ -744,7 +744,7 @@ DorisFSDirectory* DorisFSDirectoryFactory::getDirectory( LOG_AND_THROW_IF_ERROR(_fs->exists(file, &exists), "Get directory exists IO error"); if (!exists) { LOG_AND_THROW_IF_ERROR(_fs->create_directory(file), - "Get directory create directory IO error") + "Get directory create directory IO error"); } dir = _CLNEW DorisFSDirectory(); }