Skip to content

Commit

Permalink
[chore](fs) add a config to contorl if sync on close
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed May 25, 2024
1 parent 5aab04b commit 31eb615
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ DEFINE_mInt32(priority_queue_remaining_tasks_increased_frequency, "512");
// sync tablet_meta when modifying meta
DEFINE_mBool(sync_tablet_meta, "false");

// sync when closing a file writer
DEFINE_mBool(sync_file_on_close, "true");

// default thrift rpc timeout ms
DEFINE_mInt32(thrift_rpc_timeout_ms, "60000");

Expand Down
3 changes: 3 additions & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,9 @@ DECLARE_mInt32(priority_queue_remaining_tasks_increased_frequency);
// sync tablet_meta when modifying meta
DECLARE_mBool(sync_tablet_meta);

// sync a file writer when it is closed
DECLARE_mBool(sync_file_on_close);

// default thrift rpc timeout ms
DECLARE_mInt32(thrift_rpc_timeout_ms);

Expand Down
4 changes: 2 additions & 2 deletions be/src/io/fs/local_file_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ Status LocalFileWriter::_close(bool sync) {
_fd = -1;
return st;
};
if (sync) {
if (sync && config::sync_file_on_close) {
if (_dirty) {
#ifdef __APPLE__
if (fcntl(_fd, F_FULLFSYNC) < 0) [[unlikely]] {
return fd_reclaim_func(
return fd_reclaim_func(q
localfs_error(errno, fmt::format("failed to sync {}", _path.native())));
}
#else
Expand Down

0 comments on commit 31eb615

Please sign in to comment.