mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
dbms: more fsync [#CONV-2944].
This commit is contained in:
parent
1acad2acb1
commit
8fc69c2a8e
@ -88,6 +88,7 @@ class LogBlockOutputStream : public IBlockOutputStream
|
||||
public:
|
||||
LogBlockOutputStream(StoragePtr owned_storage);
|
||||
void write(const Block & block);
|
||||
void writeSuffix();
|
||||
private:
|
||||
StorageLog & storage;
|
||||
Poco::ScopedWriteRWLock lock;
|
||||
@ -105,6 +106,12 @@ private:
|
||||
CompressedWriteBuffer compressed;
|
||||
|
||||
size_t plain_offset; /// Сколько байт было в файле на момент создания LogBlockOutputStream.
|
||||
|
||||
void sync()
|
||||
{
|
||||
compressed.next();
|
||||
plain.sync();
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<std::pair<size_t, Mark> > MarksForColumns;
|
||||
|
@ -70,6 +70,7 @@ class TinyLogBlockOutputStream : public IBlockOutputStream
|
||||
public:
|
||||
TinyLogBlockOutputStream(StoragePtr owned_storage);
|
||||
void write(const Block & block);
|
||||
void writeSuffix();
|
||||
private:
|
||||
StorageTinyLog & storage;
|
||||
|
||||
@ -83,6 +84,12 @@ private:
|
||||
|
||||
WriteBufferFromFile plain;
|
||||
CompressedWriteBuffer compressed;
|
||||
|
||||
void sync()
|
||||
{
|
||||
compressed.next();
|
||||
plain.sync();
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map<std::string, SharedPtr<Stream> > FileStreams;
|
||||
|
@ -144,6 +144,7 @@ void StorageChunks::appendChunkToIndex(const std::string & chunk_name, size_t ma
|
||||
WriteBufferFromFile index(index_path, 4096, O_APPEND | O_CREAT | O_WRONLY);
|
||||
writeStringBinary(chunk_name, index);
|
||||
writeIntBinary<UInt64>(mark, index);
|
||||
index.sync();
|
||||
}
|
||||
|
||||
void StorageChunks::dropThis()
|
||||
|
@ -216,6 +216,18 @@ void LogBlockOutputStream::write(const Block & block)
|
||||
}
|
||||
|
||||
|
||||
void LogBlockOutputStream::writeSuffix()
|
||||
{
|
||||
/// Заканчиваем запись.
|
||||
marks_stream.sync();
|
||||
|
||||
for (FileStreams::iterator it = streams.begin(); it != streams.end(); ++it)
|
||||
it->second->sync();
|
||||
|
||||
streams.clear();
|
||||
}
|
||||
|
||||
|
||||
void LogBlockOutputStream::addStream(const String & name, const IDataType & type, size_t level)
|
||||
{
|
||||
/// Для массивов используются отдельные потоки для размеров.
|
||||
|
@ -245,6 +245,16 @@ void TinyLogBlockOutputStream::writeData(const String & name, const IDataType &
|
||||
}
|
||||
|
||||
|
||||
void TinyLogBlockOutputStream::writeSuffix()
|
||||
{
|
||||
/// Заканчиваем запись.
|
||||
for (FileStreams::iterator it = streams.begin(); it != streams.end(); ++it)
|
||||
it->second->sync();
|
||||
|
||||
streams.clear();
|
||||
}
|
||||
|
||||
|
||||
void TinyLogBlockOutputStream::write(const Block & block)
|
||||
{
|
||||
storage.check(block, true);
|
||||
|
Loading…
Reference in New Issue
Block a user