Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](regression) spare .testfile to make disk checker happy when injecting fault #29477

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading