mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
1. add macosx fix
This commit is contained in:
parent
572aec481a
commit
4e7823ade7
@ -542,8 +542,13 @@ public:
|
||||
file_path,
|
||||
std::to_string(bytes_written));
|
||||
|
||||
if (::fdatasync(file.fd) < 0)
|
||||
throwFromErrnoWithPath("Cannot fsync " + file_path, file_path, ErrorCodes::CANNOT_FSYNC);
|
||||
#if defined(OS_DARWIN)
|
||||
if (::fsync(file.fd) < 0)
|
||||
throwFromErrnoWithPath("Cannot fsync " + file_path, file_path, ErrorCodes::CANNOT_FSYNC);
|
||||
#else
|
||||
if (::fdatasync(file.fd) < 0)
|
||||
throwFromErrnoWithPath("Cannot fdatasync " + file_path, file_path, ErrorCodes::CANNOT_FSYNC);
|
||||
#endif
|
||||
|
||||
current_block_index += buffer_size_in_blocks;
|
||||
|
||||
|
@ -34,10 +34,10 @@ LocalDirectorySyncGuard::~LocalDirectorySyncGuard()
|
||||
#if defined(OS_DARWIN)
|
||||
if (fcntl(fd, F_FULLFSYNC, 0))
|
||||
throwFromErrno("Cannot fcntl(F_FULLFSYNC)", ErrorCodes::CANNOT_FSYNC);
|
||||
#endif
|
||||
#else
|
||||
if (-1 == ::fdatasync(fd))
|
||||
throw Exception("Cannot fsync", ErrorCodes::CANNOT_FSYNC);
|
||||
|
||||
throw Exception("Cannot fdatasync", ErrorCodes::CANNOT_FSYNC);
|
||||
#endif
|
||||
if (-1 == ::close(fd))
|
||||
throw Exception("Cannot close file", ErrorCodes::CANNOT_CLOSE_FILE);
|
||||
}
|
||||
|
@ -114,7 +114,11 @@ void WriteBufferFromFileDescriptor::sync()
|
||||
next();
|
||||
|
||||
/// Request OS to sync data with storage medium.
|
||||
#if defined(OS_DARWIN)
|
||||
int res = ::fsync(fd);
|
||||
#else
|
||||
int res = ::fdatasync(fd);
|
||||
#endif
|
||||
if (-1 == res)
|
||||
throwFromErrnoWithPath("Cannot fsync " + getFileName(), getFileName(), ErrorCodes::CANNOT_FSYNC);
|
||||
}
|
||||
|
@ -156,7 +156,11 @@ int mainImpl(int argc, char ** argv)
|
||||
pool.scheduleOrThrowOnError([=]{ thread(fd, mode, min_offset, max_offset, block_size, count); });
|
||||
pool.wait();
|
||||
|
||||
fdatasync(fd);
|
||||
#if defined(OS_DARWIN)
|
||||
fsync(fd);
|
||||
#else
|
||||
fdatasync(fd);
|
||||
#endif
|
||||
|
||||
watch.stop();
|
||||
|
||||
|
@ -136,6 +136,13 @@ int mainImpl(int argc, char ** argv)
|
||||
|
||||
for (size_t i = 0; i < descriptors; ++i)
|
||||
{
|
||||
#if defined(OS_DARWIN)
|
||||
if (fsync(fds[i]))
|
||||
throwFromErrno("Cannot fsync", ErrorCodes::CANNOT_FSYNC);
|
||||
#else
|
||||
if (fdatasync(fds[i]))
|
||||
throwFromErrno("Cannot fdatasync", ErrorCodes::CANNOT_FSYNC);
|
||||
#endif
|
||||
if (fdatasync(fds[i]))
|
||||
throwFromErrno("Cannot fsync", ErrorCodes::CANNOT_FSYNC);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user