Skip to content

Commit

Permalink
[fix](regression) spare .testfile to make disk checker happy when inj…
Browse files Browse the repository at this point in the history
…ecting fault (apache#29477)

Signed-off-by: freemandealer <[email protected]>
  • Loading branch information
freemandealer authored and wsjz committed Feb 4, 2024
1 parent f36f7ec commit 705ee7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions be/src/io/fs/local_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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());
Expand Down
2 changes: 0 additions & 2 deletions be/src/olap/data_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/data_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 705ee7f

Please sign in to comment.