dbms: more fsync [#CONV-2944].

This commit is contained in:
Alexey Milovidov 2013-09-15 01:40:29 +00:00
parent 1acad2acb1
commit 8fc69c2a8e
5 changed files with 37 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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()

View File

@ -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)
{
/// Для массивов используются отдельные потоки для размеров.

View File

@ -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);