This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 329d20df3b2 [fix](regression) spare .testfile to make disk checker 
happy when injecting fault (#29477)
329d20df3b2 is described below

commit 329d20df3b2715afec358941be3a7bfe5ca278d8
Author: zhengyu <[email protected]>
AuthorDate: Thu Jan 4 15:09:57 2024 +0800

    [fix](regression) spare .testfile to make disk checker happy when injecting 
fault (#29477)
    
    Signed-off-by: freemandealer <[email protected]>
---
 be/src/io/fs/local_file_system.cpp | 8 ++++++--
 be/src/olap/data_dir.cpp           | 2 --
 be/src/olap/data_dir.h             | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/be/src/io/fs/local_file_system.cpp 
b/be/src/io/fs/local_file_system.cpp
index 1828c7c3d2c..a503366167f 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 d19e77f6e8e..09c50314608 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 f8a405d4ffd..811118c1c9a 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 {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to