未验证 提交 bde4da0f 编写于 作者: A alexey-milovidov 提交者: GitHub

Merge pull request #20465 from azat/write-abnormal-server-termination-fixes

Fix abnormal server terminations due to write failures
......@@ -562,6 +562,7 @@ void debugIncreaseOOMScore()
{
DB::WriteBufferFromFile buf("/proc/self/oom_score_adj");
buf.write(new_score.c_str(), new_score.size());
buf.close();
}
catch (const Poco::Exception & e)
{
......
......@@ -217,6 +217,7 @@ namespace
/// Write the file.
WriteBufferFromFile out{tmp_file_path.string()};
out.write(file_contents.data(), file_contents.size());
out.close();
/// Rename.
std::filesystem::rename(tmp_file_path, file_path);
......@@ -274,6 +275,7 @@ namespace
writeStringBinary(name, out);
writeUUIDText(id, out);
}
out.close();
}
......
......@@ -50,6 +50,7 @@ struct Test
{
DB::WriteBufferFromFile wb(filename);
wb.write(reinterpret_cast<const char *>(&store), sizeof(store));
wb.close();
}
{
......
......@@ -95,8 +95,15 @@ public:
++pos;
}
virtual void sync() {}
virtual void finalize() {}
virtual void sync()
{
next();
}
virtual void finalize()
{
next();
}
private:
/** Write the data in the buffer (from the beginning of the buffer to the current position).
......
......@@ -97,6 +97,7 @@ void run(String part_path, String date_column, String dest_path)
Poco::File(new_tmp_part_path_str + "checksums.txt").setWriteable();
WriteBufferFromFile checksums_out(new_tmp_part_path_str + "checksums.txt", 4096);
checksums.write(checksums_out);
checksums.close();
Poco::File(new_tmp_part_path).renameTo(new_part_path.toString());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册