diff --git a/be/src/io/fs/local_file_system.cpp b/be/src/io/fs/local_file_system.cpp index 78ba222d1ffd8c..0445f30cc51c90 100644 --- a/be/src/io/fs/local_file_system.cpp +++ b/be/src/io/fs/local_file_system.cpp @@ -39,6 +39,7 @@ #include "io/fs/file_writer.h" #include "io/fs/local_file_reader.h" #include "io/fs/local_file_writer.h" +#include "olap/data_dir.h" #include "runtime/thread_context.h" #include "util/async_io.h" // IWYU pragma: keep #include "util/debug_points.h" @@ -60,8 +61,11 @@ Status LocalFileSystem::create_file_impl(const Path& file, FileWriterPtr* writer const FileWriterOptions* opts) { int fd = ::open(file.c_str(), O_TRUNC | O_WRONLY | O_CREAT | O_CLOEXEC, 0666); DBUG_EXECUTE_IF("LocalFileSystem.create_file_impl.open_file_failed", { - ::close(fd); - fd = -1; + // spare '.testfile' to make bad disk checker happy + if (file.filename().compare(kTestFilePath)) { + ::close(fd); + fd = -1; + } }); if (-1 == fd) { return Status::IOError("failed to open {}: {}", file.native(), errno_to_str()); diff --git a/be/src/olap/data_dir.cpp b/be/src/olap/data_dir.cpp index 80a0f7131fdad1..ec068a658133a6 100644 --- a/be/src/olap/data_dir.cpp +++ b/be/src/olap/data_dir.cpp @@ -80,8 +80,6 @@ DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(disks_state, MetricUnit::BYTES); DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(disks_compaction_score, MetricUnit::NOUNIT); DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(disks_compaction_num, MetricUnit::NOUNIT); -static const char* const kTestFilePath = ".testfile"; - DataDir::DataDir(const std::string& path, int64_t capacity_bytes, TStorageMedium::type storage_medium, TabletManager* tablet_manager, TxnManager* txn_manager) diff --git a/be/src/olap/data_dir.h b/be/src/olap/data_dir.h index 8cdb54b5ccb62a..dd1ab5da2f7cfd 100644 --- a/be/src/olap/data_dir.h +++ b/be/src/olap/data_dir.h @@ -43,6 +43,8 @@ class TxnManager; class OlapMeta; class RowsetIdGenerator; +const char* const kTestFilePath = ".testfile"; + // A DataDir used to manage data in same path. // Now, After DataDir was created, it will never be deleted for easy implementation. class DataDir {